!set gl_typExple=$wims_read_parm
!readproc data/glossary/mathematics/geometry/macro/randalphanum_gen
!set gl_a=$(gl_rd)$(gl_typExple)

!set gl_coef=!randint 1,5
!set gl_long1=!randitem 3,4
!set gl_long2=!listcomplement $gl_long1 in 3,4

!set gl_AB=$[$gl_coef*$gl_long1]
!set gl_AC=$[$gl_coef*$gl_long2]
!set gl_BC=$[$gl_coef*5]

!set gl_data1=\mathrm{AB},\mathrm{AC},\mathrm{BC}
!set gl_data2=$gl_AB,$gl_AC,$gl_BC

!if $gl_typExple =3
  !set gl_modif1=!randint 1,3
  !if $gl_modif1=3
    !set gl_modif2=!randitem 1,2,3
  !else
    !set gl_modif2=!randitem -2,-1
  !endif
  gl_data2=!replace item number $gl_modif1 by $[$(gl_data2[$(gl_modif1)])+$(gl_modif2)] in $gl_data2
!endif

!!!set gl_data4=$[($gl_AB)^2],$[($gl_AC)^2],$[($gl_BC)^2]
!set gl_data4=$[($(gl_data2[1]))^2],$[($(gl_data2[2]))^2],$[($(gl_data2[3]))^2]

!set gl_ang=!random 0,6.28

!set gl_xB=$[$(gl_data2[1])*$[cos($gl_ang)]]
!set gl_yB=$[$(gl_data2[1])*$[sin($gl_ang)]]
!set gl_xC=$[$(gl_data2[2])*$[cos($[Pi/2+$gl_ang])]]
!set gl_yC=$[$(gl_data2[2])*$[sin($[Pi/2+$gl_ang])]]

!set gl_xMin=$[$[min($[min(0,$gl_xB)],$gl_xC)]-2]
!set gl_xMax=$[$[max($[max(0,$gl_xB)],$gl_xC)]+2]
!set gl_yMin=$[$[min($[min(0,$gl_yB)],$gl_yC)]-2]
!set gl_yMax=$[$[max($[max(0,$gl_yB)],$gl_yC)]+2]


!!! JSXGraph
!!!set gl_xsize=1
!!!set gl_ysize=1
!set gl_xsize=$[$gl_xMax-($gl_xMin)]
!set gl_ysize=$[$gl_yMax-($gl_yMin)]
!set gl_radius=$[$[min($gl_long1,$gl_long2)]*0.2]


!set gl_JXGOptions=JXG.Options.text.cssDefaultStyle = '';\
JXG.Options.text.highlightCssDefaultStyle = '';\
JXG.Options.axis.lastArrow = false;\
JXG.Options.elements.highlight=false;\
JXG.Options.point.showInfobox=false;\
JXG.Options.elements.tabindex = -1;

!set gl_BoardOptions=axis:false,\
grid:false,\
drawZero:false,\
showCopyright : false,\
showNavigation:false,\
showZoom : true,\
keepaspectratio : false,\
zoom: {factorX: 1.10,factorY: 1.10,wheel: true,needShift: true,eps: 0.001},\
pan: {\
needShift: false,\
enabled: true,\
needTwoFingers: true,\
pinchHorizontal: true,\
pinchVertical: true,\
pinchSensitivity: 7}

!set gl_code=const brd$(gl_a) = JXG.JSXGraph.initBoard('id$(gl_a)', {\
  boundingbox:[$gl_xMin,$gl_yMax,$gl_xMax,$gl_yMin],\
  $gl_BoardOptions});\
  brd$(gl_a).renderer.displayCopyright('JSXGraph v'+JXG.version,11);\
  let type_$(gl_a)=$gl_typExple;\
  let ptA_$(gl_a) = brd$(gl_a).create('point', [0, 0],{face:'cross', name:'A', strokeColor: '#858585',fixed:true,label:{autoPosition:true,offset:[5,10],fixed: false}});\
  let ptB_$(gl_a)=brd$(gl_a).create('point',[$(gl_xB),$(gl_yB)],{face:'cross',name:'B',strokeColor: '#858585',fixed:true, label:{autoPosition:true,offset:[5,10]}});\
  let ptC_$(gl_a) = brd$(gl_a).create('point', [$(gl_xC),$(gl_yC)], {face:'cross',name:'C',strokeColor: '#858585',fixed:true, label:{autoPosition:true, offset:[5,10]}});\
  if(type_$(gl_a)==0){\
    let seg_$(gl_a)=brd$(gl_a).create('segment',[ptB_$(gl_a),ptC_$(gl_a)],{strokeColor:'green',strokeWidth:4});\
  }\
  if(type_$(gl_a)!=3 && type_$(gl_a)!=4 ){\
    let angle_$(gl_a)=brd$(gl_a).create('angle',[ptB_$(gl_a),ptA_$(gl_a),ptC_$(gl_a)],{name:' ',radius:$gl_radius, strokeColor:'black', fillColor:'blue', fillOpacity:0.4});\
  }\
  let tri_$(gl_a)=brd$(gl_a).create('polygon',[ptA_$(gl_a),ptB_$(gl_a),ptC_$(gl_a)],{strokeColor: 'white',fillColor: 'blue',fillOpacity:0.2,visible:true});


  !set gl_script$(gl_a)=$gl_JXGOptions\
  $gl_code



  !if $gl_typExple =2
    !set gl_choix=!randint 1,3
    !set gl_compl=!listcomplement $gl_choix in 1,2,3
    !set gl_enonc=$(gl_data1[$(gl_compl[1])])=$(gl_data2[$(gl_compl[1])]),$(gl_data1[$(gl_compl[2])])=$(gl_data2[$(gl_compl[2])])
    !set gl_quest=$(gl_data1[$gl_choix])
    !set gl_rep=$(gl_data2[$gl_choix])
    !set gl_data3=!replace item number $(gl_choix) by $(gl_data1[$(gl_choix)]) in $gl_data2
    !set gl_data5=!replace item number $(gl_choix) by $(gl_data1[$(gl_choix)])^{2} in $gl_data4
    !set gl_egal1=$(gl_data1[3])^{2}=$(gl_data1[1])^{2}+$(gl_data1[2])^{2}
    !set gl_egal2=$(gl_data3[3])^{2}=$(gl_data3[1])^{2}+$(gl_data3[2])^{2}

    !if $gl_choix=3
      !set gl_egal3=$(gl_data5[3])=$(gl_data5[1])+$(gl_data5[2])
      !set gl_egal4=$(gl_data5[3])=$(gl_data4[3])
      !set gl_egal5=$(gl_data1[3])=\sqrt{$(gl_data4[3])}
    !else
      !if $gl_choix=2
        !set gl_egal3=$(gl_data5[2])=$(gl_data5[3])-$(gl_data5[1])
        !set gl_egal4=$(gl_data5[2])=$(gl_data4[2])
        !set gl_egal5=$(gl_data1[2])=\sqrt{$(gl_data4[2])}
      !else
        !set gl_egal3=$(gl_data5[1])=$(gl_data5[3])-$(gl_data5[2])
        !set gl_egal4=$(gl_data5[1])=$(gl_data4[1])
        !set gl_egal5=$(gl_data1[1])=\sqrt{$(gl_data4[1])}
      !endif
    !endif

    !set gl_egal6=$(gl_quest)=$gl_rep
  !endif

  !if $gl_typExple isin 34
    !set gl_enonc=$(gl_data1[1])=$(gl_data2[1]),$(gl_data1[2])=$(gl_data2[2]),$(gl_data1[3])=$(gl_data2[3])

  !endif

  !!!! TO DO !!!!
  !!!! REVOIR LA FIGURE DE EXEMPLE 3
