Subversion Repositories wimsdev

Rev

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