Subversion Repositories wimsdev

Rev

Rev 18606 | Rev 18642 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
16849 obado 1
# Canvasdraw changes log
2
## TODO :
3
- sort out the global/local variable mess...and reorganize headerfile
17576 obado 4
	 : zooming and grid: scaling needs to be more adaptive! (use constant amount of grid lines)
18606 bpr 5
## 2025 (bpr-bernardi)
18607 bpr 6
  2025/06/21: do vlines as vline, hlines as hline to avoid leaks
7
  change parseFloat in Math.trunc and ajust x2px y2px
8
  2025/06/16: modifications (no change, just way to go to CASE)
18155 schaersvoo 9
## 2024
18218 schaersvoo 10
* 23/5/2024: add 'exp' to "to_js_math()"
18571 bpr 11
* 1/5/2024:  command "dashtype" was gone fishing...there must be a much better way of dealing with prefix "dash"...
18160 schaersvoo 12
* 31/4/2024: work in progress: rewrite reset,noreset !
18155 schaersvoo 13
* 28/4/2024: prefix "dash" may be used by all 'dashable' objects
18571 bpr 14
	     which is an overload on 'dashable' syntax !!
18155 schaersvoo 15
	     use commands "noreset" and "dashed" to 'dash' all following objects...until command 'reset'
16
	     size 200,200
17
	     xrange -10,10
18
	     yrange -10,10
19
	     noreset
20
	     dashed
21
	     hline ...
22
	     vline ...
23
	     polyline ...
24
	     rect ...
25
	     circle ...
26
	     reset
27
	     etc etc
18071 schaersvoo 28
* 1/3/2024: quick fix for halfline
29
## 2023
17586 schaersvoo 30
* 23/2/2023: minor improvement for sub/sup routine for command family strings (use of space is optional)
17583 schaersvoo 31
* 22/2/2023: snaptopoints may be called multiple times (no limit) And restored MAX_INT to 128 (but it's open for change, anyway)
17581 bpr 32
* 22/2/2023: increase the limit MAX_INT to 256
17576 obado 33
* 21/2/2023: canvasmultidraw now place object with relative coords (%) instead of absolute (px)
17518 schaersvoo 34
* 13/1/2023: corrected flaw in external images 'copy & drag/drop'
16849 obado 35
## 2022
17425 schaersvoo 36
* 28/8/2022: added command "newrange xmin,xmax,ymin,ymax" see https://wimsedu.info/?topic=dessiner-des-portions-de-fonctions-sur-un-meme-graphe
16942 schaersvoo 37
* 01/8/2022: getMouse(),latest improvements related to 'reponsiveness' will fatally lockup browsers in the pixel-by-pixel filling...at least in userdraw clickfill
16920 schaersvoo 38
* 19/7/2022: checked and corrected 'dashed' objects like arc,arrowarc,ellipse...
17581 bpr 39
* 16/7/2022: solved long standing issue of dashed arrow(s) and dashed arrow(s)2
17576 obado 40
* 06/7/2022: clearbutton preserves div's with '<' && '/>' and objects placed with `placed_image_on_canvas(id)` e.g. with `id = placed*`
16910 schaersvoo 41
* 05/7/2022: corrected flaw in 'clearbutton' https://wimsedu.info/?topic=geometrie-interactive-avec-canvasdraw
16892 schaersvoo 42
* 05/7/2022: command 'group' :
43
	- still some issues with direct clicks on group members (NaN due to competing mouselisteners)
44
	- removed 'debug newlines'
45
	- external images -via command 'copy' NOT supported (too much trouble)
46
	- need to add 'copy' to dragstuff library or introduce another command...
16872 schaersvoo 47
* 26/6/2022: added keyword 'group' : provides mouse-driven movements of all objects after keyword 'group' until keyword 'kill group;
48
	- may be combined with 'slider' to move or rotate single objects or grouped objects
49
	- may not be combined with command 'drag xy' (mouse listeners are already occupied...)
50
	- may be combined with command 'onclick'
16882 schaersvoo 51
	- added objects created by command 'latex' to grouping (todo : external images etc)
16872 schaersvoo 52
 
16849 obado 53
* 23/6/2022: corrected drag&drop reply of external images (via command 'copy') when mixed with other external/internal objects...
54
 
55
	 	 #
56
	 	 size 400,400
57
	 	 xrange -10,10
58
	 	 yrange -10,10
59
	 	 grid 2,2,grey
60
	 	 linewidth 2
61
	 	 onclick
62
	 	 fcircle -6,6,50,red
63
	 	 onclick
64
	 	 fcircle -6,-6,50,green
65
	 	 noreset
66
	 	 snaptogrid
67
	 	 drag xy
68
	 	 centered
69
	 	 latex 0,0,\frac{12345}{23456} \times \frac{12345}{23456}
70
	 	 translate 4,4
71
	 	 html 0,0,<table style='border:solid red 2px'><tr><th>HTML TABLE</th></tr><tr><td><img src="gifs/en.gif" /></tr><tr><td><img src="gifs/nl.gif" /></tr><tr><td><img src="gifs/fr.gif" /></tr><tr><td><img src="gifs/cn.gif" /></tr><tr><td><img src="gifs/it.gif" /></tr></table>
72
	 	 userdraw arrow2,red
73
	 	 translate 8,8
74
	 	 copy 0,0,-1,-1,-1,-1,gifs/nl.gif
75
 
76
* 20/6/2022: Start to make canvasdraw responsive [OB] :
16845 bpr 77
	- reduce size on small screens,
78
	- use percentage instead of absolute positioning for xml/html/tex
79
	- convert mouse position coords on shrinked canvas
80
	- correct mouse coordinates when inside a scrolled wims_scrollable div
16849 obado 81
	- Replace "Ariel" font references by "Arial"
82
* 19/6/2022: added function plot to multidraw (https://wimsedu.info/?topic=userinput-function)
83
	command 'multidraw functions' will -for now- give just 2 inputfields... *TODO*: make configurable, so implement commands like 'multidraw functions5')
84
	for multiple function input fields, use multiple keywords 'function', e.g. something like:
85
	multidraw text,line,function,function,function,points
86
* 27/5/2022: added subsup to userdraw and multidraw 'text' (which is always 'centered' e.g use_offset=4)
17581 bpr 87
* 26/5/2022: corrected replyformat 100
16849 obado 88
* 23/5/2022: overriding fontfamily and use Helvetica as font for _sub ^sup  strings: all inline numbers are in script-size (80% eg the same as strings+numbers for sub/sup)
17581 bpr 89
* 21/5/2022: using 'scriptsize' imitation on sub / sup
16849 obado 90
* 20/5/2022: added a sub / sup imitation to the canvas 'string' command family
16700 schaersvoo 91
 
16849 obado 92
		size 400,400
93
		xrange -6,6
94
		yrange -6,6
95
		fontfamily 22px Arial
16700 schaersvoo 96
 
16849 obado 97
		# use single space for separation in formula...
98
		# use double space to create new word
99
		string red,-5,0,H_3 O^+ + OH^\u2212  \u2192 2H_2 O
16845 bpr 100
 
16849 obado 101
* 2/4/2022: added timeout fix for centering issue in case of MathJaX (draw_xml())
15758 schaersvoo 102
 
16849 obado 103
## 2021
104
* 14/4/2021: added flydraw command 'range xmin,xmax,ymin,ymax'
105
* 6/4/2021: corrected 'text objects' (from cmd's text/string) were not added to 'noreset', e.g. keyword 'noreset' was ignored...
17581 bpr 106
added a live example from E3/number/oefgraduation.fr
16849 obado 107
* 4/4/2021: corrected use of precompiler directive "KATEX_INSTALLED" (was not working...)
108
* 12/3/2021: add "version 0.5" to canvasdraw include file
109
* 23/2/2021:
15716 schaersvoo 110
added generic command 'kill argument'
111
work in progress
15717 schaersvoo 112
corrected wrong alternative command for jscurve
16849 obado 113
* 21/2/2021:
15715 schaersvoo 114
alternative commands now 'seachable' using js-function look()
16849 obado 115
* 19/2/2021:
15711 schaersvoo 116
slightly improved dashing of arrows (in dragstuff,userdraw & multidraw)
117
to test : other objects+dashing !
118
resetting dashing for the arrow head (head was also dashed...)
119
see https://wimsedu.info/?topic=dashed-arrows-not-dashed-in-canvasdraw
16849 obado 120
* 2/2/2021:
15690 schaersvoo 121
added command 'arcarrow|arrowarc', left,right,left/right
122
added commands 'arc','angle','arcarrow' to onclick and drag&drop
17581 bpr 123
* 17/1/2021:
15672 schaersvoo 124
corrected syntax issue in canvasmultidraw.c signalled by Opera Presto : 'forbidden function user_drawstop(evt) declaration in statement'*/
15674 schaersvoo 125
 
15673 schaersvoo 126
can not correct centering in case of MathJaX, in commands like
16849 obado 127
 
128
```
15672 schaersvoo 129
####
15673 schaersvoo 130
centered
15672 schaersvoo 131
math 0,0,\frac{1}{222}
132
####
16849 obado 133
```
134
 
15674 schaersvoo 135
Things get even worse when activating in exec.c the "Safari/MathJax bugfix : refresh display when document ready."
136
(besides the ridiculous delay !!)
137
You should really try KaTeX on these systems/browsers !!!
15672 schaersvoo 138
 
15673 schaersvoo 139
OEF example of the problem:
16849 obado 140
 
141
```
15672 schaersvoo 142
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143
\text{m1=wims(mathmlmath \frac{12344}{\pi\pi\pi\pi^{\pi}})}
144
\text{m2=wims(mathmlmath \frac{\pi\pi\pi\pi^{\pi}}{\alpha})}
145
\text{m3=wims(mathmlmath \sqrt{\pi\pi\pi\pi^{\pi}})}
146
\text{m4=wims(mathmlmath \sqrt{\frac{1223}{3344}})}
147
 
148
\statement{
149
<script type="text/javascript">
150
 function read_canvas(){
151
   var fun = eval("read_canvas"+canvas_scripts[0]);
152
   if( typeof fun === 'function'){ return fun();};
153
 };
154
 function read_dragdrop(){
17581 bpr 155
   var fun = eval("read_dragdrop"+canvas_scripts[0]);
15672 schaersvoo 156
   if(typeof fun === 'function'){return fun();};
157
 };
158
 
159
</script>
160
<br/>
161
<span id="m1" onclick="javascript:place_image_on_canvas(this.id)" >\m1</span>
162
<span id="m2" onclick="javascript:place_image_on_canvas(this.id)" >\m2</span>
163
<span id="m3" onclick="javascript:place_image_on_canvas(this.id)" >\m3</span>
164
<span id="m4" onclick="javascript:place_image_on_canvas(this.id)" >\m4</span>
165
 
166
\canvasdraw{400,400}{
167
xrange -10,10
168
yrange -10,10
169
grid 1,1,grey
170
noreset
171
# use keyword 'noreset' to avoid using keyword 'centered' before every addition of objects !
172
centered
173
fontfamily Bold Italic 42pt Courier
174
# these images are internal the reply prefix is imagepalette_0, imagepalette_1... !!
175
imagepalette gifs/ca.gif,gifs/en.gif,gifs/nl.gif,gifs/fr.gif,gifs/cn.gif,gifs/de.gif,gifs/kh.gif,gifs/it.gif
176
multicolors red,green,blue,lightblue,cyan
177
multisnaptogrid 1,1,1,1,0
178
multilinewidth 0,4,0,3,1
179
multidraw text,arrow,images,points,lines
180
math -6,6,\frac{1}{\pi}
181
math -2,2,\frac{1}{\pi}
182
math 2,-2,\frac{1}{\pi}
183
math 6,-6,\frac{1}{\pi}
184
linewidth 3
185
points red,-6,6,-2,2,2,-2,6,-6
186
mouse red,22
187
}
188
 
189
 
190
These images are external...The reply id-prefix is "placed_0_'this.id'"
191
<table><tr>
192
<td><img src="gifs/ca.gif" onclick='javascript:place_image_on_canvas(this.id);' id="ca" /></td>
193
<td><img src="gifs/nl.gif" onclick='javascript:place_image_on_canvas(this.id);' id="nl" /></td>
194
<td><img src="gifs/en.gif" onclick='javascript:place_image_on_canvas(this.id);' id="en" /></td>
195
<td><img src="gifs/fr.gif" onclick='javascript:place_image_on_canvas(this.id);' id="fr" /></td>
196
<td><img src="gifs/cn.gif" onclick='javascript:place_image_on_canvas(this.id);' id="cn" /></td>
197
<td><img src="gifs/it.gif" onclick='javascript:place_image_on_canvas(this.id);' id="it" /></td>
198
<td><img src="gifs/kh.gif" onclick='javascript:place_image_on_canvas(this.id);' id="kh" /></td>
199
<td><img src="gifs/de.gif" onclick='javascript:place_image_on_canvas(this.id);' id="de" /></td>
200
</tr>
201
</table>
202
   <input type="button" onclick="alert(read_canvas());" value="read_canvas()" />
203
   <input type="button" onclick="alert(read_dragdrop());" value="read_dragdrop()" />
204
}
16849 obado 205
```
15672 schaersvoo 206
 
16849 obado 207
* 15/1/2021:
15665 schaersvoo 208
corrected long standing flaw regarding "centered" on external stuff...tested: bitmap,svg,TeX [on KaTeX]
15669 schaersvoo 209
corrected 'onclick' for 'draw_xml()'
15665 schaersvoo 210
 
17581 bpr 211
* 14/1/2021:
15657 schaersvoo 212
only on KaTeX enabled wims, a slider title may use TeX produced by command "mathmlmath"
16849 obado 213
 
214
* 13/1/2021:
15655 schaersvoo 215
slider title may use TeX produced by command "mathmlmath"
216
 
16849 obado 217
=> oef example...
218
 
219
```
15655 schaersvoo 220
\title{slider + tex title}
221
\text{A = \frac{1}{2}}
222
\text{B = \frac{1}{3}}
223
\text{C = \frac{1}{4}}
15657 schaersvoo 224
\text{a = \(\frac{1}{2}\)}
15655 schaersvoo 225
\text{b = wims(mathmlmath \\Huge \\frac{1}{3} )}
226
\text{c = wims(mathmlmath \\Huge \\frac{1}{4} )}
227
\text{canvas=wims(exec canvasdraw
228
size 400,400
229
xrange -10,10
230
yrange -10,10
16849 obado 231
fontfamily 38px Arial
15655 schaersvoo 232
opacity 255,40
233
grid 1,1,grey
234
strokecolor red
15657 schaersvoo 235
slider -10,10,400,50,x active,\( \frac{1}{2} \)
15655 schaersvoo 236
frect -6,5,-4,-5,red
237
centered
238
latex -5,0,\A
239
killslider
240
strokecolor blue
241
slider -10,10,400,50,x active,\b
242
frect -6,5,-4,-5,blue
243
centered
244
latex -5,0,\B
245
killslider
246
strokecolor green
247
slider -10,10,400,50,x active,\c
248
frect -6,5,-4,-5,green
249
centered
250
latex -5,0,\C
251
killslider)
252
}
253
\statement{
254
canvas = \canvas
17581 bpr 255
}
16849 obado 256
```
15655 schaersvoo 257
 
16849 obado 258
* 8/1/2021:
15646 schaersvoo 259
added affine transformation to Fly text commmand analogue
15655 schaersvoo 260
 
16849 obado 261
* 3/1/2021:
15628 schaersvoo 262
added check on 'nan' in case of parametric curve
16849 obado 263
		size 260,220
264
		xrange 0,13
265
		yrange 0,11
266
		trange 0,2
267
		curve black,1/t,4*sin(t)
15540 schaersvoo 268
 
16849 obado 269
 
270
## 2020
271
* 29/12/2020:
15623 schaersvoo 272
disabled limitation of adding "curve points outside the visual ymin/ymax range" (parametric curves)
273
 
16849 obado 274
* 27/12/2020:
15611 schaersvoo 275
corrected command "parallel" , to be more compatible with flydraw & affine transformations
15613 schaersvoo 276
when a transformation is set  before command parallel...the lines may be set onclick or drag xy!
15611 schaersvoo 277
 
16849 obado 278
* 24/12/2020:
15601 schaersvoo 279
solved some issues with curve & affine/rotate...
16849 obado 280
see [https://wimstest1.di.u-psud.fr/wims/wims.cgi?lang=en&module=adm/doc&cmd=new&job=read&doc=1028&block=transform]()
15601 schaersvoo 281
 
16849 obado 282
```
15601 schaersvoo 283
size 200,200
284
xrange -5,5
285
yrange -5,5
286
linewidth 2
287
trange 0,1
288
curve blue,2*t,sin(2*pi*t)
289
affine 0,1,1,2,-1,1
290
trange 0,1
291
curve green,2*t,sin(2*pi*t)
16849 obado 292
```
15601 schaersvoo 293
 
16849 obado 294
* 22/12/2020:
295
command "fillpattern image_url" was gone fishing! `get_image_from_url()` needs to be called after function definition..
17581 bpr 296
* 16/11/2020:
16849 obado 297
	- added 'affine' to curve evaluation
15540 schaersvoo 298
 
16849 obado 299
	```
300
	size 220,220
301
	xrange -5,5
302
	yrange -5,5
303
	hline 0,0,black
304
	vline 0,0,black
305
	rotationcenter 0,0
306
	slider -2*pi,2*pi,200,28,angle degree active,Rotate
307
	linewidth 4
308
	curve blue,sin(x)
309
	affine 1,-0.2,-0.6,1,0,2
310
	curve red,sin(x)
311
	```
15540 schaersvoo 312
 
17581 bpr 313
* 13/11/2020:
16849 obado 314
	- added `safe_eval()` to userinput (using inputfields)
7614 schaersvoo 315
 
16849 obado 316
* 8/7/2020:
317
	- command `input x,y,size,readonly,value` gave canvaserror when 'value' was ommitted or a 'space'
318
	- corrected bug [https://wimsedu.info/?topic=bug-canvasdraw-et-ou-drawinput]()
319
		```
320
		case 4: temp = get_string(infile,1); --->  case 4: temp = get_string(infile,3);
321
		```
322
* 14/6/2020:
323
	- corrected bug in multidraw snaptopoints+curvedarrow
324
* 11/6/2020:
325
	- added 'touchend' to improve behaviour of touch devices in case 'userdraw' and 'multidraw' [TO TEST]
326
* 9/6/2020
327
	- touchend  not supported (eg lifting finger+tapping after dragging to signal some 'corner point')
328
	- in case of touch devices, use commands 'userinput' to enforce mathematical precise drawing and not finger painting...
329
	- function calc_lines(): 'multidraw lines' & 'userdraw line,color' returned (xmin:y1)--(xmax:y2)
330
	    that should have been (x1:y1)---(x2:y2) ...otherwise snaptogrid gives float values !
331
* 8/6/2020:
332
	- added command 'noreset' or 'killreset'
333
* 5/6/2020:
334
	- solved issue of sync loading of images (`command:html 0,0,<img src="modules/U2/geometry/oefrosoni.it/images/273x273/fig4.png"  />`)
335
 
336
	```
337
		size 400,400
338
		xrange -6,6
339
		yrange -6,6
340
		fontsize 40
341
		linewidth 1
17581 bpr 342
		slider -10,10,300,28,angle active degree,
16849 obado 343
		centered
344
		html 0,0,<img src="modules/U2/geometry/oefrosoni.it/images/273x273/fig4.png"  />
345
		killslider
346
		centered
347
		html 0,0,<img src="modules/U2/geometry/oefrosoni.it/images/273x273/fig4_ovr.png"  />
348
	```
349
 
350
	- commands math, katex, latex are identical
351
	- added compile time checking of 'katex.c' presence:
15111 schaersvoo 352
if present: use KaTeX for all browsers
353
if not present: use MathJaX (chrome) or native MathML (firefox)
16849 obado 354
	- TO DO: check if this actually works on non-KaTeX...
7614 schaersvoo 355
 
16849 obado 356
* 25/5/2020:
357
	- removed js-code for rotating (and transforming mouse-coordinates...) Now coordinates are transformed in C
358
	- slider, solved several issues (removed old slider stuff)
359
	- animated slider may be combined with manual/mouse slider
360
	- slider corrected for touch device
361
* 24/5/2020:
362
	- add keyword 'animate' to slider
7614 schaersvoo 363
 
16849 obado 364
	```
365
		size 300,300
366
		xrange -6,6
367
		yrange -6,6
368
		grid 1,1,grey
369
		linewidth 1
370
		slider 0,2*pi,300,28,angle animate active, no
371
		opacity 255,30
372
		ftriangle 2,2,-2,2,0,0,red
373
		ftriangle -2,2,-2,-2,0,0,blue
374
		ftriangle -2,-2,2,-2,0,0,green
375
		ftriangle 2,-2,2,2,0,0,orange
376
		rotationcenter 0,0
377
		frect -2,2,2,-2,black
378
	```
7614 schaersvoo 379
 
380
 
16849 obado 381
* 22/5/2020:
382
	- slider things...
383
* 21/5/2020:
384
	- minor changes: not yet really satisfied with combinations of xml+dragdrop+slider
385
	- some doc examples
386
* 20/5/2020:
387
	- slider reorganized:
388
	- restored all listeners on slider.(mousedown ,mousemove and mouseup)
389
	- update example 'angle': angle and arc are exceptions in case of sliders...they are always active (e.g. not click-activated)
390
	- added 'onclick=4' : in case of sliders ,no need for click-on-object to active the object--slider (important for objects covering each other)
391
 
392
* 18/5/2020:
393
	- restored interaction of commands 'arc' and 'angle' with sliders (specially Rotate)
394
	- drawxml() objects like katex,mathml,latex,html,obabel now interact identical as
15111 schaersvoo 395
    dragstuff library objects with slider...eg. 'first click'=select for sliders, 'second click' unselect sliders
16849 obado 396
    e.g.: `slidergroup[object_cnt] = obj or slidergroup[object_cnt] = null`
15111 schaersvoo 397
    selected sliders until 'killslider'
17581 bpr 398
 
16849 obado 399
    ```
400
	######################################################
401
	size 500,500
402
	xrange -6,6
403
	yrange -6,6
404
	grid 1,1,grey
405
	fontfamily 42px Arial
406
	opacity 255,60
407
	centered
408
	#drag xy
409
	snaptogrid
410
	slider -10,10,500,50,angle,R
411
	slider -10,10,500,50,x,X
412
	slider -10,10,500,50,y,Y
413
	# these objects act -if selected- on the above sliders
414
	katex 3,3,\frac{123}{123^{\pi}}
415
	centered
416
	obabel 0,0,smi,-:c1cccc1cc,-xb none -xP100
417
	filled
418
	fillcolor blue
419
	angle 0,0,4,0,0,red
420
	killslider
421
	linewidth 4
422
	slider -10,10,500,50,angle,Rotate rect
423
	# if selected this object will use only the above slider
424
	frect -5,5,-4,4,red
425
	##########################################################
426
	```
15271 bpr 427
 
16849 obado 428
* 15/5/2020:
429
	- further reduced size of 'plain' grid (like 'grid 1,1,grey')
430
	- using uniform "slidergroup[object_cnt] = object" to avoid difficulies with reply's of dragstuff/xml [IN PROGRESS]				         __
431
	- slider appearance changed to :  _____\/______________
7614 schaersvoo 432
 
16849 obado 433
	- xml-objects (katex/latex/mathml/html) and slider: onclick will activate slider for object and deactivate after second click
14071 bpr 434
 
16849 obado 435
	```
436
	size 500,500
437
	xrange -6,6
438
	yrange -6,6
439
	grid 1,1,grey
440
	fontfamily 42px Arial
441
	strokecolor red
442
	fillcolor orange
443
	#rotationcenter 0,0
444
	slider -12,12,500,50,angle,rotate
445
	katex 0,0,\frac{1}{2}
446
	katex 3,3,\frac{1}{3}
447
	katex -3,3,\frac{9}{3}
448
	#latex 0,0,\frac{1}{2}
449
	#latex 3,3,\frac{1}{3}
450
	#latex -3,3,\frac{9}{3}
451
	obabel 0,5,smi,-:c1cFccc1cc,-xb none,-xB blue,-xi,-xt,-xa,-xX,-xP100,-h
452
	html 3,-3,<img src='gifs/en.gif' />
453
	html 4,-2,<H2>OK?</H2>
454
	html -4,-2,<input size='4' value='?" />
455
	```
14071 bpr 456
 
16849 obado 457
	- added import of 'TD' and 'TH' elements with an unique 'id' and onclick='javascript:place_image_on_canvas(this.id)' to the canvas
14071 bpr 458
 
16849 obado 459
* 13/5/2020:
460
	- fixed several incompatibilities
461
	- moved legend_cnt,linegraph_cnt barchar_cnt variables (used by 'grid') to global. reducing the size of default grid
462
 
463
* 12/5/2020:
464
	- reorganized command copy/copyresized: reply is now js-object, identical to dragstuff library
465
	- onclick/drag of 'copy images' transparent integration with dragstuff objects onclick/drag and external XML material
466
	- slider is not supported for flydraw analogues copy/copyresized : use command `html x,y,<img src='gifs/en.gif' />`
467
	- IOS fixed (thx Olivier Obado)
468
	- renamed variable 'click_cnt' into 'object_cnt' : it counts all interactive (onclick,dragdrop,slider) objects and results
15111 schaersvoo 469
    in a uniform 'reply' object{}
14071 bpr 470
 
16849 obado 471
* 8/5/2020:
472
	- finished commands 'html','katex','latex','mathml' using draw_xml()
15271 bpr 473
    with 'html' virtually all material can be imported
15111 schaersvoo 474
    affine operations and sliders are supported
16849 obado 475
	- corrected reply & slider
476
* 6/5/2020:
477
	- added imported object to sliders [work in progress]
478
	- added rotation center to draw_xml(obj); [only for command katex]
479
* 5/5/2020:
480
	- changed draw_xml() to object, for importing svg,img,div,p,span,mathml,katex in canvasdraw
481
	- added transformation matrix to draw_xml(). Preparing for slider manipulation of imported objects
482
* 3/5/2020: corrected error avoiding multiple calls to 'obabel'
483
* 1/5/2020: killed 'stderr' default message from 'obabel' : "converted 1 molecule"
484
* 30/4/2020:
485
	- added command 'katex x,y,tex-string'
486
	- thus bypassing cludge between firefox/mathml/mathjax/katex
487
	- for traditional wims (using MathML) use command 'latex x,y,tex-string' or 'mathml x,y,xml-code'
488
	- for katex-only wims, use only 'katex'
489
	- solved 'centered' and 'snaptogrid' issues dealing with drag&drop of generated 'svg/mathml/xml/html/js-code'
490
	- added link to 'howto katex and wims'
7614 schaersvoo 491
 
16849 obado 492
* 21/4/2020:
493
	- using execvp() to call "obabel" , using $PATH
7614 schaersvoo 494
 
16849 obado 495
* 20/4/2020:
496
	- changed command 'smiles' into 'obabel'
497
	- now all formats may be used as input
498
	- obabel 5,5,mol,$module_dir/mymolfile.mol,-xb none,-xB blue,-xi,-xt,-xa,-xX,-xP180,-h
499
	- obabel -5,-5,smi,-:c1ccFccc1,-xb none,-xB blue,-xi,-xt,-xa,-xX,-xP180,-h
500
	- added check on 'forbidden argument' to call obabel
14071 bpr 501
 
16849 obado 502
* 18/4/2020:
503
	- added command 'smiles args' , calling -if installed- 'obabel' to produce an SVG image
504
	- added command 'chemtex' , adding "mhchem.js" for typesetting (needs to come first!)
505
	- chemtex: added bogus code for mathjax. THIS WILL ONLY WORK ON KATEX ENABLED WIMS !
506
 
507
```
15111 schaersvoo 508
chemtex
509
size 400,400
510
xrange -10,10
511
yrange -10,10
512
fillcolor green
513
grid 1,1,grey
514
drag xy
515
centered
516
smiles 5,5,-:c1cFccc1cc,-xb none,-xB blue,-xi,-xt,-xa,-xX,-xP180,-h
517
rotate 180
518
drag xy
519
centered
520
smiles -5,-5,-:c1cFccc1cc,-xb none,-xB blue,-xi,-xt,-xa,-xX,-xP180,-h
521
drag xy
522
rotate -90
523
centered
524
smiles -5,5,-:c1cFccc1cc,-xb none,-xB blue,-xi,-xt,-xa,-xX,-xP180,-h
525
zoom red
526
drag xy
527
killrotate
16849 obado 528
fontfamily 32px Arial
15271 bpr 529
latex 0,0,\frac{1}{2} \ce{H3O+}
16849 obado 530
```
7991 schaersvoo 531
 
16849 obado 532
* 15/3/2020:
533
	- command latex ; improve code...minor cosmetic things (need to test on android)
534
	- changed syntax command html : 'html x,y,some-html-code'
535
	- drag/drop centering for html/latex/mathml/images
536
 
537
```
15111 schaersvoo 538
size 500,500
539
xrange -10,10
540
yrange -10,10
541
grid 1,1,grey
542
linewidth 3
543
vline 0,0,green
544
hline 0,0,green
16849 obado 545
fontfamily 16px Arial
15111 schaersvoo 546
fillcolor red
547
strokecolor blue
548
drag xy
549
centered
550
latex 0,0,\frac{12345}{23456} \times \frac{12345}{23456}
551
drag xy
552
centered
553
latex 5,5,\frac{12345}{\frac{12345}{ \frac{12345}{12345}}}
554
centered
555
drag xy
556
html -5,5,<table border=1><tr><td>1234567</td></tr><tr><td>1234567</td></tr><tr><td>1234567</td></tr><tr><td>1234567</td></tr></table>
557
drag xy
558
centered
559
copy 5,-5,-1,-1,-1,-1,gifs/images/skull_and_crossbones50.png
560
centered
561
drag xy
562
html 5,0,<img src=gifs/images/skull_and_crossbones50.png />
16849 obado 563
```
7991 schaersvoo 564
 
565
 
16849 obado 566
* 13/3/2020:
567
	- corrected stupid error in default replyformat
568
	- added support for touch/android for 'drag_xml()' 'drag_external_images()'
569
	- unified onclick/drag&drop answer format for MathML,JS_TeX,bitmap-images,html5-canvas-objects
570
	- compiler warnings (BPR)
14071 bpr 571
 
16849 obado 572
* 10/3/2020:
573
	- command 'rotate angle (deg)' now works for 'draw_xml()' e.g. for commands like latex,mathml,html,video,audio etc
574
	- corrected drag&drop reply for external things...
8112 schaersvoo 575
 
16849 obado 576
* 7/3/2020:
577
	- command functionlabel is now converted to js-array "functionlabel f(x)=:g(x)=:h(x)=:f'(x)="
578
	- so multiple funtion inputs may all have different colours and function agruments
8112 schaersvoo 579
 
16849 obado 580
* 6/3/2020:
581
	- added alternative command 'userdraw function,color' , is identical to 'userinput function'
582
	- added alternative command 'userdraw functions[n],color' , is identical to n-times 'userinput function' (n=1..9)
583
	- command 'multistrokecolors' or 'multicolors' may be used for setting  function argument/plot colour
14071 bpr 584
 
16849 obado 585
* 15/2/2020:
586
	- corrected flaw in drawing+zooming+multiple jscurves
587
	- userinput for arrows and polylines (forgotten and corrected)
588
	- zooming js-curves created by 'userinput function' (or should it be 'userdraw function'?...)
15111 schaersvoo 589
    will adapt to new x/y-ranges after re-clicking the 'draw' or 'OK' button. This is a flaw and not a feature !!
590
 
16849 obado 591
* 13/2/2020:
592
	- corrected stuff related to 'onclick'
593
	- corrected combo of clickreply+dragreply
15111 schaersvoo 594
 
16849 obado 595
* 11/2/2020:
596
	- corrected commands 'arc' and 'angle'
597
	- reset() will not reset the 'use_rotate' eg only 'killrotate' will set 'angle = 0.0'
598
	- default css_class="none"
599
	- corrected flaw in command 'input' ('style' is no longer needed...-> css)
15111 schaersvoo 600
 
16849 obado 601
* 9/2/2020:
602
	- restored command 'userinput function|inputfield'
603
	- 'userdraw text,color' uses `text_inputfield+mouse` and/or `text_inputfield+xy-inputfields`
15271 bpr 604
 
16849 obado 605
* 7/2/2020:
606
	- made a few corrections (Marina)
607
	- 'userinput inputfield'
15111 schaersvoo 608
 
16849 obado 609
* 6/2/2020:
610
	- added (forgotten) 'userdraw demiline(s),color'
611
	- restored command 'userinput inputfields|textarea|function'
15111 schaersvoo 612
 
16849 obado 613
* 5/2/2020:
614
	- forgotten rotation/translation for object 'segment'
615
	- restored 'setlimits' and added 'redraw_jsplot()'
616
	- added 'jsplot' to 'zoom'
15111 schaersvoo 617
 
16849 obado 618
* 4/2/2020:
619
	- restored copy/copyresized with onclick or drag xy
620
	- start with affine transformation without using canvas/html5 transform system (e.g. drag&drop&click will work for transformed objects)
15111 schaersvoo 621
    [work in progress]
16849 obado 622
	- added commands 'linear a,b,c,d' and 'killlinear|killinear' (flydraw compatibility needs to be tested)
623
	- updated internal doc's; (todo : example scripts)
624
	- added forgotten userdraw arrow(s)2,color
15111 schaersvoo 625
 
16849 obado 626
* 31/1/2020:
627
	- cleaning: removed unused js-functions
628
	- work in progress: combined drag/drop external images, draggable copy/resized images and dragstuff objects
15111 schaersvoo 629
 
16849 obado 630
* 30/1/2020:
631
	- userdraw zooming ; marked 'canvas-zoom-buttons' forbidden (eg clicking on zoom will not produce extra userdrawing clicks...)
632
	- start with cleaning...
15271 bpr 633
 
16849 obado 634
* 29/1/2020:
635
	- minor stuff
15111 schaersvoo 636
 
16849 obado 637
* 28/1/2020:
638
	- restored 'userdraw dotfill...textfill,color|text' (pattern filling)
639
	- restored 'userdraw inputs'
640
	- changed 'style' for elements by command 'css some_css' for buttons etc (style="xxxx" --> class="xxxx" )
15111 schaersvoo 641
 
16849 obado 642
* 26/1/2020:
643
	- restored 'userdraw clickfill,color' (the lrest like 'userdraw dotfill,color' not yet ready)
15111 schaersvoo 644
 
16849 obado 645
* 25/1/2020:
646
	- rightmouse click removes last drawn userdraw thing
15111 schaersvoo 647
(including svg/div/p/span/images/inputfields...eg non-canvas elements)
16849 obado 648
	- restored 'userdraw inputs,color'
15271 bpr 649
 
16849 obado 650
* 24/1/2020:
651
	- restored "userdraw" image(s),arc(s),parallelogram(s)  etc
15111 schaersvoo 652
 
16849 obado 653
* 22/1/2020:
654
	- moving "userdraw" things to separate file, simular to "multidraw"
15111 schaersvoo 655
    work in progress...not all primitives are implemented.
656
    giving further reduction of resulting javascript filesize
657
 
16849 obado 658
* 17/1/2020
659
	- zooming : added mouse wheel zoom-in-out
15111 schaersvoo 660
	    : restored panning and reset (x) is now back to original x|y min|max
661
	    : added basic support for touch devices
662
	    : TODO adjust zooming params
663
 
16849 obado 664
* 16/1/2020
665
	- removed unused variables (clang, compiled with: -Weverything)
666
	- zoom & drag/drop
667
	- TODO: zoom & other-grid-types ; use mousewheel & tablets?
15111 schaersvoo 668
 
16849 obado 669
* 11/1/2020
670
	- corrected long standing design flaw (zooming would reset dragged objects...)
671
	- modified command grid (concering zooming)
672
	- TODO : rethink zooming & panning !!
15111 schaersvoo 673
 
16849 obado 674
	```
675
	##############
676
	performance/size_reductions:
17581 bpr 677
 
16849 obado 678
	U1/logic/oefmap.fr&+cmd=new&defaultlist=free01&+exo=free01&+qnum=1&+scoredelay=&+seedrepeat=0&+qcmlevel=1
679
		- old canvasdraw version approx 40 kb
680
		- new canvasdraw version approx 20 kb
681
		- latest canvasdraw version approx 18 kb
17581 bpr 682
 
16849 obado 683
	H5/analysis/gebieden-1.nl&subject=4&level=0&total_exos=3&rounding=-1&usage=2&taal=nl
684
		- old canvasdraw version approx 83 kb
685
		- new canvasdraw version approx 38 kb
686
	##############
687
	```
15111 schaersvoo 688
 
16849 obado 689
	- split large files into fragments:still needs some further shifting/reorganizing
690
	- multidraw: add draw primitive: crosshair | crosshairs (draw_type no. 25 | 26)
691
    TODO: arc,angle,ellipse??
15111 schaersvoo 692
 
16849 obado 693
	- multidraw: finished fillpatterns
15111 schaersvoo 694
 
16849 obado 695
```
8379 schaersvoo 696
size 400,400
697
xrange -10,10
698
yrange -10,10
15111 schaersvoo 699
grid 1,1,grey
700
linewidth  3
701
snaptogrid
702
multilinewidth 1,2,3,1,2,3
703
multifillcolors red,green,blue,brown,cyan,yellow
704
multistrokecolors red,green,blue,brown,cyan,yellow
705
#solid, grid, hatch, diamond, dot, none
706
multifill 1,2,3,4,0
707
multidraw rects,circles,triangles,poly5,parallelogram,points
16849 obado 708
```
8379 schaersvoo 709
 
16849 obado 710
* 10/1/2020
711
	- simplified 'fillpattern' for static and dynamic objects
712
	- multidraw:
15111 schaersvoo 713
    started with implementing fillpatterns for multidraw (only rects/circles for now)
714
    command: multifill 0,1,2,3,4,5 ... none,fillcolor,grid,hatch,diamond,dot
715
    image filling not yet ready...
16849 obado 716
	- corrected flaw in 'ellipses'
717
	- corrected docs for 'ellipse | ellipses'
718
	- corrected zoom issue (minimized code increase)
8448 schaersvoo 719
 
16849 obado 720
* 8/1/2020
721
	- added a few other object to "non-html5-canvas" rotation
14071 bpr 722
 
16849 obado 723
* 6/1/2020
724
	- "stringup" now can be "onclick & dragdrop"
15111 schaersvoo 725
eg: stringup == string+angle+mouse_rotation-code
726
note: no need to reset rotation through 'killrotate'
17581 bpr 727
 
16849 obado 728
	```
729
	onclick
730
	rotate 45
731
	string red,0,0,AAAAAA
732
	killrotate
733
	string red,4,4,BBBBBB
734
	```
17581 bpr 735
 
16849 obado 736
	is identical with:
17581 bpr 737
 
16849 obado 738
	```
739
	onclick
740
	stringup red,0,0,45,AAAAAA
741
	string red,4,4,BBBBBB
742
	```
14071 bpr 743
 
16849 obado 744
	- dragstuff using C-switch
745
	- code kbytes:
14071 bpr 746
 
16849 obado 747
```
15271 bpr 748
 minimal: 		 4 kb
15111 schaersvoo 749
 grid only: 		15 kb
750
 userdraw only: 	10 kb
751
 multidraw single:	18 kb
752
 multidraw all: 	40 kb
753
 onclick + objects: 	14 kb
754
 drag xy + objects: 	14 kb
755
 typical exercise : 	30 kb
16849 obado 756
```
15271 bpr 757
 
16849 obado 758
* 4/1/2020
759
	- moved dragstuff code : needs to simplify
760
	- start to move HTML5/Canvas transformation things to canvasdraw.c:
761
		- e.g. just recalculate the coordinates for objects: so there is no need for recalculating mouse coordinates in case of onclick/drag
762
		- except for 'text' and ?
763
		- keep optional mouse coordinate recalculation when using HTML5 transformations...
9266 schaersvoo 764
 
15271 bpr 765
 
16849 obado 766
* 11/2019
767
	- rewrite of multidraw code and removal of verbatim js-code
768
	A few notes:
769
	- command 'inputstyle' will be used for setting 'css class' of the multidraw control table
15111 schaersvoo 770
    for example: inputstyle wimstable
16849 obado 771
	- when using a single draw primitive , command 'multilable nocontrols' will remove the 'control buttons'
772
	- when using keyword "duplicates" || "allowdups"  multiple identical points will NOT be removed from the student answer/reply
773
	- drag&drop math typesetting onto canvasdraw image:
774
	    - multidraw|userdraw images will only work with Mathml (through !insmath etc) if you use the 'wims modules svn' version of wims_mathml !!
775
		- e.g. things like !insdraw  \mmlid{123} \frac{1}{\pi}
776
		- of course the 'id' will only be added to a single call: this will NOT work: \mmlid{1} \frac{1}{\pi} + \mmlid{2} \frac{\pi}{2}
777
	   - multidraw|userdraw images and MathJaX will not work !
778
	   - multidraw|userdraw images and native MathML and KaTeX will work
779
	- drag&drop external material onto canvasdraw image:
780
		- all objects/content of type 'p','span','div','bitmap image','svg image' with an unique 'id' and
15111 schaersvoo 781
       onclick handler "onclick='javascript:place_image_on_canvas(this.id)'" may be placed onto a canvasdraw image
782
       when 'userdraw images,boguscolor' or 'multidraw images,...' is declared.
16849 obado 783
	- currently implemented multidraw primitives:
784
		*     "point","points",
785
		*     "circle","circles",
786
		*     "line","lines",
787
		*     "segment","segments",
788
		*     "arrow","arrows",
789
		*     "triangle","triangles",
790
		*     "closedpoly",
791
		*     "text",
792
		*     "rect","rects",
793
		*     "poly","polys",
794
		*     "parallelogram","parallelograms",
795
		*     "images",
796
		*     "curvedarrow","curvedarrows",
797
		*     "curvedarrow2","curvedarrows2"
15271 bpr 798
 
16849 obado 799
	- TODO: add a few more draw primitives, like
15111 schaersvoo 800
    "crosshair(s)","ellipse(s)","arc(s) || angle(s)"...
15271 bpr 801
 
802
 
15111 schaersvoo 803
############## REWRITE ################################
11769 schaersvoo 804
 
15111 schaersvoo 805
added 'angle' to draw_xml()10/4/2020
806
typo in 'case 12' command 'arc'
16849 obado 807
 
808
* 23/3/2020
15111 schaersvoo 809
added alternative commands for a few 'multidraw' subcommands
810
typo in doc
16849 obado 811
* 29/1/2020
15111 schaersvoo 812
stringup may now be set onclick (drag&drop not supported: is implemented in 'canvasdraw.min')
813
corrected non-univeral path to wims_mathml
16849 obado 814
* 6/1/2020
15111 schaersvoo 815
forgotten to reset angle=0 in 'killrotate'
16849 obado 816
 
817
## 2019
818
* 26/12/2019
15111 schaersvoo 819
NO support for dragging and transformation / rotations
820
generic mouse coordinate transformation ( transform_mouse(x,y,obj) ) usable for 'affine transformation' and 'onclick'
16849 obado 821
* 25/12/2019
15111 schaersvoo 822
 
823
"drag" and "rotate" WILL NOT WORK !!
824
"onclick" and "rotate" may be combined. (see createxo help "rotate")
825
 
826
adjusted documentation.
827
string/text using 'xoffset','xyoffset','yoffset' will now use a 2*linewidth marge
828
22/12/2019
829
 
16849 obado 830
object 10: clicked
15271 bpr 831
object 9 : clicked
15111 schaersvoo 832
object 8 : not clicked
833
object 7 : not clicked
834
object 6 : clicked
835
object 5 : moved from (1:2) -> (2:2)
836
object 4 : not moved
837
object 3 : moved from (1:1) -> (3:3)
838
object 2 : moved from (1:3) -> (3:2)
839
object 1 : moved from (1:0) -> (2:1)
840
object 0 : not moved
841
reply = ["not_moved", "1:1:0:2:1:0", "2:0:1:3:2:0", "3:1:1:3:3:0", "not_moved", "5:1:2:2:2:0",1,0,0,1,1]
15271 bpr 842
for example:
15111 schaersvoo 843
 
844
the clicked objects are '0' or '1'
845
obj_number,xorg[0],yorg[0],xnew[0],ynew[0],new_angle
846
moved object are items in the javascript reply array...in the same order as their appearance in the fly_script
847
unmoved object are labelled "not_moved" !
848
"onclick" and "drag x|y|xy" may now be used together and all data be read using "read_dragdrop()"
849
 
850
[ these are bugs, not features... ]
851
drag xy & rotate are only compatible if you are using a 'slider'
852
onclick & rotate are not compatible
853
impoved mouse selection of text (height of selection box was not ok)
854
corrected missing font-change when text was set 'onclick' [BPR]
855
 
16849 obado 856
* 21/12/2019
15111 schaersvoo 857
corrected wrong hexcolor conversion [Sophie Lemaire]
16849 obado 858
 
859
* 12/11/2019
15111 schaersvoo 860
if set, multiple identical points will NOT be removed from the student answer/reply
861
added keyword "duplicates" || "allowdups" for default "multidraw" replyformat
16849 obado 862
* 9/11/2019
15111 schaersvoo 863
corrected multidraw curvedarrows numeric input [BPR]
16849 obado 864
* 8/11/2019
865
correction in multidraw circles : list_uniq(A,B,C) will reserve 'C' for non-numeric answers !
15111 schaersvoo 866
 
16849 obado 867
* 2/11/2019
15271 bpr 868
this will break module "H4/logic/logica-1.nl/exos/exo14" (only dutch module, so no serious conflicts)
15111 schaersvoo 869
reply format for "multidraw" in case of "circles" will give radius in x-range [BPR]
870
 
16849 obado 871
* 2/11/2019
872
 
873
```
15111 schaersvoo 874
#######
875
}
876
<input type="button" onclick="alert(read_dragdrop());" value="read_dragdrop()" />
877
<input type="button" onclick="alert(read_canvas());" value="read_canvas()" />
878
 
879
 
880
</script>
881
 find_images();
882
 };
883
  };
884
   };
885
    img.setAttribute('onclick','javascript:place_image_on_canvas(this.id);');
886
    idx++;
887
    img.setAttribute('id','drag_'+idx);
888
   if(id.indexOf('insert')!= -1){
889
   var id = img.id;
890
   var img = images[p];
891
  for(var p=0;p<len;p++){
892
  var idx=0;
893
  var len = images.length;
894
  var images = document.getElementsByTagName('img');
895
 /* look for images with 'insert' in the 'id'*/
896
 function find_images(){
897
 };
898
   if(typeof fun === 'function'){return fun();};
15271 bpr 899
   var fun = eval("read_dragdrop"+canvas_scripts[0]);
15111 schaersvoo 900
 function read_dragdrop(){
901
 };
902
   if( typeof fun === 'function'){ return fun();};
903
   var fun = eval("read_canvas"+canvas_scripts[0]);
904
 function read_canvas(){
905
<script type="text/javascript">
906
 
907
</table>
15271 bpr 908
 <tr><th> <img src="gifs/en.gif"  id="insert_en" /> </th><th>  <img src="gifs/nl.gif"  id="insert_nl" /> </th><th>  <img src="gifs/cn.gif"  id="insert_cn" />  </th><th>  <img src="gifs/it.gif"  id="insert_it" />  </th></tr>
909
 <tr><th> \I1   </th><th> \I2 </th><th> \I3 </th><th> \I4 </th></tr>
910
 <tr><th> \(\M1\) </th><th> \(\M2)</th><th> \(\M3) </th><th> \(\M4\) </th></tr>
911
 <tr><th> M1   </th><th> M2 </th><th> M3 </th><th> M4 </th></tr>
15111 schaersvoo 912
<table border="1">
913
}
914
# multidraw images
915
userdraw images,red
11764 schaersvoo 916
snaptogrid
15111 schaersvoo 917
centered
918
grid 2,2,grey,1,1,6,grey
919
axisnumbering
920
axis
921
precision 1
922
yrange -10,10
923
xrange -10,10
924
bgcolor white
925
\canvasdraw{500,500}{
11769 schaersvoo 926
 
15111 schaersvoo 927
\statement{
11820 schaersvoo 928
 
15111 schaersvoo 929
\text{divstyle="display:inline-block;width:auto;text-align: center;"}
15271 bpr 930
\text{I4=<img style="width:50%;height:50%" onclick="javascript:place_image_on_canvas(this.id);" src="modules/data/chemistry/mol2D.fr/images/100_39_0.png" id="I4" />}
15111 schaersvoo 931
\text{I3=<img style="width:50%;height:50%" onclick="javascript:place_image_on_canvas(this.id);" src="modules/data/chemistry/mol2D.fr/images/1002_69_3.png" id="I3" />}
932
\text{I2=<img style="width:50%;height:50%" onclick="javascript:place_image_on_canvas(this.id);" src="modules/data/chemistry/mol2D.fr/images/1002_57_9.png" id="I2" />}
933
\text{I1=<img style="width:50%;height:50%" onclick="javascript:place_image_on_canvas(this.id);" src="modules/data/chemistry/mol2D.fr/images/1002_28_4.png" id="I1" />}
934
\text{M4=\mmlid{M4}\xrightarrow{\rm N_2 \uparrow}}
935
\text{M3=\mmlid{M3}\xrightarrow{\rm O_2 \uparrow}}
936
\text{M2=\mmlid{M2}\xrightarrow{\rm H_2 \uparrow}}
937
\text{M1=\mmlid{M1}\xrightarrow{\text{reaction}}}
938
##### example OEF...
16849 obado 939
```
11823 schaersvoo 940
 
16849 obado 941
	- 'userdraw images,bogus color' : right mouse click removes item/object under mouse pointer
942
	- solving issue with size of dynamic created div's in 'userdraw images,color' and 'multidraw images'
11823 schaersvoo 943
 
16849 obado 944
* 26/9/2019
15111 schaersvoo 945
 
946
multidraw images
947
userdraw images,red
948
using command:
949
including KaTeX or MathJaX js-typesetting, MathML,bitmap, and any other html content,
950
All 'svg','div','span' elements on page may be used to drop onto canvas,
16849 obado 951
 
952
* 17/9/2019
15111 schaersvoo 953
on touch devices the canvasdraw inputfields could not be used
954
add attrubute autofocus,true to function 'add_inputs()'
955
 
16849 obado 956
* 8/9/2019
15111 schaersvoo 957
will now accept anything from the exercise page (including MathML,MathJaX,KaTeX typesetting) if included a 'div' with unique id and onclick='javascript:place_image_on_canvas(this.id);'
958
multidraw images
15271 bpr 959
userdraw images,somecolor
15111 schaersvoo 960
 
16849 obado 961
* 5/9/2019
15111 schaersvoo 962
case killslider: replaced 'int p' by loop indicator 'i' [obado]
963
 
16849 obado 964
* 27/8/2019
15111 schaersvoo 965
TEMPORARY ---> all browsers are type 'GECKO' and MathJaX will take care of all others in command 'latex'
966
 
967
in case of KaTeX only use command 'latex x,y,tex_string'
968
command mathml is only suitable for "GECKO" and "NON-GECKO+MathJaX"
969
command latex calls 'getMML()' e.g. 'wims_mathml'  in case of "GECKO"
970
 
16849 obado 971
* 26/8/2019
15111 schaersvoo 972
Needs looking into. In mathml.c: katex div: 'display:block;visibility:hidden'./SCHAERSVOORDE/H1/algebra/vergelijkingen-1.nl/exos/exo9:mathml 0,10,10,0,$fun\
15271 bpr 973
setting 'drag_type = -1' to drag KaTeX with left top corner...problems reading width of created div's/span's
15111 schaersvoo 974
WORK IN PROGRESS ( canvasdraw will need to call wims_mathml in case of GECKO browsers!)
975
to be used for KaTeX
976
Added command 'latex x,y,tex-string
977
 
16849 obado 978
* 25/8/2019
979
 
980
```
15111 schaersvoo 981
fcircles blue,3,3,1
982
drag xy
983
angle 0,0,2,0,0,red
984
fillpattern dot
985
arrow 0,0,5,0,7,red
986
fillcolor blue
987
slider -pi,pi,250,30,angle degrees,Rotate
988
opacity 200,100
989
fillcolor white
990
rotationcenter 0,0
991
linewidth 3
992
precision 1000
993
yrange -5,5
11820 schaersvoo 994
xrange -5,5
15111 schaersvoo 995
size 300,300
16849 obado 996
```
15111 schaersvoo 997
 
15271 bpr 998
- click on 'reset' will deactivate all
15111 schaersvoo 999
- click on objects will activate
1000
- command 'angle x0,y0,x1,y1,angle,color' will always be active in case of a rotation slider.
1001
- drag x|y|xy may be combined with slider(s)
1002
- snapto* will not work !
1003
in slider exercises:
1004
 
1005
onclick and dragdrop may be combined, but is not really usefull :)
1006
- every onclick object starts with obj.onclick_cnt = 0... when clicked obj.click_cnt = 1
1007
- only the first element of a row is important (obj.click_cnt), which is 0 or 1
1008
in onclick exercises
1009
 
1010
- obj.click_cnt is the objects sequence number (starting with '0' for the first draggable object in the script)
1011
- only clicked objects have a line in the reply
1012
in dragdrop exercises:
1013
 
1014
obj.click_cnt+','+obj.xorg[0]+','+obj.yorg[0]+','+current_x+','+current_y+','+current_angle+';\\n
1015
dragdrop reply is now in format:
1016
broken modules adapted
1017
 
16849 obado 1018
* 15/8/2019
1019
 
15111 schaersvoo 1020
   -- todo: restore slider 'follow_function system'
15271 bpr 1021
6) -- todo: restore xy-slider??
15111 schaersvoo 1022
6) finished: reply&display precision and reply-format
15271 bpr 1023
5) finished: restored slider display 'system'
15111 schaersvoo 1024
4) finished: slider rotation with preservation of coordinates e.g. 'mouse dragging' is supported
1025
3) finished: group selection (just by clicking...no 'lasso')
15271 bpr 1026
2) finished: real coordinates when using 'drag & manual rotating' objects
15111 schaersvoo 1027
1) finished: multiple sliders per object or objects (until 'killslider')
1028
targets:
1029
 
16849 obado 1030
* 8/2019 rewriting of slider stuff (reponse to request/question of BPR)
15111 schaersvoo 1031
 
16849 obado 1032
* 10/8 correctedd stupid typo in DRAW_EXTERNAL_IMAGES
15271 bpr 1033
and corrected snapping to grid
15111 schaersvoo 1034
corrected flaw in multidraw cirle [BPR]
16849 obado 1035
* 3/7/2019
15111 schaersvoo 1036
removed 'touchend' (MC)
16849 obado 1037
* 22/6/2019
15111 schaersvoo 1038
(changes should be made, not yet fixed)
1039
work on the documentation: add '' ``for emphased words and <code></code>
16849 obado 1040
* 08/06/2019
1041
`userdraw circles,red`
15111 schaersvoo 1042
is identical to
16849 obado 1043
`multidraw circles
1044
strokecolor red
1045
multilabel NOCONTROLS`
15111 schaersvoo 1046
 
1047
in multidraw NOCONTROLS and a single object, no need for a 'draw object' button. It's analogue to userdraw.
1048
in multidraw right mouse click will remove last drawn object of the currently selected  draw primitive
16849 obado 1049
 
1050
* 7/6
15111 schaersvoo 1051
added ruler & protractor to new multisnap_check(x,y,use_snap);
1052
 
16849 obado 1053
```
15111 schaersvoo 1054
#<input type='button' onclick='javascript:var fun=eval("clear_draw_area"+canvas_scripts[0]);fun(9,0);' value='REMOVE LAST ARROW ' />
1055
<input type='button' onclick='javascript:var fun=eval("clear_draw_area"+canvas_scripts[0]);fun(24,0);' value='REMOVE LAST CURVEDARROW2 ' />
1056
<input type='button' onclick='javascript:userdraw_primitive=24;multidraw_click_cnt = 0;' value='start drawing curvedarrows2' /> etc etc
1057
<input type='button' onclick='javascript:userdraw_primitive=null' value='STOP DRAWING' />
16849 obado 1058
```
15111 schaersvoo 1059
controls for example:
16849 obado 1060
 
1061
```
15111 schaersvoo 1062
curvedarrows2 = 24
1063
curvedarrow2 = 23
1064
curvedarrows = 22
1065
curvedarrow = 21
1066
images = 20
1067
parallelograms = 19
1068
parallelogram = 18
1069
polys[3-9] = 17
1070
poly[3-9] = 16
1071
rects = 15
1072
rect = 14
1073
text = 13
1074
closedspoly = 12
1075
triangles = 11
1076
triangle = 10
1077
arrows = 9
1078
arrow = 8
1079
segments = 7
1080
segment = 6
1081
lines = 5
1082
line = 4
1083
circles = 3
1084
circle = 2
1085
points =1
1086
point = 0
16849 obado 1087
```
15111 schaersvoo 1088
The object types are internally represented by the following numbers (makeing typo's will render your exercise null and void)
1089
To activate this feature, use multilabel NOCONTROLS
1090
When you are not content with the default 'multidraw control panel', you can create your own interface, using a few javascript functions to call the drawprimitives, delete things and 'stop drawing' in case you also want to drag&drop stuff...
1091
### from doc's
1092
6/6 added keyword 'NOCONTROLS' to disable all buttons for multidraw
1093
 
1094
command 'drag xy|x|y' was fallen of the wagon...
1095
 
1096
don't touch replyformat 29: it is universal and for multidraw  !
1097
todo: modify/change 6,10,11,15,16,17,18,19,20,25,27,31
1098
 
1099
OEF : replyformat		22,23,28
1100
USERDRAW DEFAULTS: replyformat  2,6,8,10,11,15,16,17,18,19,20,23,24,25,27,29,31
1101
SCHAERSVOORDE : replyformat	2,7,8,21,22,23,24
1102
Starting with unifying the 'replyformat' jungle...without touching existing modules
1103
A single function "multisnap_check(x,y,use_snap)" will return xy[2] array with corrected  coordinates
1104
 
16849 obado 1105
* 5/6 removed confusing code about 'snapping to something' and unified it in a single variable 'use_snap=0,1,2,3,4' for 'dragstuff library', 'userdraw' and 'multidraw'
1106
* 4/6 modified 'find_angle()' now using Math.atan2(x,y) ... smooth turning 360+ without flipping...see 'protractor'
1107
 
1108
```
1109
<script>
15111 schaersvoo 1110
 resize_svg_mathml(mythings);
1111
 var mythings = [ array_with_image_id's ];
1112
 };
1113
  };
1114
   svg.setAttribute("width", w+'px');
1115
   svg.setAttribute("height", h+'px');
1116
   var h = parseInt(getComputedStyle(div).height);
1117
   var w = parseInt(getComputedStyle(div).width);
1118
   var div = document.getElementById(mythings[p+1]);
1119
   var svg = document.getElementById(mythings[p]);
1120
  for(var p=0; p < len ; lpp){
1121
  var len = mythings.length;
1122
 function resize_svg_mathml( mythings ){
1123
<script type="text/javascript">
1124
To resize and used the svg element, a small piece of javascript is needed..
1125
</svg>
1126
</foreignObject>
1127
<div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;width:auto;text-align: center;" > MATHML </div>
1128
<foreignObject width="100%" height="100%">
1129
<svg xmlns="http://www.w3.org/2000/svg" width="1px" height="1px" onclick="javascript:place_image_on_canvas(this.id);" id='my_id'>
16849 obado 1130
```
1131
when the MathML code is embedded in a foreignObject, a div and an svg with size 1px, like in:
15111 schaersvoo 1132
On Gecko browsers there is an option to include MathML from the page onto the canvas,
1133
The 'id' and (x;y) coordinates will be returned using read_canvas();
16849 obado 1134
`<img src="somewhere" id="myid" onclick="javascript:place_image_on_canvas(this.id)" alt="hmm" />`
15111 schaersvoo 1135
Images (bitmap or svg) present in the exercise page and the img-tag with an unique 'id' and onclick='javascript:place_image_on_canvas(this.id)' can be placed onto the canvas.
1136
(*)
1137
 
1138
multidraw curvedimages,curvedimages2
1139
multidraw images  (*)
1140
userdraw curvedimages2,color
1141
userdraw curvedimages,color
1142
userdraw curvedimage2,color
1143
userdraw curvedimage,color
1144
userdraw images,boguscolor (*)
1145
using: in canvasdraw.c: int use_snap = 0; /* 0 = none 1=grid : 2=x-grid : 3=y-grid : 4=snap to points ... to finally harmonize the 'snap to grid etc etc */
1146
using multisnap_check(x,y,snap_type)
1147
preparing replyformat 29 (multidraw) as generic reply system (every object has a line, every line is a matrix)
1148
Merged with wimsmodules:
1149
 
1150
 
1151
y1,y2,yc,...
1152
x1,x2,xc,...
1153
default replyformat = 2
1154
 
16849 obado 1155
* 3/6 curvedarrow now has 3 points :
1156
 
15111 schaersvoo 1157
added to multidraw family 'curvedarrow' and 'curvedarrow2'
1158
added to dragstuff library objects 'curvedarrows color,x1,y1,xc,yc,x2,y2,...' and  'curvedarrows2 color,x1,y1,xc,yc,x2,y2,...'
1159
just to be complete...
1160
added to dragstuff library objects 'curvedarrow x1,y1,xc,yc,x2,y2,color' and  'curvedarrow2 x1,y1,xc,yc,x2,y2,color'
1161
added 'userdraw curvedarrow2,color' and 'userdraw curvedarrows2,color'
16849 obado 1162
 
1163
* 1/6/2019
15111 schaersvoo 1164
TODO: add curvedarrow to dragstuff object library
1165
TODO: multidraw curvedarrow
1166
TODO: 'userdraw curvedarrow2,color' and  'userdraw curvedarrows2,color'
16849 obado 1167
* 31/5/2019 added userdraw primitive 'userdraw curvedarrow,color' and  'userdraw curvedarrows,color'
1168
* 15/5/2019 dragging external images now centers the image around the mouse pointer
15111 schaersvoo 1169
all other drag&drop things (canvas related and div's (from xml/mathml) seem to work fine, only dragging of images fails
1170
this -however- does not seem to correct the problem om 'styled' wims-servers [BPR].
1171
draw_external images now makes use of the same dragstuff.getMouse()
16849 obado 1172
* 14/5/2019 problems with dragging images...
1173
* 13/5/2019 bugfix command angle|arc combined with command 'slider'...slidervalue is in radians...arc|angle needs degrees
1174
* 11/5/2019 add some examples for OEF [BPR] (work in progress)
1175
* 4/3/2019 corrected fontsize behaviour of command 'text' (always trouble between 'fontsize' and 'fontfamily' commands) [BPR]
1176
* 2/2/2019 corrected behaviour of replyformat 11 etc (dealing with (x1:y1)---<x2:y2) )
15111 schaersvoo 1177
 
16849 obado 1178
```
15111 schaersvoo 1179
jsplot red,4*cos(2*x),2*sin(3*x-pi/6),cos(x),3*sin(x),3*cos(x),sin(x),x,x^2
1180
multistrokecolors red,red,blue,blue,green,green,orange,orange
1181
precision 1000
1182
linewidth 1
1183
animate
1184
trange -pi,pi
1185
fillcolor blue
1186
linewidth 4
1187
grid 1,1,grey,4,4,7,black
1188
opacity 100,190
1189
axisnumbering
1190
axis
1191
precision 0
11820 schaersvoo 1192
yrange -5,5
15111 schaersvoo 1193
xrange -5,5
1194
size 400,400
16849 obado 1195
```
15111 schaersvoo 1196
(command animate may only be used once)
16849 obado 1197
 
1198
* 28/12 multiple animated curves using command jsplot
1199
* 25 --> 26
15111 schaersvoo 1200
corrected "snprintf(tmp_buffer,25,"use_mouse_coordinates();\n");add_to_buffer(tmp_buffer);"
16849 obado 1201
* 15/10 BPR
1202
* 12/4 piechart will show 'legend' text inside piechart when using keyword 'centered': use fill opacity to enhance visibility
1203
* 14/3/2018 draw_crosshairs: forgotten ctx.save(); (crosshairs will 'move' with every click...)
1204
* 13/11 live docs
1205
* 12/11 added command 'ellipses'
1206
* 6/11 added few things to "live documentation" work in progress
1207
* 18/10 reoganised string/text keywords 'centered','xoffset','yoffset','xyoffset'
1208
* 8/10 remove duplicates while drawing 2-point objects (circle/line/demiline/segment/rect)
15111 schaersvoo 1209
 
16849 obado 1210
* 4/10 work in progress: adding examples to documentation (the "example:"  flag can be used to extract)
15111 schaersvoo 1211
 
16849 obado 1212
* 2/10 fixed bugs (thx B.Perrin)
1213
* 28/9 bug fix : variable use_axis_numbering was reset by introduction of numberline command...
1214
* 20/9 bug fix in command curve (a parameter was wrongly set, resulting in curve being type=13 (is a circle) insteadof type=9
15111 schaersvoo 1215
 
16849 obado 1216
```
15111 schaersvoo 1217
mouse blue,22
1218
precision 1
1219
userinput function
1220
functionlabel f(x)=
1221
strokecolor green
1222
jsplot red,4*cos(2*x),2*sin(3*x-pi/6)
1223
precision 1000
11820 schaersvoo 1224
linewidth 1
15111 schaersvoo 1225
animate
1226
trange -pi,pi
1227
fillcolor blue
1228
linewidth 4
1229
grid 1,1,grey,2,2,5,black
1230
opacity 100,190
1231
axisnumbering
1232
axis
1233
precision 0
1234
yrange -5,5
1235
xrange -2*pi,2*pi
1236
size 400,400
1237
popup
16849 obado 1238
```
11824 schaersvoo 1239
 
16849 obado 1240
* 17/9 added basic 'point_on_curve' animation (parametric and 'normal' functions)
11837 schaersvoo 1241
 
16849 obado 1242
```
15111 schaersvoo 1243
zoom red
1244
numberline -5,5,2,10,-3.5,-3
1245
zoom red
1246
xaxis -4:AAAAA:-2:BBBBB:2:CCCCC:4:DDDDD
1247
strokecolor purple
1248
numberline -5,5,1,8,-2,-1.5
1249
xaxisup -4:AAAA:-2:BBBB:2:CCCC:4:DDDD
1250
strokecolor blue
1251
numberline -5,5,1,5,2,2.5
1252
xaxis -4:AAA:-2:BBB:2:CCC:4:DDD
1253
strokecolor green
1254
numberline -5,5,1,4,4,4.5
1255
xaxisup -4:AA:-2:BB:2:CC:4:DD
1256
strokecolor red
1257
opacity 255,255
1258
grid 1,1,grey
1259
hline 0,0,black
1260
xaxis -4:A:-2:B:2:C:4:D
1261
noyaxis
1262
yrange -5,5
11837 schaersvoo 1263
xrange -5,5
15111 schaersvoo 1264
size 400,400
16849 obado 1265
```
15111 schaersvoo 1266
     adding y-offset when x-values overlap.
1267
     multiple numberlines are allowed using multiple 'xaxis' commmands for labeling several numberlines, including a x-axis label in command grid...
1268
     numberline is mapped to xrange/yrange
16849 obado 1269
* 15/9 added command macro "numberline x0,x1,xmajor,xminor,y0,y1"
15111 schaersvoo 1270
 
1271
     solved long  standing issue with color 0,0,0 (black) as fill border
1272
     added 'fixed' pattern filling to primitives 'boxplot' and 'piechart'
16849 obado 1273
* 6/9  just for completeness: added pattern filling to all fillable userdraw primitives
15111 schaersvoo 1274
 
16849 obado 1275
```
15111 schaersvoo 1276
clearbutton removed
1277
userdraw gridfill,red
1278
circle 10,10,100,red
1279
imagefill 0,0,0,gifs/en.gif
1280
# syntax: x,y,scale?,image
1281
plot blue,-x^2+4
1282
plot red,x^2-4
11837 schaersvoo 1283
yrange -5,5
15111 schaersvoo 1284
xrange -5,5
1285
size 150,150
16849 obado 1286
```
11839 schaersvoo 1287
 
15111 schaersvoo 1288
NOTE: special filling (hatch,dot,...,image) should be harmonized to include userdraw and drag&drop library objects !!
1289
26/8 command imagefill x0,y0,URL now works like flydraw should
1290
 
16849 obado 1291
```
15111 schaersvoo 1292
fcircle 2,-3,100,cyan
11854 schaersvoo 1293
drag xy
15111 schaersvoo 1294
fillpattern gifs/fr.gif
1295
fcircle 2,3,100,green
11854 schaersvoo 1296
drag xy
15111 schaersvoo 1297
fillpattern gifs/de.gif
11854 schaersvoo 1298
fcircle -2,-3,100,red
1299
drag xy
15111 schaersvoo 1300
fillpattern gifs/nl.gif
1301
fcircle -2,3,100,blue
11854 schaersvoo 1302
drag xy
15111 schaersvoo 1303
fillpattern gifs/en.gif
1304
snaptogrid
1305
yrange -5,5
1306
xrange -5,5
1307
size 400,400
16849 obado 1308
```
14071 bpr 1309
 
16849 obado 1310
note: needs an alert for synchrone loading of images (TO DO: closures in fill routines ? )
1311
 
1312
* 25/8	added commmand 'fillpattern image_url' to use an image as 'ctx.fillStyle()'
1313
* 20/8	added patternfilling to 'userdraw' family
1314
 
1315
```
15111 schaersvoo 1316
zoom red
1317
userdraw dotfill,blue
1318
fcircle 3,-3,160,cyan
18571 bpr 1319
fillpattern diamond
15111 schaersvoo 1320
fcircle 0,3,160,green
1321
fillpattern hatch
1322
fcircle -3,-3,160,red
1323
fillpattern dot
1324
fcircle -6,3,160,blue
1325
fillpattern grid
1326
opacity 165,160
1327
yrange -5,5
11858 schaersvoo 1328
xrange -5,5
15111 schaersvoo 1329
size 370,370
16849 obado 1330
```
11874 schaersvoo 1331
 
16849 obado 1332
* 18/8	added command 'fillpattern grid | dot | hatch | diamond'
1333
* 14/8 	added commands 'textfill x,y,color,sometext' and 'userdraw textfill,color,some_text'
1334
* 13/8	updated html docs
11891 schaersvoo 1335
 
16849 obado 1336
```
15111 schaersvoo 1337
clearbutton REMOVE
1338
fill 0,5,red
1339
gridfill 4,0,3,3,blue
1340
diamondfill -4,0,6,6,cyan
1341
dotfill 0,0,6,6,green
1342
linewidth 1
1343
userdraw hatchfill,red
1344
plot blue,-x^2+4
1345
plot red,x^2-4
1346
yrange -5,5
11891 schaersvoo 1347
xrange -5,5
15111 schaersvoo 1348
size 150,150
16849 obado 1349
```
11891 schaersvoo 1350
 
15111 schaersvoo 1351
	userdraw clickfill,color (will use only color,no pattern)
1352
	userdraw hatchfill,color
1353
	userdraw dotfill,color
1354
	userdraw gridfill,color
1355
	userdraw diamondfill,color
11893 schaersvoo 1356
 
16849 obado 1357
* 12/8  added to userdraw family (not yet 'cleaned' the js-code)  the commands:
1358
* 11/8  function 'find_angle' was gone fishing in case of command 'protractor'
1359
        added gridfill,hatchfill,diamondfill
15111 schaersvoo 1360
example:
1361
     added pattern to command 'userdraw clickfill,color'
1362
     other patterns will -hopefully- follow
16849 obado 1363
* 10/8 premature version of pattern filling ; for now only 'dotfill x,y,dx,dy,color'
15111 schaersvoo 1364
     if set the text will not start at given (x:y) but end at (x:y)
16849 obado 1365
* 8/8  added keyword 'yoffset' for use with rotated text strings (command textup or stringup)
1366
* 4/8  multidraw primitive 'text' is now always x-centered on click-coordinates
15111 schaersvoo 1367
     reorganized canvasdraw.c : commands in alfabetical order (cleaning & formatting not yet ready)
1368
     (added 'this.use_once')
16849 obado 1369
* 3/8  corrected flaw introduced by keywords xyoffset etc... removed repeated shifting of text-strings in redraw of canvas
15111 schaersvoo 1370
     the inputfields will be x/y centered on (x:y)... default was left top corner
1371
     keyword xoffset also active for commands 'input x,y,size,editable,value'  and 'userdraw input(s),color'
16849 obado 1372
* 2/8  added keywords xyoffset,xoffset|centered,resetoffset for easier text-label placing close to 'objects' like crosshairs,points...
1373
* 26/7 multidraw_button_table now centered in tooltip placeholder div element (using style="margin: 0 auto;" )
1374
* 25/7 multidraw command 'text' now will place a 'text string' on canvas via a mouse-click or (if command multiuserinput is set to 1 for 'text') via x/y inputfields
1375
* 24/7 corrected multidraw text error (duplicate text)
1376
* 15/7 added command 'fillall color,x1,y1,x2,y2,x3,y3...xn,yn' for filling multiple speparated areas with the same color
1377
* 14/7 set timeout on clickfill and while waiting set cursor to 'wait'
11996 schaersvoo 1378
 
16849 obado 1379
```
15111 schaersvoo 1380
clearbutton REMOVE
1381
userdraw clickfill,purple
1382
colorpalette orange,yellow,red,green,lightgreen,blue,lightblue,cyan
1383
# multifillcolors orange,yellow,red,green,lightgreen,blue,lightblue,cyan
1384
replyformat 10
1385
snaptogrid
1386
grid 1,1,grey
1387
canvastype 4
1388
# use the grid canvas 4 as fill borders
1389
yrange -5,5
1390
xrange -5,5
13514 schaersvoo 1391
size 400,400
16849 obado 1392
```
15111 schaersvoo 1393
example of a simple clicktile in direct exec:
13521 schaersvoo 1394
 
16849 obado 1395
      this will bind coordinates with color...if the exercise wishes.
15111 schaersvoo 1396
      added command 'colorpalette color1,color2...color2' for creation of color-buttons to change the click color.
14038 schaersvoo 1397
 
15111 schaersvoo 1398
      to identify the correct color on the correct area...
1399
      When using something like 'replyformat 10' or another format reporting the 'userdraw_radius[]' the color-number will be part of 'read_canvas()'
1400
      the colors will re-cycle when there are more clicks than colors...
16849 obado 1401
 
1402
* 13/7  'userdraw clickfill,color' may now make use  of command 'multifillcolors color1,color2,color3...color_n'
15111 schaersvoo 1403
      fill commands may be used together with 'userdraw clickfill,color'
1404
      (it will still ignore the bordercolor...I just can't make this work... grrr )
18571 bpr 1405
      command 'filltoborder x,y,bordercolor,color' is still the same as fill
15111 schaersvoo 1406
      command 'fill x,y,color' or 'floodfill c,y,color' may now be used multiple times.
14035 schaersvoo 1407
 
15111 schaersvoo 1408
      read_canvas() will return the click-coordinates
1409
      areas can be removed (after confirm 'clear ?' ) with command 'clearbutton some_text'
16849 obado 1410
* 11/7  now 'userdraw clickfill,color' can fill multiple selected area's
15111 schaersvoo 1411
      (although this is possible through foreignobject --> blob --> image --> canvas )
16849 obado 1412
      will be located at (1:0) and the mathml will decide the width and height of the drag/click div's (the div's are added to the 'mother' div and not -of c ourse- to the html5 canvas
1413
 
1414
      ```mathml 1,0,-10000,10000, <span style="font-size:1em;">
1415
      <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
1416
       <mstyle id="wims_mathml347806" mathsize="110%">
1417
        <mstyle mathsize="200%">
1418
         <mstyle displaystyle="true">
1419
          <mfrac>
1420
           <mi>?</mi>
1421
           <mrow><mi>sin</mi>
1422
            <mrow>
1423
             <mo stretchy="true">(</mo>
1424
             <mstyle displaystyle="true">
1425
              <mfrac><mi>?</mi><mi>?</mi></mfrac>
1426
             </mstyle>
1427
             <mo stretchy="true">)</mo>
1428
            </mrow>
1429
           </mrow>
1430
          </mfrac>
1431
         </mstyle>
1432
        </mstyle>
1433
       </mstyle>
1434
      </math></span>```
1435
 
15111 schaersvoo 1436
      so the left top corner of
1437
      however, the  values must still be defined (syntax backwards compatibility)
16849 obado 1438
 
1439
* 8/7   command mathml will use fill_color/fill_opacity when dragged / clicked ; x2,y2 (used for determining the width/height of the embedded mathml div, are no longer used
1440
* 6/7   improved onclick & (standard) reply format
1441
* 5/7   improved drag&drop in case of mathml (or better all xml/html inclusives)
1442
* 4/7   corrected -again?- color cludge in 'barchart'...
1443
* 20/5  added forgotten minimal touch-support for multidraw routines
15111 schaersvoo 1444
      drag xy|x|y and [xy]snaptogrid are supproted
1445
      (it's not really dragging , but selecting and moving to a new location by click)
16849 obado 1446
* 12/2  added very primitive dragging to 'mathml'
14038 schaersvoo 1447
 
16849 obado 1448
	```
15111 schaersvoo 1449
      line 11 = text_x+";"+text_y+";"+text"\n"
1450
      line 10 = parallelogram_x+";"+parallelogram_y+"\n"
1451
      line 9 = closedpoly_x+";"+closedpoly_y+"\n"
1452
      line 8 = rects_x +";"+rects_y+"\n"
1453
      line 7 = polys[3-9]_x+";"+polys[3-9]_y+"\n"
1454
      line 6 = triangles_x+";"+triangles_y+"\n"
1455
      line 5 = lines_x+";"+lines_y+"\n"
1456
      line 4 = arrows_x+";"+arrows_y+"\n"
1457
      line 3 = segments_x+";"+segments_y+"\n"
1458
      line 2 = circles_x+";"+circlespoint_y+";"+multi_radius+"\n"
1459
      line 1 = points_x+";"+points_y+"\n"
16849 obado 1460
   ```
15111 schaersvoo 1461
      The output is always a 11 lines string with fixed sequence.
14038 schaersvoo 1462
 
15111 schaersvoo 1463
      multiple parallograms may be used: the coordinates are stored in "line 10" in the reply
1464
      multiple polys[3-9] may be used: poly[3-9] or polys[3-9] has "line 7" in the reply
1465
      removed command poly[s][3-9] and parallelogram[s] from 'triangle' sub-command and used as additional commands.
1466
      command multidraw
16849 obado 1467
* 9/2
1468
 
1469
## 2017
15111 schaersvoo 1470
      the same  canvas :making it possible to do a 'userdraw clickfill,color' & pan & zoom on the single js-curves-canvas
16849 obado 1471
* 30/10 added some options to command jsplot/jscurve: multiple js-curves may now be plot in a single command and on
15111 schaersvoo 1472
      But it's still a vary ugly cludge caused by the "Flydraw backwards compatibility"
1473
      then this family&size will be used.
1474
      if command "fontfamily 'size px Family'" was given and the size of "m" is larger then a set/default fontsize
16849 obado 1475
      the context will use this fontsize in Arial...
1476
      if command "fontsize int" is given and it's size is larger than the default fontfamily "12px Arial"
1477
 
1478
      ```
15111 schaersvoo 1479
      ###
16849 obado 1480
      if( font_size > tmp_font_size ){context_userdraw.font = font_size+\"px Arial\";};
15111 schaersvoo 1481
      var tmp_font_size = parseInt(context_userdraw.measureText(\"m\").width);\
1482
      ###
16849 obado 1483
      ```
15111 schaersvoo 1484
      corrected cludge of fontsize versus fontfamily :
1485
      color was taken from fontcolor... and not from userdraw command... which is color --> strokecolor
16849 obado 1486
* 29/10 corrected "userdraw text,color" :
1487
      `x1,y1,text1 \n x2,y2,text2 \n` etc
15111 schaersvoo 1488
      changed the default replyformat for 'userdraw text,color' and 'userdraw input(s),color' to the type:
1489
      (in both cases a right | middle button click will always remove the drawings
1490
      and added to 'clearbutton' the removal of inputfields produced by command "userdraw input(s),color"
16849 obado 1491
* 28/10 corrected ctx-reset flaw in "userdraw text,color" when removing text with the "clearbutton xxx"
1492
* 24/10 command vline | hline now have range -100*xmin | 100*ymax : so on "moderate" zooming there will still be a vline | hline
1493
* 13/10 added keywords "noxaxis" "noyaxis" to "grid" command family
1494
* 8/10  canvasinfo.sh will (after chmod +x) generate also canvasdraw.phtml and move it to "../../../public_html/scripts/help/en"
15111 schaersvoo 1495
      so now every userdraw object may be deleted (indiviually) by a right mouse click...middle click still no good
1496
      added 'oncontextmenu="return false;"' to main canvas_div to disable context menu with right click on image
16849 obado 1497
* 7/10  added snapto*** to "userdraw clickfill,color"
1498
* 6/10  moved command "clickfill color" to the userdraw command list e.g. userdraw clickfill,color: clickfill is per default on the drag_canvas (unless you specify an other canvastype)
1499
* 5/10  added support for touch devices
1500
* 30/9  `clear_draw_area()` used by "clearbutton txt"  did not reset the internal click-count-variable "xy_cnt"
1501
* 29/9  corrected errors in replyformat 23 (B. Perrin)
1502
* 26/9  tried to solve the syntax issues with polyline etc
1503
* 11/9  added an option to command clock (and corrected the modulo bug :javascript remainder % is not the same as modulo)
15111 schaersvoo 1504
      added some html info
16849 obado 1505
* 10/9  corrected slider display (arguments "display x" and "display y" always showed "x : y" values
1506
* 4/7   using '\t' as command separator (for use within OEF)
1507
*       difference between 'arc' and 'angle': 'arc' may set width+height (ellipse)
1508
* 15/2 corrected filling in command 'arc'
1509
* 4/2  added command 'rotationcenter xc,yc' and keyword 'killrotate'
1510
* 3/1  corrected fontsize flaw in commands text / textup
1511
 
1512
## 2016
1513
	removed nonexisting 'div' argument 'tabindex=0' (thx to Perrin)
1514
 
1515
* 29/12 clearbutton was incompatible with chromium etc (revert to button.style = "style_text" when all browsers are supporting this construct)
1516
* 18/9 corrected command 'centerstring' : forgotten clearRect()
1517
* 17/9 corrected command clock: colors are now -really- optional
1518
*       corrected -fixed- interactive boxplot stuff (js-related)
1519
* 15/9 disabled 'crispy-lines' when zooming is activated (repeated translation of context)
1520
*       e.g. producing crispy sharp lines : if(line_width %2 == 1){ctx.translate(0.5,0.5);}
1521
* 12/9 now linewidth 1 == 1px and linewidth 2 == 2px
1522
* 5/9  added command boxplot and jsboxplot
1523
* 3/9  added commands xerrorbars,yerrorbars to dragdrop library
15111 schaersvoo 1524
      minor corrections in html-doc for fontsize ; although it will not compensate for 'not-reading-the-docs' !
1525
      corrected flaw in draw_points()
1526
      (the single command 'userdraw type,color) will NOT ZOOM / PAN !!)
16849 obado 1527
* 30/8 multidraw primitives will now zoom / pan (added function redraw_all())
1528
       added several alternatives to html-doc
1529
* 25/8 added command 'cursor some_css_cursor'
1530
* 20/8 added 'rect' and 'rects' to multidraw command
1531
* 10/8 added 'xaxisup' and modified grid extension 'barchart' using the xminor/x2step for the bar-width...
1532
* 2/8   added 'text' to 'multidraw'
1533
* 	when status=done the image will be shown in the page --> canvas_div.style.display='block'
1534
* 28/7  read_canvas and read_dragdrop in popup window
1535
*        no yet suitable for communication back to wims...[work in progress]
1536
*        embedding canvasdraw into separate window xsize x ysize
1537
* 26/7  added keyword 'popup'
1538
* 21/7  added command `triangles color,x1,y1,x2,y2,x3,y3,...`
14038 schaersvoo 1539
 
16849 obado 1540
```
15111 schaersvoo 1541
# reply[3]...reply[5] = protractor
1542
# reply[0]...reply[2] = ruler
1543
replyformat 32
14044 schaersvoo 1544
 
15111 schaersvoo 1545
protractor 2,-2,6,0,-1,1,1
1546
ruler -4,3,5,1,-1,1
1547
opacity 255,40
1548
fillcolor orange
14071 bpr 1549
 
15111 schaersvoo 1550
vline 0,0,black
1551
hline 0,0,black
1552
yrange -5,10
1553
xrange -5,10
1554
size 400,400
16849 obado 1555
```
14053 schaersvoo 1556
 
16849 obado 1557
* 14/7 combinations of ruler & protractor
1558
* 13/7 added command macro `ruler x,y,x-width ,y-height,passive_mode`
15111 schaersvoo 1559
	snaptogrid implementes ( xy | x | y )
16849 obado 1560
 	reply format implemented  `(read_canvas())  reply[0] = x;reply[1] = y;reply[2]=angle_in_radians`,
1561
 	value display implemented,
1562
 	left-right rotation with mouse (left click & drag),
1563
 	zooming implemented,
1564
* 12/7	added 'macro' command 'protractor x,y,x-width,type,passive_mode,value_display
1565
* 8/7	revert to normal size of a point at 'linewidth = 1' (e.g. differ from ridiculous small point size of flydraw)
15111 schaersvoo 1566
	This last -duplicated- point is removed from the answer array
1567
	only 1 onject can be drawn (only with mouse).The poly is closed when clicking on the first point again (+/- 10px)
16849 obado 1568
* 7/7	added argument 'closedpoly' to command 'multidraw'
14063 schaersvoo 1569
 
15111 schaersvoo 1570
	When things are more mature and speed is no longer an issue, the 'single userdraw' command will be replaced by multi*
1571
	And yes, these are horrible long command names.
1572
	multifillopacity,multiuserinput,multilabel,multilinewidth,multisnaptogrid
1573
	multidraw,multidash,multistrokecolors,multifill,multifillcolors,multistrokeopacity,
16849 obado 1574
* 26/6	multi-family of commands are 'finished'
15111 schaersvoo 1575
        NOT READY: many issues are still unadressed
14071 bpr 1576
 
15111 schaersvoo 1577
	(to increase speed of execution)
1578
	The js-canvas drawfunctions will be different (simpler) compared with the single 'userdraw obj,color' functions
1579
	using buttons to switch drawing primitive...
16849 obado 1580
* 17/6   added experimental 'multidraw', allowing multiple drawing primitives in a single canvas image,
14208 schaersvoo 1581
 
15111 schaersvoo 1582
	added command 'snaptofunction some_fun_x,some_fun_y'
14208 schaersvoo 1583
 
16849 obado 1584
		frect -3,3,0,0,red
1585
		slider -5,5,120,10,x function display,some_text
1586
		sliderfunction_x 5*sin(x)
17581 bpr 1587
 
16849 obado 1588
		'sliderfunction_y some_operation_on_y'
1589
		'sliderfunction_x some_operation_on_x'
1590
		added command
1591
		added argument 'function' to the slider objects.
1592
* 28/4	removed point2point...
1593
* 24/4	added experimental command 'point2point x,y,color1,color2,x-relation_1:y-relation_1: ... : x-relation_n_:y-relation_n
15111 schaersvoo 1594
	make background color in generated <span> elements adjustable via command 'fillcolor'
1595
	make font color in generated <span> elements adjustable via command 'strokecolor'
1596
	todo:
16849 obado 1597
* 23/4	removed most static settings of fontsize and/or style.
1598
* 22/4	corrected 'static fontsize settings' in some js-user-input stuff, using size set by 'command fontsize int'... to be continued
1599
* 21/4	corrected missing 'ctx.restore()' in case of arrow (gives very strange  rotations when using a slider to rotate only the arrow...)
1600
* 19/4	changing "abs" by "fabs" in case of floating point variables. (BPR)
1601
* 8/4	added forgotten /*<![CDATA[*/ .... /*]]>*/ to script tag
1602
* 25/2	Internet Explorer & "use strict" : changed 'span.style="color:..." into span.setAttribute('style','color:...');
14208 schaersvoo 1603
 
15111 schaersvoo 1604
	 (even those not set draggable)
1605
	 note: all external images positions will be present in the 'read_canvas' array
1606
	 the third image position is (-2:-5)
1607
	 the second image position is (6:2) and
1608
	 the first image position is (-5:4) ,
1609
	 0:-5:4,1:6:2,2:-2:-5
1610
	 e.g. expect in  case of 3 external images set draggable, something like
1611
	 read_canvas() will reply "object_number:x:y" of all external images introduced by commands 'copy copyresized'
16849 obado 1612
 
1613
	- corrected replyformat 20 (only used for external image drag&drop... outside the dragstuff library !!)
1614
	- corrected resetting of 'reply array' in case of zooming... (why did I reset this?)
1615
* 17/2
1616
	- added check on wims_status=done when using 'onclick' (otherwise objects can be 'clicked/dragged' in an answer.phtml)
1617
	- simplified onclick things in external images
1618
	- fixed bug when onclick external images were mixed with static external images
1619
* 16/12 - corrected 'userdraw points,color' erase/redraw bug (using 'clearbutton buttontxt')
1620
* 7/12	- onclick objects may now be of any type (eg external images ,via copy /copyresized or any other canvas 'object')
15111 schaersvoo 1621
	 see canvassdraw.html for possible usage and limitations
16849 obado 1622
* 25/11 - added "onclick" to external images (via commands copy / copyresized)
15111 schaersvoo 1623
	-again tried to fix copy/copyresized (grrr)
1624
	 and thus reset to "0,0,0"
16849 obado 1625
* 24/11
1626
	- corrected syntax-flaw in js-function draw_rects() ; both stroke_color and fill_color were not correctly defined
15111 schaersvoo 1627
          analogue to command 'ellipse'
16849 obado 1628
	- corrected command 'arc' : switched from width/height (width and height may now be different) in pixels to width / heigth in x/y-range
15111 schaersvoo 1629
          now "linewidth 1" is almost invisible, just as in 'flydraw'...that is a clear improvement :)
16849 obado 1630
	- synchronised size of point / points with flydraw
15111 schaersvoo 1631
          The image may be of type BITMAP and SVG
1632
          (even if there is no external image imported)
16849 obado 1633
* 23/11	- solved issue with drawing onto external images: now a empty 'external_image' canvas is created first / per default...
15111 schaersvoo 1634
	  image operations are now performed on a "real canvas" and no longer on a "canvas_div"
16849 obado 1635
* 22/11
1636
	- joined draw_external_images and drag_external_images
15111 schaersvoo 1637
	- changed output "function distance()" from integer to floating point. (slightly better in case of snaptopoints)
16849 obado 1638
* 9/11
1639
	- fixed bug of increasing font_size when using multiple 'text' commands [perrin]
15111 schaersvoo 1640
	- added "xsnaptogrid,ysnaptogrid,snaptogrid,snaptopoints" to dragging of 'external images'
1641
	- "click_cnt" counter (to identify the object in reply) only incremented when 'onclick' and / or "drag x|y|xy" is set.
1642
	- added "snaptopoints" to userdraw primitives and drag&onclick library
16849 obado 1643
* 6/11	- corrected dragging (dragging was missing...) of closed polygon (triangle etc)
1644
```
15111 schaersvoo 1645
userdraw arrow,blue
1646
#userdraw arrows2,blue
1647
arrowhead 10
1648
linewidth 2
1649
snaptopoints 0,0,-6,0,-3,3,0,6,3,3,6,0,3,-3,0,-6,-3,-3
1650
points red,-6,0,-3,3,0,6,3,3,6,0,3,-3,0,-6,-3,-3
1651
point 0,0,blue
1652
linewidth 3
1653
yrange -10,10
1654
xrange -10,10
1655
size 400,400
16849 obado 1656
```
15111 schaersvoo 1657
	 only implemented in command "userdraw arrow(s),color"
16849 obado 1658
* 5/11
1659
   - added experimental command "snaptopoints x1,y1,x2,y2,..."
1660
   - added command "bezier color,xs,ys,x1,y1,x2,y2,x3,y3"
1661
   - added alernative to command "polyline" : "path color,x1,y1,x2,y2,...."
1662
   - added command "roundrects color,radius,x1,y1,x2,y2,...."
1663
   - added command "vlines color,x1,y1,x2,y2,...."
1664
   - added command "hlines color,x1,y1,x2,y2,...."
1665
   - added command "demilines color,x1,y1,x2,y2,...." alternative "halflines"
1666
* 3/11   - added commands "rects color,x1,y1,x2,y2,...." and "frects color,x1,y1,x2,y2,...."
1667
* 2/11   - docs
1668
* 1/11
1669
   - corrected font behaviour of Flydraw text command.
15111 schaersvoo 1670
        Flydraw command "lines" is equivalent to "polyline"
1671
        "polyline" | "polylines" | "brokenline" | "brokenlines" will produce interconnected segments between the points (not closed)
1672
        "lines" will produce not connected lines through points (x1:y1)--(x2:y) etc
16849 obado 1673
   - syntax changed for command "lines color,x1,y1,x2,y2...x_n-1,y_n-1,x_n,y_n"
1674
   - corrected command "clearbutton some_text" : multiple interactive scripts in web page may have individual 'clear drawing buttons'
1675
   - corrected crosshair_size
15111 schaersvoo 1676
	can be set draggable / onclick individually
14208 schaersvoo 1677
 
16849 obado 1678
* 29/10
1679
	- added command "arrows2 color,head px,x_1a,y_1a,x_1b,y_1b,x_2a,y_2a,x_2b,y_2b....x_na,y_na,x_nb,y_nb
1680
	- added 'replyformat 28' to reinput date from 'userdraw circles,color' [perrin]
1681
* 17/10
1682
	- removed empty string error warning in 'char *get_string_argument(); [perrin]
1683
	- removed macro "iscalculation" and replace it by something better...
1684
	- added command "arrows color,x1,y1,x2,y2...x_n,y_n
15111 schaersvoo 1685
        note: radius is not in pixels but in xy-coordinate system ! (so dragging / onclick / scaling works )
16849 obado 1686
* 11/10
1687
	- added command "circles color,x1,y1,r1,x2,y2,r2...x_n,y_n,r_n
15111 schaersvoo 1688
	like: "0.2345^1.234x" will receive a warning : it should be "(0.2345)^(1.234x)"
1689
	(but they have a small footprint...)
16849 obado 1690
	- added warnings when plot function input has "syntax" issues...well it's more likely that my simple math-parsers are too simple
1691
	- added command segments color,x1,y1,x2,y2....x_n,y_n  	[perrin]
1692
	- added simple javascript "rawmath" to convert user function input (like : 4x --> 4*x)
15111 schaersvoo 1693
	 default value 'f(x)='
16849 obado 1694
	- added command 'functionlabel some_string' to label the specific inputfields for function input
1695
 
1696
* 9/10
1697
	- now multiple functions may be plotted by user via 'userinput function' and read via read_canvas()
1698
 
1699
```
1700
	  function read_dragdrop(){
1701
	  var script_len = canvas_scripts.length;var dragdrop_reply = "";var found_result = false;for(var p = 0 ; p < script_len ; p++){var fun = eval("read_dragdrop"+canvas_scripts[p]);if(typeof fun === 'function'){var result = fun();if( result && result.length != 0 ){if(script_len == 1 ){ return result;};found_result = true;dragdrop_reply = dragdrop_reply + result +"\n";};};};if( found_result ){return dragdrop_reply;}else{return null;};};
15111 schaersvoo 1702
	  <!-- will return all 'drag&drop' or 'onclick' data from all canvas javascript includes -->
1703
	  };
1704
	   };
1705
	    return null;
1706
	   {
1707
	   else
1708
	   }
1709
	    return draw_reply;
1710
	   if( found_result ){
1711
	   };
1712
	    };
1713
	     };
1714
	      draw_reply = draw_reply + result + "\n";
1715
	      found_result = true;
1716
	      if(script_len == 1 ){ return result;};
1717
	     if( result  && result.length != 0){
1718
	     var result = fun();
1719
	    if( typeof fun === 'function'){
1720
	    var fun = eval("read_canvas"+canvas_scripts[p]);
1721
	   for(var p = 0 ; p < script_len ; p++){
1722
	   var found_result = false;
1723
	   var draw_reply = "";
1724
	   var script_len = canvas_scripts.length;
1725
	  function read_canvas(){
1726
	  <!-- will return all 'userdraw' or 'userinput' data from all canvas javascript includes -->
16849 obado 1727
```
15111 schaersvoo 1728
	 A special version of 'read_canvas()' and 'read_dragdrop()' should be included in the web page, something like this:
14208 schaersvoo 1729
 
16849 obado 1730
	 In the C-program, the local functions will be called `read_canvas%d()` with '%d' is the random `canvas_root_id`
1731
	 array `canvas_scripts` will keep track of the `canvas_root_id` number of scripts included in the page.
1732
	 The native `read_canvas()` and `read_dragdrop()` are now linked to the `canvas_root_id` and a global
14225 schaersvoo 1733
 
16849 obado 1734
* 1/10	-multiple interactive canvasdraw scripts in a single page may now work correctly in replying the userdrawarrays and the drag&drop data..
1735
* 25/9	-added command 'demiline x1,y1,x2,y2,color` and commands 'userdraw demiline,color' 'userdraw demilines,color'
1736
* 22/9	-corrected missing js-variable declaration in 'userdraw path(s) ' [use strict]
1737
* 20/9	-added userinput function | input | textarea as alternative command + argment to keywords "userinput_function","userinput_textarea" and "userinput_xy"
1738
* 11/9	-tried to improve 'filltoborder x,y,bordercolor,fillcolor'
1739
* 10/9	-added keyword 'userinput_function'
1740
* 9/9	-corrected placement of inputfields 'userdraw inputs,color' (no longer can input fields be placed on top of each other
1741
* 30/8
1742
	- added command 'clearbutton button_text' to remove all user drawings from userdraw_canvas (and empty all userdraw data arrays)
15111 schaersvoo 1743
	(although I'm not happy to increase the size of the general part of the include file)
1744
	...sometimes functions expect these array's to be defined [use strict]
1745
	- added userdraw_x = [],yserdraw_y = [],userdraw_radius = [] to global section of javascript include
16849 obado 1746
* 29/8
1747
	- corrected 'display radius,color,fontsize' in case there is no 'userdraw circle,color' defined
1748
	- corrected 'use strict' problems with 'clock'
15111 schaersvoo 1749
	display x | y | xy | degree | radius ,color,fontsize
16849 obado 1750
 
1751
* 28/8
1752
	- added argument 'radius' to mousedisplay (in case of 'userdraw circle,color'
15111 schaersvoo 1753
	x_input_1:y_input_:1input_value_1,x_input_2:y_input_:2input_value_2...
16849 obado 1754
	- added 'replyformat 27' : read_canvas() will return array
1755
* 27/8	- corrected flaw [sigalled by 'use strict'] in 'userdraw text,color'
1756
* 26/8	- added command 'userdraw input,color' and 'userdraw inputs,color' [work in progress]
15111 schaersvoo 1757
	 type: x display | y display | xy display | angle degree | angle radian
1758
	 display slider values, use:
1759
	 type: x | y | xy | angle
1760
	 slider min,max,width,height,type,string
14230 schaersvoo 1761
 
16849 obado 1762
* 24/8	- reverted to originale command 'display' and modified slider arguments to support a per slider display of it's value in the main canvas window
15111 schaersvoo 1763
	 work in progress
16849 obado 1764
* 23/8	- added 'slider | slider_degree | slider_radian' to command "display x|y|xy|degree|slider|slider_degree|slider_radian,color,fontsize"
14232 schaersvoo 1765
 
16849 obado 1766
```
15111 schaersvoo 1767
zoom blue
1768
userdraw segment,orange
1769
string black,0.9,0.1,P
1770
fontfamily italic 24px Courier
1771
point 1,0,orange
1772
linewidth 4
1773
angle 0,0,0.3,0,0,green
1774
fillcolor yellow
1775
filled
1776
segment 0,0,1,0,orange
1777
linewidth 2
1778
slider 0,2*pi,200,40,angle degree,use slider to rotate point P
1779
circle 0,0,200,red
1780
fillcolor white
1781
grid 1,1,grey,4,4,10,blue
1782
xaxis 0:0:1:1:2:2:3:3:4:4:5:5:6:6:0.5*pi:\u03c0/2:pi:\u03c0:1.5*pi:3\u03c0/2:2*pi:2\u03c0:3*pi:3\u03c0:4*pi:4\u03c0
16849 obado 1783
fontfamily bold 14px Arial
15111 schaersvoo 1784
opacity 200,150
1785
axis
1786
yrange -1,1
1787
xrange -1,7
1788
size 800,200
16849 obado 1789
```
1790
    for example:
1791
    	if the grid does not match the xaxis values:strings there will be extra tics
15111 schaersvoo 1792
	- added x/y-tics in command 'grid xmajor,ymajor,color,xminor,yminor,tics-size,axiscolor'  case of command 'xaxis' or 'yaxis'
16849 obado 1793
 
1794
* 21/8
1795
	- corrected rotation direction in case of 'slider type angle' (anti-clockwise)
15111 schaersvoo 1796
	- removed 'animate' from dragstuff library : this should be done with a kind of slider...TO DO !!
1797
	  hope this works for all browsers...tested on FreeBSD Opera/Firefox/Seamonkey/Chrome
14234 schaersvoo 1798
 
16849 obado 1799
* 20/8
1800
	- added 'use strict'; to js-include [just to make sure the js-code is "properly written"
15111 schaersvoo 1801
	- slider using 'xy' will start & end by clicking the 'slider rect'
1802
	  'angle' will zoom in/out (using scale_x_radius();) and will use radians for slider values (in contrast to 'arc' which uses width/height in pixels)
1803
	- added command 'angle x,y,width,start,end,color' as alternative to flydraw compatible command 'arc'
16849 obado 1804
 
1805
* 19/8	- improved response speed of slider (in dragstuff library)
15111 schaersvoo 1806
	  The amount of sliders in not limited
1807
	  now a slider may adjust several different objects...until keyword 'killslider' or next 'slider'
16849 obado 1808
 
1809
* 18/8
1810
	- added keyword 'killslider'
15111 schaersvoo 1811
	- for all other object the slider will 'move' / 'rotate' the complete object
1812
	- if slider is used for command 'arc' the angle will be set with the slider
1813
	- javascript:read_dragdrop(); will return an array  'object number:slider value'
16849 obado 1814
* 17/8	- type: xy,x,y,angle : added slider 'rect' for xy movement
1815
* 15/8	- further integration of slider: all draggable objects may have sliders (x/y/angle)
1816
* 14/8
1817
	- adding slider to dragstuff library : work in "progress"
15111 schaersvoo 1818
	- adapted 'rotate angle' to be compatible with flydraw... :  -1*angle (Marina)
1819
	- correct imagefill etc : reset() was missing (Marina)
16849 obado 1820
* 5/8	- added replyformat 25/26 : 'userdraw arc(s),color' with degrees or radians
15111 schaersvoo 1821
	  STILL NOT 100%  CORRECT !!
16849 obado 1822
* 4/8
1823
	- corrected command 'userdraw arc,color'
15111 schaersvoo 1824
	- added precision to the dragdrop library (eg. read_dragdrop() )
16849 obado 1825
* 28/7
1826
	- added precision to the read_canvas() functions.
15111 schaersvoo 1827
	- corrected command 'ellipse' : switched from Beziercurve to arc-method. Should now be a true ellipse
1828
	- corrected command 'roundrect' : no inverted roundrect possible
16849 obado 1829
* 27/7	- corrected command 'square' ...
1830
* 26/7
1831
	- corrected a few flaws introduced by internal changing from 'translation' to 'affine'
15111 schaersvoo 1832
	- corrected command 'lattice' (hope it's ok now)
1833
	- corrected missing dashing of 'arrow' 'arrow2'
1834
	 to imitate flydraw's filling is too much work ... for both browser js-engine and me ...
1835
remark:  hatchfill/dotfill/diamondfill are not the same as flydraw...I've  not understood the flydraw filling correctly...
1836
	- corrected 'filltoborder' and 'floodfill' ... it should / could work now
1837
	- corrected command 'square x,y,side px,color'
1838
	  Changed several functions: new flaws in javascript may be introduced.
1839
	  the translation_ty being affine_matrix[5]
1840
	  the translation_tx being affine_matrix[4]
1841
	- removed internal variable used by 'translate' and moved to generic 'affine matrix'
1842
	- corrected affine : tx/ty now in x/y-range
16849 obado 1843
* 25/7	Thanks to Marina:
1844
 
1845
* 29/6
1846
	- added mousex / mousey commands : just show x or y values of mouse coordinates
1847
	- changed command 'barchart' : now "unlimited" barchart commands will be plotted in a single graph.
1848
	- reverted some correction mechanism for grid / axisnumbering when zooming out...need to rething
15111 schaersvoo 1849
          'userdraw vlines,color'
1850
          'userdraw vline,color'
1851
          'userdraw hlines,color'
1852
          'userdraw hline,color'
16849 obado 1853
	- added
15111 schaersvoo 1854
          Now the sequence is not important. However  both commands should be called at the end of the script
1855
          ('mouse' was only active when 'zoom' function was called before 'mouse')
16849 obado 1856
 
1857
* 28/6
1858
	- corrected preference behaviour of commands 'zoom' and 'mouse'
15111 schaersvoo 1859
	- removed some '\n' from js include code
14234 schaersvoo 1860
 
16849 obado 1861
* 27/6
1862
	- "replyformat 15" will only report inputfields/textareas set 'write' (eg not set 'readonly')
15111 schaersvoo 1863
	- added "replyformat 24" read all inputfields/textareas even those set 'readonly'
16849 obado 1864
* 23/6	- added command 'centerstring color,y,text' for placing a x-centered text in the canvas
1865
* 21/6
1866
	- corrected command jsplot : now more complex(...) functions may be used.
1867
	- increased value MAX_INT from 64 -> 128 : this is used for several arrays in C
1868
	- added some info on 'sgraph' (...)
1869
* 18/6
1870
	- solved small issue with removal of userdraw circle
15111 schaersvoo 1871
	- solved issue with precision (multiple roundings  x <--> px) in read_canvas() and js-functions x2px(x) / px2x(px):last precision in script is used for reply-precision
1872
	- fix stupid error in 'replyformat 23'
1873
	- zoom in y-direction was gone fishing...
1874
	- if wims_status='done' all 'drawing' related input fields are removed  (eg. userinput_xy etc)
1875
	- added flag to avoid multiple including of safe_eval, usd by several optional things
1876
	  added some alert message when inputstring has unfinished calculations , 'like 123 + 10^5/678'
1877
	- adapted 'safe_eval' to accept numbers like 2.345*10^5 (previous version only accepted 10^5...)
1878
          (barchart and linegraph are closely linked to grid: there can be multiple linegraphs in a single grid...but there can only be 1 grid)
16849 obado 1879
 
1880
* 17/6
1881
	- modified command 'piechart' and 'legend' : now multiple piecharts with legends may be present in a single canvas image
15111 schaersvoo 1882
 	- mouseup() in draglibrary corrected
16849 obado 1883
* 15/6	- added timeout for floodfill and filltoborder: the canvas was not yet 'drawn' in current setup , when floodfill was called...
1884
* 10/6	- added '(xy)snaptogrid' to drag library
15111 schaersvoo 1885
	  overide this default behaviour with keyword 'status' or 'nostatus'
16849 obado 1886
* 8/6
1887
	- inputfields/textarea's in canvasimage will be cleared and set 'readonly' when wims status variable is 'done'
15111 schaersvoo 1888
	  (in case you want to draw something...but not send the drawing to wims..)
1889
	- added 'replyformat -1' to disable the javascript read_canvas() function
1890
	  added commands 'userdraw arrow2' and 'userdraw arrows2'
16849 obado 1891
* 7/6
1892
	- corrected more inbalance in save() / restore() in 'draw_arrow()'
15111 schaersvoo 1893
	- corrected inbalance in save() / restore() causing annoying problems in command 'arc'
1894
	  todo CHECK THE REST !!
1895
	- added forgotten rotate&angle arguments to commands 'string / text'
1896
	- changed command 'grid' : now zooming and axisnumbering is slightly better...but it stays amateur scribling, grrrr...
1897
	- corrected typo "};else{" in javascript  replyformat 7
16849 obado 1898
* 6/6
1899
	- removed randomness from command clock (was annoying)
15111 schaersvoo 1900
	    added a lightweight javascipt function to convert math into js-math (only suitable for basic stuff)
1901
	    for plotting curves using clientside calculations: formula is verbatim in page-source
16849 obado 1902
	- added command jscurve color,formula_in_x
1903
* 5/6	- work in progress:
1904
* 2/6    - BPR: replace the dependance with libmatheval to the wims evaluation.
15111 schaersvoo 1905
	  allowing all combinations of 'setlimits', 'trace_jsmath' ,'jsmath' , 'userinput_xy+userdraw' , mouse , drag etc
16849 obado 1906
* 1/6
1907
	- added keyword 'setlimits'
15111 schaersvoo 1908
	- work in progress: added keyword 'setlimits'
16849 obado 1909
* 31/5	- slightly modified "trace_jsmath some_js_math_function_in_x" and "jsmath some_js_math_function_in_x"
1910
* 30/5	- added commands `trace_jsmath some_js_math_function_in_x` and `jsmath some_js_math_function_in_x`
1911
* 27/5	- javascript variable 'precision' was gone fishing
15111 schaersvoo 1912
	  level curve may be set 'onclick' or 'draggable'; every single curve has an unique identifier
16849 obado 1913
* 23/5	- command 'levelcurve' : the quality of the curves is not to be compared with the 'Flydraw levelcurve'
15111 schaersvoo 1914
          I'm not sure if this should be implemented in javascript...
16849 obado 1915
* 22/5	- work in progress: added command 'levelcurve'
15111 schaersvoo 1916
	  removed function get_double() from canvasdraw.
1917
	  corrected command 'rays color,xc,yc,x1,y1....xn,yn' (it was using pixels instead of x/y-range coordinates)
16849 obado 1918
* 21/5	- added forgotten commande 'dvline' and 'dhline'
15111 schaersvoo 1919
	  note: mouse coordinates (for drag / onclick) are not transformed....TODO)
16849 obado 1920
* 20/5	- added command 'affine a,b,c,d,tx,ty' and keyword 'killaffine'  (Marina Cazzola)
15111 schaersvoo 1921
	  'snaptogrid'  " will snap to both xmajor and ymajor (or xminor and yminor, if defined)
1922
	  'ysnaptogrid' : will snap to ymajor (or yminor, if defined)
1923
	  'xsnaptogrid' : will snap to xmajor (or xminor, if defined)
16849 obado 1924
* 19/5	- added keywords
15111 schaersvoo 1925
	- removed command 'debug'
1926
	    x1,y1,x2,y2,x3,y3,.....x(n-1),y(n-1),xn,yn
1927
	    x1,y1,x2,y2,x2,y2,x3,y3,x3,y3.....,x(n-1),y(n-1),x(n-1),y(n-1),xn,yn --replyformat 23-->
16849 obado 1928
* 18/5	- add replyformat 23 : used for 'userdraw polyline' : filtering out the second click on the same (+/- 5 px) point
15111 schaersvoo 1929
	  corrected mixup between userdraw polyline / polygon...
1930
	  if the mouse coordinate display or the student reply -in case of 'userdraw'-  needs a higher precision, just use as last command something like 'precision 10000'
16849 obado 1931
 
1932
* 16/5	- command 'precision' before ylogscale / xlogscale will set the number of decimals of the x-axis / y -axis (a local variable precision is set)
15111 schaersvoo 1933
	  corrected y-axis numbering in case of 'xlogscale'
16849 obado 1934
* 11/5
1935
	- added js function safe_eval() to command 'userinput_xy' to "safely" evaluate math inputs like 10^2 or sqrt(5)
1936
	- corrected x-axis numbering in case of 'ylogscale'
1937
	- corrected problems with ';' in html-text / text-arguments (the ';' is a command separator ... added 22/4)
1938
	- forgotten to clearRect()
15111 schaersvoo 1939
	  (just more copy and paste "programming")
16849 obado 1940
* 10/5	- added 'userdraw polygon,color'  'userdraw line,color' and 'userdraw lines,color' to userinput_xy
1941
* 5/5	- added commands 'ylogscale' , 'xlogscale' , 'xylogscale' , 'xlogbase' and 'ylogbase'
1942
* 25/4	- add 'nok' button to remove last item from userdraw arrays
15111 schaersvoo 1943
	  add keyword usertextarea_xy (...)
16849 obado 1944
* 24/4	- add userdraw polyline,color
1945
* 23/4	- corrected sgraph
1946
* 22/4	- added semicolon ; as 'new line separator' (Marina Cazzola)
1947
* 21/4	- corrected command grid in case xmin > 0  and / or ymin > 0
15111 schaersvoo 1948
	  for use as very (!) primitive 'broken axis graph'
16849 obado 1949
* 20/4	- work in progress: add command `sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color`
14295 schaersvoo 1950
 
16849 obado 1951
```
15111 schaersvoo 1952
	  'userdraw arrows,color'
1953
	  'userdraw arrow,color'
1954
	  'userdraw crosshairs,color'
1955
	  'userdraw crosshair,color'
1956
	  'userdraw circles,color'
1957
	  'userdraw circle,color'
1958
	  'userdraw points,color'
1959
	  'userdraw point,color'
1960
	  'userdraw segments,color'
1961
	  'userdraw segment,color'
1962
	  for now: only implemented in
16849 obado 1963
```
14295 schaersvoo 1964
 
16849 obado 1965
* 18/4	- added keyword 'userinput_xy' : if set 2 or 3 inputfields will be shown...the pupil will be able to 'draw' with mouse and/or by giving  a x-value and y-value (or radius-value)
1966
* 14/4   - added 'snaptogrid' to gridfill and dotfill (e.g. userdraw will snap to the grid)
1967
* 11/4	- corrected flaw in snaptogrid : now works correctly for dividers xminor  and yminor (only if they are even dividers e.g. 2,4,6,8 etc)
1968
* 8/4	- added to wims_svn
1969
 
1970
* 5/4	- corrected flaw in 'normal' userdraw (without snaptogrid)
15111 schaersvoo 1971
	  todo: other gridfill commands may use snaptogrid
1972
	  grid 1,1,black,2,2,6,grey  : will snap to all minor grid lines n/2
1973
	  grid 1,1,black : it will snap to all major grid lines 'n'
16849 obado 1974
* 2/4	- added command / keyword 'snaptogrid' : a userdrawing will snap to the given grid...
15111 schaersvoo 1975
	  added keyword 'status' to disable this default behaviour (e.g. pupils may draw in canvas when wims $status=done
16849 obado 1976
* 25/3	- userdraw functions only active if wims $status != done
15111 schaersvoo 1977
	  canvasdraw now only works in correct wims_environment : e.g. ./canvadraw < fly.txt  will not work anymore
1978
	  No option anymore to gzip the include.
1979
	  The rest is printed in a fairly small buffer and printed to stdout at the end of parsing the fly-script.
16849 obado 1980
* 23/3	- simplified buffer usage : now js-include file in wims-getfile-directoy is standard.
14295 schaersvoo 1981
 
16849 obado 1982
	Probably have to look into str_replace() !
1983
	segfault occured in case "blah" was not present in "temp"  (and no replacement was made) and string length wos big
1984
	On 32/64 bits FreeBSD ; 32/64 bits OpenBSD no problems
1985
 
1986
	```
1987
	if( strstr(temp,"blah") != 0 ){ temp = str_replace( temp ,"blah","beh");}
1988
    char *temp = getstring(infile,1);
1989
    Changed into:
1990
    char *temp = str_replace( getstring(infile,1),"blah","beh");
1991
	```
1992
* 21/3	- corrected spurious segfault on Gentoo 64 bits (leiden) and OpenSuSE-32 :
1993
* 14/3	- forgotten 'break;'
1994
* 3/3	- synchronized commands "arrow" and "arrow2" with flydraw syntax; e.g. arrow x1,y1,x2,y2,head_in_px,color
15111 schaersvoo 1995
	  It works if not too much cropping is required.
1996
	  The commands are still not equal to Flydraw: I'm giving up on this !!
16849 obado 1997
* 28/2
1998
	- tried to correct copy/ropyresized ; using image as background image of div (e.g. no canvas !)
1999
	  We just use the URL of the image...and add some CSS to it (no-repreat / Size / Position) and det the URL to the backgroundImage of the main div
2000
	- an external image copied into a canvas / resized etc... can be set as background of the document.body...
2001
	- an external image copied into a canvas / resized etc... can not be set as CSS backgroundImage of a div... (at least in firefox)
2002
	- there is no way to paint on top of an external image loaded into a canvas...
14295 schaersvoo 2003
 
16849 obado 2004
* 27/2	- solved nasty issue with "drawing on top of external image"  with copy / copyresized
2005
* 19/2	- added command 'animate type' as primitive animation ; only 'point' on curve is implemented
15111 schaersvoo 2006
	  Using generic js-functions in wims-pages to read all mathml-inputs (including the ones in a canvas image !)
16849 obado 2007
* 12/2	- removed reading of mathml-inputfield in canvas (only "replyformat 16" will read it)
14295 schaersvoo 2008
 
15111 schaersvoo 2009
	  canvas_div.style.background-size --> canvas_div.style.backgroundSize
16849 obado 2010
* 8/2
2011
	- corrected syntax in bgimage:
15111 schaersvoo 2012
	- command "bgimage url" will scale to fit background image
16849 obado 2013
* 7/2
2014
	- corrected x-y mixup in case xrange/yrange was forgotten (eg xrange = 0 px ,sizex px)
15111 schaersvoo 2015
	- added forgotten filling of an arc ;command 'filledarc'
2016
	  (something like:fontfamily bold italic 24px Courier)
2017
	  the rest of the gridfonts (numbering or x/yaxis text) is determined by the 'fontfamily'
16849 obado 2018
* 6/2
2019
	- added default fontfamily settings to 'legend', 'xlabel' and 'ylabel' ; size may be set by command 'fontsize'
15111 schaersvoo 2020
	- add command 'dsegment' as alias for dashed segment
2021
	  eg only active inputfields will be read with read_canvas();
16849 obado 2022
* 5/2	- if inputfield has attribute 'readonly', do not read the value when using javascript:read_canvas();
2023
* 3/2
2024
	- added forgotten 'readonly' attribute to js-function 'draw_inputs()'
2025
	- solved(?) some strange fill issues (pixel manipulation) added demo
14295 schaersvoo 2026
 
15111 schaersvoo 2027
          If legendcolors was not set , the default stroke_color will be used in a 'legend'
2028
          for all other legends, we can specify.
2029
          barchart & piechart will use -ofcourse- the same colours for legend
16849 obado 2030
* 1/2
2031
	- add command 'legendcolors color1:color2:color3:...:color_n'
15111 schaersvoo 2032
	- command 'legend string1:string2:string3:..:string_n' may now be used with any 'grid' (e.g. not only for barchart/linegraph/piechart)
2033
	- commands 'xlabel' 'ylabel' only depend on command 'grid' (eg without 'axis' and/or 'axisnumbering')
2034
	- added commands 'xlabel some_string' ylabel some_string'
2035
	- corrected tooltip when using images as 'linktext'
14295 schaersvoo 2036
 
15111 schaersvoo 2037
	will output reply[0]=x1 reply[1]=y1 reply[2]=x2 reply[3]=y2 ... reply[n-1]=x_n reply[n]=y_n
16849 obado 2038
 
2039
* 31/1
2040
	- read_canvas() : Added 'replyformat 22' : single array output (just for use in my existing checkfile)
15111 schaersvoo 2041
	will output words (x1:y1) (x2:y2) (x3:y3) ... (x_n:y_n)
2042
	- read_canvas() : Added 'replyformat 21' : verbatim coordinate output (just for use in my existing checkfile)
2043
	Command "intooltip tooltip_text" will accept html-text, images and now also Mathml as tooltip_text
16849 obado 2044
	- Now "mouse red,24" will default to font '24px Arial'
15111 schaersvoo 2045
	fontfamily [type] [size]px [family]
2046
	was set, the argument fontsize of command "mouse color,fontsize" was ignored...due to the strict syntax in html/js
16849 obado 2047
 
2048
* 29/1  - Corrected js-fontfamily kludge...when something like "fontfamily italic 14px Arial"
15111 schaersvoo 2049
	(On multiple panning/zooming the mouse coordinate display will get 'sluggish' and not very quick in response)
2050
	When 'x' is pressed the page will reload (location.reload();) so the panned/zoomed image or drawing will be reset to it's original state.
16849 obado 2051
 
2052
* 23/1	Added a 'x' to pan/zoom-buttons (command "zoom color")
2053
	`xaxis -4*pi:-4\u03c0:-3*pi:-3\u03c0:-2*pi:-2\u03c0:-1*pi:-\u03c0:pi/2:\u03c0/2:pi:\u03c0`
15111 schaersvoo 2054
	example (unicode allowed; no html)
16849 obado 2055
 
2056
		yaxis y_value:y_text:y_value:y_text:y_value:y_text....
2057
		xaxis x_value:x_text:x_value:x_text:x_value:x_text....
2058
 
2059
* 22/1 Corrected commands with "pi"... javascript did not calculate the x-value...
2060
 
2061
## 2014
2062
(was using keyword 'input' but changed wims_mathml to use a styled textarea as input...)
2063
 
2064
* 28/12 in case of command 'mathml' , look for 'mathml0' to trigger javascript:read_mathml() if no other ineractiveness was previously defined
2065
* 29/11 copy & copyresized of external images : preparing for drag&drop (outside the drag&drop shape library)
15111 schaersvoo 2066
	correction of zoom_buttons (wrong panning in wrong direction...)
16849 obado 2067
* 27/11 improved plotting of asymptotic curves
2068
* 16/11 setting & reading clock (preliminiary: for now just html-buttons for adjusting H,M,S...should be active fields in canvas...)
15111 schaersvoo 2069
	custom  colours: clock 0,0,60,4,35,45,1,2,white,white,white,black,yellow
2070
	custom  colours: clock 0,0,60,4,35,45,1,2,,,,yellow,red
2071
	default colours: clock 0,0,60,4,35,45,1,2,[space]
2072
	clock x,y,r(px),H,M,S,type hourglass,interactive [ ,H_color,M_color,S_color,background_color,foreground_color ]
16849 obado 2073
* 15/11 changed basic syntax of command clock : all colours are now optional
15111 schaersvoo 2074
	Temporarily removed check on 'valid wims-session' : it is not working for a 'chroot' environment (TODO correct this !!)
2075
	(only when using canvasdraw in a 'chroot' environment , giving : Undefined symbol "_ThreadRuneLocale)
2076
	I can not use the normal implementations found in 'ctypes.h' for this purpose, due to a bug in FreeBSD's C-library
16849 obado 2077
* 14/11 implemented own versions of "tolower()" and "toupper()"...
15111 schaersvoo 2078
	clock x,y,r(px),H,M,S,type hourglass,interactive,H_color,M_color,S_color,background_color,foreground_color
16849 obado 2079
* 13/11 Added interactive=2 (multiple choice  / onclick) to select a single clock
15111 schaersvoo 2080
	(work in progress)
2081
	Add basic interactivness
2082
	Add argument 'hourglass type' to controle appearance of analogue clock
16849 obado 2083
* 12/11 Multiple clocks may be set interactive ; read_canvas() will read all active clocks in H:M:S
15111 schaersvoo 2084
	Preparing for command clock (work in progress)
2085
	(was x/y-range -10,10)
2086
	ymin = 0 ymax = ysize
2087
	xmin = 0 xmax = xsize
16849 obado 2088
* 11/11 If xrange / yrange is not given :
15111 schaersvoo 2089
	Todo: check compatibility...I'm not sure it works the same as in 'flydraw'
2090
	"copyresized x1,y2,x2,y2,dx1,dy1,dx2,dy2,filename_URL"	and "copy x,y,x1,y1,x2,y2,filename_URL"
16849 obado 2091
* 08/11 Added commands
15111 schaersvoo 2092
	Just use a fairly recent Firefox / Opera / Chrome
2093
	E.g all non supported browsers will be excluded...no intention to offer 'canvas glue' library for IE < 9
2094
	try(document.createElement('canvas');)catch(e){alert("no support");return;}
16849 obado 2095
* 03/11	Added check on canvas-support in function 'create_canvas()';
2096
* 01/11 Added 'userdraw text,color' to reply types
15111 schaersvoo 2097
	a confirm will popup asking to delete the selected text.This text will be removed from the "userdraw_txt()" answer array.
16849 obado 2098
	Placing the cursor somewhere on a typed text and hitting "delete/backspace/esc",
15111 schaersvoo 2099
	You will need to hit "enter" to add the text to the array "userdraw_txt()" : lightblue background will disappear
2100
	"backspace / delete / esc" will remove typed text.
2101
	While typing the background of every typed char will be lightblue...
2102
	Any string of multiple strings may be placed anywhere on the canvas.
16849 obado 2103
* 30/10 Finished command 'userdraw text,color'
15111 schaersvoo 2104
	(it is ofcource possible, but at a very very high price)
2105
	because the mouse coordinates do not follow the transformation matrix if in the proximity of a text-object.
2106
	vertical or rotated text can not be set drag / onclick,
16849 obado 2107
* 29/10 add horizontal text to drag / onclick
2108
* 28/10 preparing for adding all 'text' commands to drag / click library
15111 schaersvoo 2109
	Would be nice to have some feedback (...)
2110
	need to find a way to bypass browser differences...using 'String.fromCharCode(evt.keyCode);' is not really a safe method ?
16849 obado 2111
* 27/10 add command "userdraw text,color" work in progress...just a single char, for now (no answer_type,yet)
15111 schaersvoo 2112
	(for example to be used for a barchart created by students)
2113
	add commands "userdraw rects,color" "userdraw roundrects,color" for drawing multiple rectangles
2114
	Many different linegraphs may be used in a single plot.
2115
	to be used together with commands 'grid'. May be combined with freestyle x-axis / y0-axis text (commands 'xaxis' 'yaxis')
16849 obado 2116
* 26/10 add command "linegraph x1:y1:x2:y2...x_n:y_n" : may be further controlled by commands 'strokecolor','linewidth','dashed','dashtype'
15111 schaersvoo 2117
	to be used together with commands 'grid'. May be combined with freestyle x-axis / y0-axis text (commands 'xaxis' 'yaxis')
2118
	add command "barchart x1:y1:color1:x2:y2:color2...x_n:y_n:color_n" to automate generation of barchart
16849 obado 2119
* 25/10 add command "legend string1:string2:...:string_n" to add an automatically sized legend to a graph
2120
* 24/10 add command "piechart xc,yc,radius,'data+colorlist'"
14295 schaersvoo 2121
 
15111 schaersvoo 2122
	add command "fontcolor color" (previously fontcolor=strokecolor) now x/y axis-texts color may be different from axis / xy-tics color
16849 obado 2123
* 22/10 grid: x/y major tics and x/y minor tics now different
15111 schaersvoo 2124
	update 'drag curve fill mathml-input' example (selective removal of filled area)
2125
	freestyle x/y-axistext move with panning (e.g stay in visual image)
2126
	to automate filling axis with text insteadof default numbering xmin...xmax
2127
	yaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string-n
2128
	xaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string-n
16849 obado 2129
* 21/10 added commands:
15111 schaersvoo 2130
	tried to improve 'axisnumbering' in command 'grid' ( avoiding number overlap )
16849 obado 2131
* 20/10 added testresults flydraw versus canvasdraw.
15111 schaersvoo 2132
	added "use_rotate" argument to shape library
16849 obado 2133
* 19/10 ellipse x,y,rx,ry,color is draggable/clickable and will scale/resize on zooming (like all other draggable 'massive' objects)
15111 schaersvoo 2134
	multiple instances of tooltip are allowed (as ofcourse is true for multiple canvas)
16849 obado 2135
* 18/10 corrected tooltip to work / integrate in 'real' wims modules
2136
* 15/10 circle x,y,radius(px),color will scale/resize on zooming (like all other draggable 'massive' objects)
2137
* 13/10 corrected hexcolor input
15111 schaersvoo 2138
	reading of useractions in canvas is only possible for a single instance (for now)
2139
	(experimental work in progress)
2140
	by using unique names for all potential conflicting functions
16849 obado 2141
* 12/10 added support for multi-canvasses in a single html-page
2142
* 10/10 added missing "userdraw polygone,color"
2143
* 9/10  added parallel to shape_library
15111 schaersvoo 2144
	default distance is 20 pix from original 'fill click'
2145
	size of 'measuring rectangle' may be tuned with "clickfillmarge"
16849 obado 2146
* 8/10  added specific removal of a 'click_filled' area.
2147
* 7/10  added arc to shape_library
2148
* 6/10  corrected syntax "fill" == "floodfill" = pixel filling to a border
2149
* 5/10  added missing "userdraw rect,color" "userdraw roundrect,color" "userdraw triangle,color"
2150
* 4/10  added missing "userdraw line,color" "userdraw lines,color"
14381 schaersvoo 2151
 
15111 schaersvoo 2152
or search keywords 'html5' 'canvas' om leiden mirror
2153
For live testing: use "directexec" module on Leiden mirror.
2154
For demo: see demo-directory.
2155
For implemented commands: see canvasdraw.html
2156
   (first need to solve  re-draw issues; managing multiple canvasses in drag/click library)
16849 obado 2157
	- Isolate static javascript code  components/functions from C-"programs"
2158
	- Some bitmap operations (like copyresize etc)
2159
	- OEF interface
15111 schaersvoo 2160
Unadressed issues at this point :
14544 schaersvoo 2161
 
15111 schaersvoo 2162
Opera (>9)
2163
Gecko browsers (Firefox > 17)
2164
Microsoft IE10
2165
Tested on :
14546 schaersvoo 2166
 
15111 schaersvoo 2167
(on Leiden mirror and intranet servers only)
2168
It will be used and tested to replace "flydraw" , "GeoGebra" and "flyapplet" in Schaersvoorde modules.
2169
Preliminary version. All javascript code is generated by 'C-program'
14548 schaersvoo 2170
 
16849 obado 2171
* 4/10/2013 First version