Rev 16827 | Rev 16832 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 16827 | Rev 16828 | ||
---|---|---|---|
Line 3115... | Line 3115... | ||
3115 | 3115 | ||
3116 | case MULTIDRAW: |
3116 | case MULTIDRAW: |
3117 | /* |
3117 | /* |
3118 | @ multidraw obj_type_1,obj_type_2...obj_type_11 |
3118 | @ multidraw obj_type_1,obj_type_2...obj_type_11 |
3119 | @ for simple single object user drawings you could also use command <a href="#userdraw">userdraw</a> |
3119 | @ for simple single object user drawings you could also use command <a href="#userdraw">userdraw</a> |
3120 | @ implemented obj_types:<ul><li>point | points</li><li>circle | circles</li><li>line | lines</li><li>segment | segments</li><li>arrow | arrows (use command 'arrowhead int' for size (default value 8 pixels))</li><li>curvedarrow | curvedarrows</li><li>rect | rects</li><li>closedpoly<br /><b>only one</b> closedpolygon may be drawn.The number of ''corner points`` is not preset (e.g. not limited, freestyle), the polygon is closed when clicking on the first point again..(+/- 10px)</li><li>triangle | triangles</li><li>parallelogram | parallelograms</li><li>poly[3-9] | polys[3-9] draw 3...9 point polygone(s): polys3 is of course triangles</li><li>images</li><li>crosshair | crosshairs</li><li>function |
3120 | @ implemented obj_types:<ul><li>point | points</li><li>circle | circles</li><li>line | lines</li><li>segment | segments</li><li>arrow | arrows (use command 'arrowhead int' for size (default value 8 pixels))</li><li>curvedarrow | curvedarrows</li><li>rect | rects</li><li>closedpoly<br /><b>only one</b> closedpolygon may be drawn.The number of ''corner points`` is not preset (e.g. not limited, freestyle), the polygon is closed when clicking on the first point again..(+/- 10px)</li><li>triangle | triangles</li><li>parallelogram | parallelograms</li><li>poly[3-9] | polys[3-9] draw 3...9 point polygone(s): polys3 is of course triangles</li><li>images</li><li>crosshair | crosshairs</li><li>function <br/>for more function user input fields, use it multiple times<br />for 4 inputfields use : multidraw function,function,function,function</li></ul> |
3121 | @ additionally objects may be user labelled, using obj_type ''text``...<br />in this case allways a text input field and if <a href='#multiuserinput'> multiuserinput=1 </a> also (x:y) inputfields will be added to the page.<br />use commands ''fontfamily`` and ''fontcolor`` to adjust (command ''multistrokeopacity`` may be set to adjust text opacity)<br />note: text is always centered on the mouse-click or user-input coordinates !<br />note: no keyboard listeners are used |
3121 | @ additionally objects may be user labelled, using obj_type ''text``...<br />in this case allways a text input field and if <a href='#multiuserinput'> multiuserinput=1 </a> also (x:y) inputfields will be added to the page.<br />use commands ''fontfamily`` and ''fontcolor`` to adjust (command ''multistrokeopacity`` may be set to adjust text opacity)<br />note: text is always centered on the mouse-click or user-input coordinates !<br />note: no keyboard listeners are used |
3122 | @ it makes no sense using something like ''multidraw point,points`` ... <br />something like "multidraw polys4,polys7" will only result in drawing a ''4 point polygone`` and not a ''7 point polygone``: this is a design flaw and not a feature... |
3122 | @ it makes no sense using something like ''multidraw point,points`` ... <br />something like "multidraw polys4,polys7" will only result in drawing a ''4 point polygone`` and not a ''7 point polygone``: this is a design flaw and not a feature... |
3123 | @ note: mouselisteners are only active if "$status != done " (eg only drawing in an active/non-finished exercise) <br /> to overrule use command/keyword "status" (no arguments required) |
3123 | @ note: mouselisteners are only active if "$status != done " (eg only drawing in an active/non-finished exercise) <br /> to overrule use command/keyword "status" (no arguments required) |
3124 | @ buttons for changing the obj_type (and in case of ''multiuserinput``, some inputfields and buttons) <br />will be present in the reserved div ''tooltip_div`` and can be styled using command 'css some_css' |
3124 | @ buttons for changing the obj_type (and in case of ''multiuserinput``, some inputfields and buttons) <br />will be present in the reserved div ''tooltip_div`` and can be styled using command 'css some_css' |
3125 | @ the button label will be default the ''object primitive name`` (like ''point``, ''circles``).<br />If you want a different label (e.g. an other language), use command ''multilabel``<br />for example in dutch: <br /><code>multilabel cirkel,lijnstuk,punten,STOP<br />multidraw circle,segment,points</code><br />(see command <a href='#multilabel'>multilabel</a> for more details) |
3125 | @ the button label will be default the ''object primitive name`` (like ''point``, ''circles``).<br />If you want a different label (e.g. an other language), use command ''multilabel``<br />for example in dutch: <br /><code>multilabel cirkel,lijnstuk,punten,STOP<br />multidraw circle,segment,points</code><br />(see command <a href='#multilabel'>multilabel</a> for more details) |
Line 3131... | Line 3131... | ||
3131 | @ It is best to prepare / format the student reply in clientside javascript.<br />However in ''wims`` language you could use something like this<br />for example you are interested in the polys5 drawings of a pupil (the pupil may draw multiple poly5 objects...)<br />note: the reply for 2 poly5's is: x11,x12,x13,x14,x15,x21,x22,x23,x24,x25 ; y11,y12,y13,y14,y15,y21,y22,y23,y24,y25<br />rep = !line 7 of reply <br />rep = !translate ';' to '\\n' in $rep <br />pts = 5 # 5 points for polygon <br />x_rep = !line 1 of $rep <br />y_rep = !line 2 of $rep <br />tot = !itemcnt $x_rep <br />num_poly = $[$tot/$pts] <br />idx = 0 <br />!for p=1 to $num_poly <br /> !for s=1 to $pts <br /> !increase idx <br /> X = !item $idx of $x_rep <br /> Y = !item $idx of $y_rep <br /> # do some checking <br /> !next s <br />!next p <br /> |
3131 | @ It is best to prepare / format the student reply in clientside javascript.<br />However in ''wims`` language you could use something like this<br />for example you are interested in the polys5 drawings of a pupil (the pupil may draw multiple poly5 objects...)<br />note: the reply for 2 poly5's is: x11,x12,x13,x14,x15,x21,x22,x23,x24,x25 ; y11,y12,y13,y14,y15,y21,y22,y23,y24,y25<br />rep = !line 7 of reply <br />rep = !translate ';' to '\\n' in $rep <br />pts = 5 # 5 points for polygon <br />x_rep = !line 1 of $rep <br />y_rep = !line 2 of $rep <br />tot = !itemcnt $x_rep <br />num_poly = $[$tot/$pts] <br />idx = 0 <br />!for p=1 to $num_poly <br /> !for s=1 to $pts <br /> !increase idx <br /> X = !item $idx of $x_rep <br /> Y = !item $idx of $y_rep <br /> # do some checking <br /> !next s <br />!next p <br /> |
3132 | @ <b>attention</b>: for command argument ''closedpoly``, only one polygone can be drawn. The last point (e.g. the point clicked near the first point) of the array is removed. |
3132 | @ <b>attention</b>: for command argument ''closedpoly``, only one polygone can be drawn. The last point (e.g. the point clicked near the first point) of the array is removed. |
3133 | @ technical: all 10 ''draw primitives`` + ''text`` will have their own -transparent- PNG bitmap canvas. <br />So for example there can be a points_canvas entirely separated from a line_canvas.<br />This to avoid the need for a complete redraw when something is drawn to the canvas...(eg only the object_type_canvas is redrawn), this in contrast too many very slow do-it-all HTML5 canvas javascript libraries.<br />The mouselisteners are attached to the canvas-div element. |
3133 | @ technical: all 10 ''draw primitives`` + ''text`` will have their own -transparent- PNG bitmap canvas. <br />So for example there can be a points_canvas entirely separated from a line_canvas.<br />This to avoid the need for a complete redraw when something is drawn to the canvas...(eg only the object_type_canvas is redrawn), this in contrast too many very slow do-it-all HTML5 canvas javascript libraries.<br />The mouselisteners are attached to the canvas-div element. |
3134 | @ a special object type is ''images``.<br />if used together with <a href='#imagepalette'>imagepalette</a> a image table will be integrated in the 'control section' of multidraw (set <code>multiuserinput 1</code> for ''images``) if not used with <a href='#imagepalette'>imagepalette</a>, provide the images or div's (<img> tag with bitmap or SVG or anything in a div element) somewhere on the html exercise page, with an onclick handler like:<br /><code><img src='gifs/images/dog.svg' onclick='javascript:place_image_on_canvas(this.id);' id="ext_image_1" /><br /><img src='gifs/fish.png' onclick='javascript:place_image_on_canvas(this.id);' id="another" /></code><br />etc ... when activating the multidraw ''image`` button, the images can be selected<br /> (left mouse button/onclick) and placed on the canvas...left mouse click.<br />using div's will enable you -amongst other content- to add math typesetting from the exercise page onto the canvas. |
3134 | @ a special object type is ''images``.<br />if used together with <a href='#imagepalette'>imagepalette</a> a image table will be integrated in the 'control section' of multidraw (set <code>multiuserinput 1</code> for ''images``) if not used with <a href='#imagepalette'>imagepalette</a>, provide the images or div's (<img> tag with bitmap or SVG or anything in a div element) somewhere on the html exercise page, with an onclick handler like:<br /><code><img src='gifs/images/dog.svg' onclick='javascript:place_image_on_canvas(this.id);' id="ext_image_1" /><br /><img src='gifs/fish.png' onclick='javascript:place_image_on_canvas(this.id);' id="another" /></code><br />etc ... when activating the multidraw ''image`` button, the images can be selected<br /> (left mouse button/onclick) and placed on the canvas...left mouse click.<br />using div's will enable you -amongst other content- to add math typesetting from the exercise page onto the canvas. |
3135 | @ 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...</br>To activate this feature, use <a href='#multilabel'>multilabel NOCONTROLS</a><br />The object types are internally represented by the following numbers (making typos will render your exercise null and void)<br/>point = 0<br />points =1<br />circle = 2<br />circles = 3<br />line = 4<br />lines = 5<br />segment = 6<br />segments = 7<br />arrow = 8<br />arrows = 9<br />triangle = 10<br />triangles = 11<br />closedspoly = 12<br />text = 13<br />rect = 14<br />rects = 15<br />poly[3-9] = 16<br />polys[3-9] = 17<br />parallelogram = 18<br />parallelograms = 19<br />images = 20<br />curvedarrow = 21<br />curvedarrows = 22<br />curvedarrow2 = 23<br />curvedarrows2 = 24<br />crosshair = 25<br />crosshairs = 26 <br />controls for example:<br /><code><input type='button' onclick='javascript:userdraw_primitive=null' value='STOP DRAWING' /><br /><input type='button' onclick='javascript:userdraw_primitive=24;multidraw_object_cnt = 0;' value='start drawing curvedarrows2' /> <br /><input type='button' onclick='javascript:var fun=eval("clear_draw_area"+canvas_scripts[0]);fun(24,0);' value='REMOVE LAST CURVEDARROW ' /> </code><br/> If using multiple canvas scripts in a single page, loop through the canvas_scripts[n] <br />note: if using NOCONTROLS and just a single draw primitive (for example, just: 'multidraw circles'), the object may be drawn directly. (analogue to 'userdraw circles,color')<br />And since a right mouse button click will always remove the last drawn object of the current object type, there is no need for a special "remove button" |
3135 | @ 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...</br>To activate this feature, use <a href='#multilabel'>multilabel NOCONTROLS</a><br />The object types are internally represented by the following numbers (making typos will render your exercise null and void)<br/>point = 0<br />points =1<br />circle = 2<br />circles = 3<br />line = 4<br />lines = 5<br />segment = 6<br />segments = 7<br />arrow = 8<br />arrows = 9<br />triangle = 10<br />triangles = 11<br />closedspoly = 12<br />text = 13<br />rect = 14<br />rects = 15<br />poly[3-9] = 16<br />polys[3-9] = 17<br />parallelogram = 18<br />parallelograms = 19<br />images = 20<br />curvedarrow = 21<br />curvedarrows = 22<br />curvedarrow2 = 23<br />curvedarrows2 = 24<br />crosshair = 25<br />crosshairs = 26 <br />controls for example:<br /><code><input type='button' onclick='javascript:userdraw_primitive=null' value='STOP DRAWING' /><br /><input type='button' onclick='javascript:userdraw_primitive=24;multidraw_object_cnt = 0;' value='start drawing curvedarrows2' /> <br /><input type='button' onclick='javascript:var fun=eval("clear_draw_area"+canvas_scripts[0]);fun(24,0);' value='REMOVE LAST CURVEDARROW ' /> </code><br/> If using multiple canvas scripts in a single page, loop through the canvas_scripts[n] <br />note: if using NOCONTROLS and just a single draw primitive (for example, just: 'multidraw circles'), the object may be drawn directly. (analogue to 'userdraw circles,color')<br />And since a right mouse button click will always remove the last drawn object of the current object type, there is no need for a special "remove button" |
- | 3136 | @%multidraw_function%size 400,400%xrange -10,10%yrange -10,10%fontfamily Italic 22px Helvetica%axis%axisnumbering%precision 0%grid 2,2,grey,1,1,5,black%multicolors red,green,blue%fontcolor orange%multilinewidth 1,2,3%multidraw text,function,function,function,line |
|
3136 | @%multidraw%size 400,400%xrange -10,10%yrange -10,10%multidash 1,0%multilinewidth 1,2%multistrokecolors red,blue%multisnaptogrid 1,1%multilabel LINES,CIRCLES,STOP DRAWING%multidraw lines,circles |
3137 | @%multidraw%size 400,400%xrange -10,10%yrange -10,10%multidash 1,0%multilinewidth 1,2%multistrokecolors red,blue%multisnaptogrid 1,1%multilabel LINES,CIRCLES,STOP DRAWING%multidraw lines,circles |
3137 | @%multidraw_images%size 400,400%xrange -10,10%yrange -10,10%grid 1,1,grey%drag xy%# use special function to read the drag coordinates%copy 0,0,-1,-1,-1,-1,gifs/images/skull_and_crossbones50.png%fontcolor green%fontfamily Bold 42pt Arial%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%multiuserinput 0,0,1%css color:blue;%multisnaptogrid 1,1,1%multilinewidth 0,4,0%# attention: use unicode text input without the slash %# \u222D ---> u222D at least will sometimes work%# otherwise cut&past unicode symbols into inputfield...%multilabel TEXT,REACTION ARROW,FLAGS,STOP DRAWING%multidraw text,arrow,images |
3138 | @%multidraw_images%size 400,400%xrange -10,10%yrange -10,10%grid 1,1,grey%drag xy%# use special function to read the drag coordinates%copy 0,0,-1,-1,-1,-1,gifs/images/skull_and_crossbones50.png%fontcolor green%fontfamily Bold 42pt Arial%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%multiuserinput 0,0,1%css color:blue;%multisnaptogrid 1,1,1%multilinewidth 0,4,0%# attention: use unicode text input without the slash %# \u222D ---> u222D at least will sometimes work%# otherwise cut&past unicode symbols into inputfield...%multilabel TEXT,REACTION ARROW,FLAGS,STOP DRAWING%multidraw text,arrow,images |
3138 | @%multidraw_demo%size 800,800%xrange -10,10%yrange -10,10%axis%axisnumbering%precision 1%grid 2,2,grey,2,2,5,grey%css color:blue;%fontfamily Italic 42pt Arial%precision 1%opacity 200,50%snaptogrid%linewidth 3%filled%multistrokecolors red,green,blue,orange,yellow,purple,black,cyan,red,green,blue,orange,green,purple,black,cyan%multifillcolors red,green,blue,orange,yellow,purple,black,cyan,red,green,blue,orange,brown,purple%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%multidraw closedpoly,segments,rect,parallelogram,triangles,poly5,points,lines,arrows,circles,text,curvedarrows,curvedarrows2,images |
3139 | @%multidraw_demo%size 800,800%xrange -10,10%yrange -10,10%axis%axisnumbering%precision 1%grid 2,2,grey,2,2,5,grey%css color:blue;%fontfamily Italic 42pt Arial%precision 1%opacity 200,50%snaptogrid%linewidth 3%filled%multistrokecolors red,green,blue,orange,yellow,purple,black,cyan,red,green,blue,orange,green,purple,black,cyan%multifillcolors red,green,blue,orange,yellow,purple,black,cyan,red,green,blue,orange,brown,purple%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%multidraw closedpoly,segments,rect,parallelogram,triangles,poly5,points,lines,arrows,circles,text,curvedarrows,curvedarrows2,images |
3139 | @%multidraw_NOCONTROLS%size 400,400%xrange -10,10%yrange -10,10%grid 2,2,grey%linewidth 3%strokecolor green%fillcolor blue%filled%opacity 255,60%multilabel NOCONTROLS%multidraw circles%# RIGHT MOUSE CLICK REMOVES LAST OBJECT |
3140 | @%multidraw_NOCONTROLS%size 400,400%xrange -10,10%yrange -10,10%grid 2,2,grey%linewidth 3%strokecolor green%fillcolor blue%filled%opacity 255,60%multilabel NOCONTROLS%multidraw circles%# RIGHT MOUSE CLICK REMOVES LAST OBJECT |
3140 | @%multidraw function%size 400,400%xrange -10,10%yrange -10,10%fontfamily Italic 22px Helvetica%axis%axisnumbering%precision 0%grid 2,2,grey,1,1,5,black%multicolors red,green,blue%fontcolor orange%multilinewidth 1,2,3%multidraw text,functions,line |
- | |
3141 | */ |
3141 | */ |
3142 | js_function[INTERACTIVE] = 1; |
3142 | js_function[INTERACTIVE] = 1; |
3143 | if(js_function[JS_ZOOM] == 1){use_zoom = 1;} /* use noisy zoom_code, when command zoom is given before command 'multidraw' */ |
3143 | if(js_function[JS_ZOOM] == 1){use_zoom = 1;} /* use noisy zoom_code, when command zoom is given before command 'multidraw' */ |
3144 | if( use_tooltip == 1 ){canvas_error("command 'multidraw' is incompatible with command 'intooltip tip_text'");} |
3144 | if( use_tooltip == 1 ){canvas_error("command 'multidraw' is incompatible with command 'intooltip tip_text'");} |
3145 | if( use_userdraw == 1 ){canvas_error("Only one userdraw primitive may be used in command 'userdraw' use command 'multidraw' for this...");} |
3145 | if( use_userdraw == 1 ){canvas_error("Only one userdraw primitive may be used in command 'userdraw' use command 'multidraw' for this...");} |
Line 3175... | Line 3175... | ||
3175 | if(strstr(temp,"text") != NULL){ |
3175 | if(strstr(temp,"text") != NULL){ |
3176 | js_function[JS_SAFE_EVAL] = 1; |
3176 | js_function[JS_SAFE_EVAL] = 1; |
3177 | js_function[DRAW_SUBSUP] = 1; |
3177 | js_function[DRAW_SUBSUP] = 1; |
3178 | } |
3178 | } |
3179 | if(strstr(temp,"function") != NULL){ |
3179 | if(strstr(temp,"function") != NULL){ |
- | 3180 | int funs = count_substring(temp, "function"); |
|
3180 | js_function[JS_SAFE_EVAL] = 1; |
3181 | js_function[JS_SAFE_EVAL] = 1; |
3181 | js_function[JS_RAWMATH] = 1; |
3182 | js_function[JS_RAWMATH] = 1; |
3182 | js_function[DRAW_JSFUNCTION] = 1; |
3183 | js_function[DRAW_JSFUNCTION] = 1; |
3183 | js_function[JS_MATH] = 1; |
3184 | js_function[JS_MATH] = 1; |
3184 | js_function[JS_PLOT] = 1; |
3185 | js_function[JS_PLOT] = 1; |
3185 | add_input_jsfunction(css_class,function_label,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1],font_size); |
- | |
3186 | input_cnt++; |
- | |
3187 | jsplot_cnt++; |
- | |
3188 |
|
3186 | for(int pp = 0 ; pp< funs ;pp++){ |
3189 | add_input_jsfunction(css_class,function_label,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1],font_size); |
3187 | add_input_jsfunction(css_class,function_label,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1],font_size); |
3190 | input_cnt++; |
3188 | input_cnt++; |
3191 | jsplot_cnt++; |
3189 | jsplot_cnt++; |
3192 | } |
3190 | } |
3193 | fprintf(js_include_file,"if(typeof(all_jsplots) !== 'number'){var all_jsplots;};all_jsplots = %d;function redraw_userdraw(){redraw_jsplot();return;};",jsplot_cnt); |
3191 | fprintf(js_include_file,"if(typeof(all_jsplots) !== 'number'){var all_jsplots;};all_jsplots = %d;function redraw_userdraw(){redraw_jsplot();return;};",jsplot_cnt); |
3194 | } |
3192 | } |
3195 | /* the canvasses range from 1000 ... 1008 */ |
3193 | /* the canvasses range from 1000 ... 1008 */ |
3196 | if( reply_format == 0){reply_format = 29;} |
3194 | if( reply_format == 0){reply_format = 29;} |
3197 | reset();/* if command 'filled' / 'dashed' was given...reset all */ |
3195 | reset();/* if command 'filled' / 'dashed' was given...reset all */ |
3198 | break; |
3196 | break; |
3199 | case MULTILABEL: |
3197 | case MULTILABEL: |
3200 | /* |
3198 | /* |
3201 | @ multilabel button_label_1,button_label_2,...,button_label_8,'stop drawing text' |
3199 | @ multilabel button_label_1,button_label_2,...,button_label_8,'stop drawing text' |
3202 | @ use before command <a href='#multidraw'>multidraw</a> |
3200 | @ use before command <a href='#multidraw'>multidraw</a> |
3203 | @ if not set all labels (e.g. the value of input type 'button') will be set by the english names for the draw_primitives (like 'point','circle'...) |
3201 | @ if not set all labels (e.g. the value of input type 'button') will be set by the english names for the draw_primitives (like 'point','circle'...) |
Line 3240... | Line 3238... | ||
3240 | @ meaning draw objects no. 3 and 5, in the list of command ''multifill``, are filled (if the object is fillable...and not a line,segment,arrow or point...) |
3238 | @ meaning draw objects no. 3 and 5, in the list of command ''multifill``, are filled (if the object is fillable...and not a line,segment,arrow or point...) |
3241 | @ using a fillpattern: multifill 0,1,2,5,3,4<br />meaning: first object is not filled...second object is solid color filled...2=grid | 3=hatch | 4=diamond | 5=dot |
3239 | @ using a fillpattern: multifill 0,1,2,5,3,4<br />meaning: first object is not filled...second object is solid color filled...2=grid | 3=hatch | 4=diamond | 5=dot |
3242 | @ use before command <a href='#multidraw'>multidraw</a> |
3240 | @ use before command <a href='#multidraw'>multidraw</a> |
3243 | @ if not set all objects -except point|points- will be set ''not filled``... unless a command <code>filled</code> was given before command <code>multifill</code> |
3241 | @ if not set all objects -except point|points- will be set ''not filled``... unless a command <code>filled</code> was given before command <code>multifill</code> |
3244 | @ only suitable for draw_primitives like ''circle | circles``, ''triangle | triangles``, ''rect | rects``, ''poly[3-9] | polys[3-9]`` and ''polygon`` |
3242 | @ only suitable for draw_primitives like ''circle | circles``, ''triangle | triangles``, ''rect | rects``, ''poly[3-9] | polys[3-9]`` and ''polygon`` |
3245 | @ wims will <b>not</b> check if the number of 0 or 1's matches the amount of draw primitives... |
3243 | @ wims will <b>not</b> check if the number of 0 or 1's matches the amount of draw primitives... |
3246 | @ always use the same sequence as is used for ''multidraw`` |
3244 | @ always use the same sequence as is used for ''multidraw`` |
3247 | */ |
3245 | */ |
3248 | if( use_tooltip == 1 ){canvas_error("command 'multidraw' is incompatible with command 'intooltip tip_text'");} |
3246 | if( use_tooltip == 1 ){canvas_error("command 'multidraw' is incompatible with command 'intooltip tip_text'");} |
3249 | i=0; |
3247 | i=0; |
3250 | while( ! done ){ /* get next item until EOL*/ |
3248 | while( ! done ){ /* get next item until EOL*/ |
Line 3400... | Line 3398... | ||
3400 | @ noyaxis |
3398 | @ noyaxis |
3401 | @ keyword |
3399 | @ keyword |
3402 | @ if set, the automatic y-axis numbering will be ignored |
3400 | @ if set, the automatic y-axis numbering will be ignored |
3403 | @ use command <a href="#axis">axis</a> to have a visual x/y-axis lines (see command <a href="#grid">grid</a>) |
3401 | @ use command <a href="#axis">axis</a> to have a visual x/y-axis lines (see command <a href="#grid">grid</a>) |
3404 | @ to be used before command grid (see <a href="#grid">command grid</a>) |
3402 | @ to be used before command grid (see <a href="#grid">command grid</a>) |
3405 | */ |
3403 | */ |
3406 | fprintf(js_include_file,"y_strings = {};\n"); |
3404 | fprintf(js_include_file,"y_strings = {};\n"); |
3407 | break; |
3405 | break; |
3408 | case NUMBERLINE: |
3406 | case NUMBERLINE: |
3409 | /* |
3407 | /* |
3410 | @ numberline x0,x1,xmajor,xminor,y0,y1 |
3408 | @ numberline x0,x1,xmajor,xminor,y0,y1 |
Line 3615... | Line 3613... | ||
3615 | @ default 150 |
3613 | @ default 150 |
3616 | @ only used for commands <a href="#curve">curve / plot</a> and <a href="#levelcurve">levelcurve</a> |
3614 | @ only used for commands <a href="#curve">curve / plot</a> and <a href="#levelcurve">levelcurve</a> |
3617 | @ use with care ! |
3615 | @ use with care ! |
3618 | */ |
3616 | */ |
3619 | plot_steps = (int) (get_real(infile,1)); |
3617 | plot_steps = (int) (get_real(infile,1)); |
3620 | break; |
3618 | break; |
3621 | 3619 | ||
3622 | case POINT: |
3620 | case POINT: |
3623 | /* |
3621 | /* |
3624 | @ point x,y,color |
3622 | @ point x,y,color |
3625 | @ draw a single point at (x;y) in color 'color' |
3623 | @ draw a single point at (x;y) in color 'color' |
3626 | @ use command <code>linewidth int</code> to adjust size |
3624 | @ use command <code>linewidth int</code> to adjust size |
3627 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> |
3625 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> |
3628 | @ will not resize on zooming (command <code>circle x,y,r,color</code> will resize on zooming) |
3626 | @ will not resize on zooming (command <code>circle x,y,r,color</code> will resize on zooming) |
3629 | @ attention: in case of command <a href="#rotate">rotate angle</a> a point has rotation center (0:0) in x/y-range |
3627 | @ attention: in case of command <a href="#rotate">rotate angle</a> a point has rotation center (0:0) in x/y-range |
3630 | @%point%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%linewidth 1%onclick%point 0,0,red%linewidth 2%onclick%point 1,1,blue%linewidth 3%onclick%point 3,3,green%linewidth 4%point 4,4,orange |
3628 | @%point%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%linewidth 1%onclick%point 0,0,red%linewidth 2%onclick%point 1,1,blue%linewidth 3%onclick%point 3,3,green%linewidth 4%point 4,4,orange |
3631 | */ |
3629 | */ |
3632 | for(i=0;i<3;i++){ |
3630 | for(i=0;i<3;i++){ |
3633 | switch(i){ |
3631 | switch(i){ |
3634 | case 0: double_data[0] = get_real(infile,0);break; /* x */ |
3632 | case 0: double_data[0] = get_real(infile,0);break; /* x */ |
3635 | case 1: double_data[1] = get_real(infile,0);break; /* y */ |
3633 | case 1: double_data[1] = get_real(infile,0);break; /* y */ |
3636 | case 2: stroke_color = get_color(infile,1);/* name or hex color */ |
3634 | case 2: stroke_color = get_color(infile,1);/* name or hex color */ |
Line 3661... | Line 3659... | ||
3661 | @ use command <code>linewidth int</code> to adjust size |
3659 | @ use command <code>linewidth int</code> to adjust size |
3662 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> individually (!) |
3660 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> individually (!) |
3663 | @ attention: in case of command <a href="#rotate">rotate angle</a> the points have rotation center (0:0) in x/y-range |
3661 | @ attention: in case of command <a href="#rotate">rotate angle</a> the points have rotation center (0:0) in x/y-range |
3664 | @%points_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%snaptogrid%linewidth 1%drag xy%points red,0,0,1,1,2,2,3,3%drag x%points blue,0,1,1,2,2,3,3,4 |
3662 | @%points_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%snaptogrid%linewidth 1%drag xy%points red,0,0,1,1,2,2,3,3%drag x%points blue,0,1,1,2,2,3,3,4 |
3665 | @%points_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%linewidth 1%onclick%points red,0,0,1,1,2,2,3,3%onclick%points blue,0,1,1,2,2,3,3,4 |
3663 | @%points_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%linewidth 1%onclick%points red,0,0,1,1,2,2,3,3%onclick%points blue,0,1,1,2,2,3,3,4 |
3666 | */ |
3664 | */ |
3667 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
3665 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
3668 | fill_color = stroke_color; |
3666 | fill_color = stroke_color; |
3669 | i=0; |
3667 | i=0; |
3670 | while( ! done ){ /* get next item until EOL*/ |
3668 | while( ! done ){ /* get next item until EOL*/ |
3671 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
3669 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
3672 | if(i%2 == 0 ){ |
3670 | if(i%2 == 0 ){ |
3673 | double_data[i] = get_real(infile,0); /* x */ |
3671 | double_data[i] = get_real(infile,0); /* x */ |
3674 | } |
3672 | } |
3675 | else |
3673 | else |
3676 | { |
3674 | { |
3677 | double_data[i] = get_real(infile,1); /* y */ |
3675 | double_data[i] = get_real(infile,1); /* y */ |
3678 | } |
3676 | } |
3679 | i++; |
3677 | i++; |
Line 3702... | Line 3700... | ||
3702 | @ draw closed polygon |
3700 | @ draw closed polygon |
3703 | @ use command ''fpoly`` to fill it or use keyword <a href='#filled'>filled</a> |
3701 | @ use command ''fpoly`` to fill it or use keyword <a href='#filled'>filled</a> |
3704 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> |
3702 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> |
3705 | @%polygon_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 2%drag xy%snaptogrid%poly blue,0,0,1,3,3,1,2,4,-1,3 |
3703 | @%polygon_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 2%drag xy%snaptogrid%poly blue,0,0,1,3,3,1,2,4,-1,3 |
3706 | @%polygon_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 1%onclick%poly green,0,0,1,3,3,1,2,4,-1,3 |
3704 | @%polygon_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 1%onclick%poly green,0,0,1,3,3,1,2,4,-1,3 |
3707 | */ |
3705 | */ |
3708 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
3706 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
3709 | i=0; |
3707 | i=0; |
3710 | c=0; |
3708 | c=0; |
3711 | while( ! done ){ /* get next item until EOL*/ |
3709 | while( ! done ){ /* get next item until EOL*/ |
3712 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
3710 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
3713 | for( c = 0 ; c < 2; c++){ |
3711 | for( c = 0 ; c < 2; c++){ |
3714 | if(c == 0 ){ |
3712 | if(c == 0 ){ |
3715 | double_data[i] = get_real(infile,0); |
3713 | double_data[i] = get_real(infile,0); |
3716 | i++; |
3714 | i++; |
3717 | } |
3715 | } |
3718 | else |
3716 | else |
3719 | { |
3717 | { |
3720 | double_data[i] = get_real(infile,1); |
3718 | double_data[i] = get_real(infile,1); |
3721 | i++; |
3719 | i++; |
3722 | } |
3720 | } |
3723 | } |
3721 | } |
3724 | } |
3722 | } |
3725 | if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);} |
3723 | if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);} |
3726 | if(use_affine == TRUE ){ transform(i-1,2);} |
3724 | if(use_affine == TRUE ){ transform(i-1,2);} |
3727 | if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */ |
3725 | if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */ |
3728 | 3726 | ||
3729 | /* draw path: closed & optional filled */ |
3727 | /* draw path: closed & optional filled */ |
3730 | decimals = find_number_of_digits(precision); |
3728 | decimals = find_number_of_digits(precision); |
3731 | string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,5,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
3729 | string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,5,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
3732 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
3730 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
3733 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,5,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
3731 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,5,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
Line 3777... | Line 3775... | ||
3777 | /* draw path: not closed & not filled */ |
3775 | /* draw path: not closed & not filled */ |
3778 | decimals = find_number_of_digits(precision); |
3776 | decimals = find_number_of_digits(precision); |
3779 | string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
3777 | string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
3780 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
3778 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
3781 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
3779 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,%s,[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset); |
3782 | add_to_buffer(tmp_buffer); |
3780 | add_to_buffer(tmp_buffer); |
3783 | if(onclick != 0){object_cnt++;} |
3781 | if(onclick != 0){object_cnt++;} |
3784 | /* object_cnt++;*/ |
3782 | /* object_cnt++;*/ |
3785 | reset(); |
3783 | reset(); |
3786 | dragstuff[4] = 1; |
3784 | dragstuff[4] = 1; |
3787 | if(use_dragstuff == 0 ){ use_dragstuff = 1; } |
3785 | if(use_dragstuff == 0 ){ use_dragstuff = 1; } |
Line 3885... | Line 3883... | ||
3885 | case PIXELSIZE: |
3883 | case PIXELSIZE: |
3886 | /* |
3884 | /* |
3887 | @ pixelsize int |
3885 | @ pixelsize int |
3888 | @ in case you want to deviate from default pixelsize = 1(...) |
3886 | @ in case you want to deviate from default pixelsize = 1(...) |
3889 | @ pixelsize 100 is of course a filled rectangle 100px × 100px |
3887 | @ pixelsize 100 is of course a filled rectangle 100px × 100px |
3890 | */ |
3888 | */ |
3891 | pixelsize = (int) get_real(infile,1); |
3889 | pixelsize = (int) get_real(infile,1); |
3892 | break; |
3890 | break; |
3893 | 3891 | ||
3894 | case PIECHART: |
3892 | case PIECHART: |
3895 | /* |
3893 | /* |
Line 4046... | Line 4044... | ||
4046 | 0,1 2,3 .....8,9 10,11..... |
4044 | 0,1 2,3 .....8,9 10,11..... |
4047 | 6,7 4,5 .....14,15 12,13..... |
4045 | 6,7 4,5 .....14,15 12,13..... |
4048 | x = [0,2,4,6,8,10,12,14...] |
4046 | x = [0,2,4,6,8,10,12,14...] |
4049 | y = [1,3,5,7,9,11,13,15...] |
4047 | y = [1,3,5,7,9,11,13,15...] |
4050 | */ |
4048 | */ |
4051 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
4049 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
4052 | fill_color = stroke_color; |
4050 | fill_color = stroke_color; |
4053 | i=0; |
4051 | i=0; |
4054 | while( ! done ){ /* get next item until EOL*/ |
4052 | while( ! done ){ /* get next item until EOL*/ |
4055 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
4053 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
4056 | if(i%2 == 0 ){ |
4054 | if(i%2 == 0 ){ |
Line 4143... | Line 4141... | ||
4143 | @%roundrects%size 400,400%xrange -10,10%yrange -10,10%roundrects blue,5,0,0,4,-4,5,4,1,2 |
4141 | @%roundrects%size 400,400%xrange -10,10%yrange -10,10%roundrects blue,5,0,0,4,-4,5,4,1,2 |
4144 | */ |
4142 | */ |
4145 | 4143 | ||
4146 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
4144 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
4147 | int_data[0] = (int) (get_real(infile,0)); /* radius value in pixels */ |
4145 | int_data[0] = (int) (get_real(infile,0)); /* radius value in pixels */ |
4148 | fill_color = stroke_color; |
4146 | fill_color = stroke_color; |
4149 | i=0; |
4147 | i=0; |
4150 | while( ! done ){ /* get next item until EOL*/ |
4148 | while( ! done ){ /* get next item until EOL*/ |
4151 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
4149 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
4152 | if(i%2 == 0 ){ |
4150 | if(i%2 == 0 ){ |
4153 | double_data[i] = get_real(infile,0); /* x */ |
4151 | double_data[i] = get_real(infile,0); /* x */ |
4154 | } |
4152 | } |
4155 | else |
4153 | else |
4156 | { |
4154 | { |
4157 | double_data[i] = get_real(infile,1); /* y */ |
4155 | double_data[i] = get_real(infile,1); /* y */ |
4158 | } |
4156 | } |
4159 | i++; |
4157 | i++; |
4160 | } |
4158 | } |
4161 | if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);} |
4159 | if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);} |
4162 | if(use_affine == TRUE ){ transform(i-1,2);} |
4160 | if(use_affine == TRUE ){ transform(i-1,2);} |
4163 | if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */ |
4161 | if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */ |
Line 4260... | Line 4258... | ||
4260 | } |
4258 | } |
4261 | string_length = 1 + snprintf(NULL,0,"[%f,%f ]",rotationcenter[0],rotationcenter[1]); |
4259 | string_length = 1 + snprintf(NULL,0,"[%f,%f ]",rotationcenter[0],rotationcenter[1]); |
4262 | check_string_length(string_length); |
4260 | check_string_length(string_length); |
4263 | rotation_center = my_newmem(string_length); |
4261 | rotation_center = my_newmem(string_length); |
4264 | snprintf(rotation_center,string_length,"[%f,%f]",rotationcenter[0],rotationcenter[1]); |
4262 | snprintf(rotation_center,string_length,"[%f,%f]",rotationcenter[0],rotationcenter[1]); |
4265 | } |
4263 | } |
4266 | break; |
4264 | break; |
4267 | 4265 | ||
4268 | case SIZE: |
4266 | case SIZE: |
4269 | /* |
4267 | /* |
4270 | @ size width,height |
4268 | @ size width,height |
Line 4475... | Line 4473... | ||
4475 | string_length = 1 + snprintf(NULL,0,"draw_setpixel([%f],[%f],\"%s\",%.2f,%d);\n",double_data[0],double_data[1],stroke_color,stroke_opacity,pixelsize); |
4473 | string_length = 1 + snprintf(NULL,0,"draw_setpixel([%f],[%f],\"%s\",%.2f,%d);\n",double_data[0],double_data[1],stroke_color,stroke_opacity,pixelsize); |
4476 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
4474 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
4477 | snprintf(tmp_buffer,string_length,"draw_setpixel([%f],[%f],\"%s\",%.2f,%d);\n",double_data[0],double_data[1],stroke_color,stroke_opacity,pixelsize); |
4475 | snprintf(tmp_buffer,string_length,"draw_setpixel([%f],[%f],\"%s\",%.2f,%d);\n",double_data[0],double_data[1],stroke_color,stroke_opacity,pixelsize); |
4478 | add_to_buffer(tmp_buffer); |
4476 | add_to_buffer(tmp_buffer); |
4479 | break; |
4477 | break; |
4480 | default:break; |
4478 | default:break; |
4481 | } |
4479 | } |
4482 | } |
4480 | } |
4483 | reset(); |
4481 | reset(); |
4484 | break; |
4482 | break; |
4485 | case SLIDER: |
4483 | case SLIDER: |
4486 | /* |
4484 | /* |
4487 | @ slider start_value,end_value,width px,height px,type,label |
4485 | @ slider start_value,end_value,width px,height px,type,label |
Line 4585... | Line 4583... | ||
4585 | # default value "y" |
4583 | # default value "y" |
4586 | # the y-value of the slider object(s) will be calculated with this function. |
4584 | # the y-value of the slider object(s) will be calculated with this function. |
4587 | # only used by command ''slider`` |
4585 | # only used by command ''slider`` |
4588 | # define before a slider command ! |
4586 | # define before a slider command ! |
4589 | */ |
4587 | */ |
4590 | break; |
4588 | break; |
4591 | case SGRAPH: |
4589 | case SGRAPH: |
4592 | /* |
4590 | /* |
4593 | @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color |
4591 | @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color |
4594 | @ primitive implementation of a ''broken scale`` graph... |
4592 | @ primitive implementation of a ''broken scale`` graph... |
4595 | @ not very versatile: only usable in combination with userdraw <br />eg no other objects will obey this "coordinate system"<br />if you want to place an object into this coordinate system, be aware that 10% or 20% of xsize and/or ysize is ''lost``.<br />Use these "formulas" to recalculate the virtual coordinates:<br />factor=0.8 in case xstart != xmin (or ystart != ymin)<br />factor=0.9 in case xstart = xmin (or ystart = ymin)<br />px_x_point = ((factor*xsize)/(xmax - xstart))*(x_point - xmax)+xsize<br />x_recalculated = px*(xmax - xmin)/xsize + $xmin<br />px_y_point = -1*factor*y_point*ysize/(ymax - ystart) + ymax*factor*ysize/(ymax - ystart)<br />y_recalculated = ymax - py*(ymax - ymin)/ysize<br /> |
4593 | @ not very versatile: only usable in combination with userdraw <br />eg no other objects will obey this "coordinate system"<br />if you want to place an object into this coordinate system, be aware that 10% or 20% of xsize and/or ysize is ''lost``.<br />Use these "formulas" to recalculate the virtual coordinates:<br />factor=0.8 in case xstart != xmin (or ystart != ymin)<br />factor=0.9 in case xstart = xmin (or ystart = ymin)<br />px_x_point = ((factor*xsize)/(xmax - xstart))*(x_point - xmax)+xsize<br />x_recalculated = px*(xmax - xmin)/xsize + $xmin<br />px_y_point = -1*factor*y_point*ysize/(ymax - ystart) + ymax*factor*ysize/(ymax - ystart)<br />y_recalculated = ymax - py*(ymax - ymin)/ysize<br /> |
Line 4742... | Line 4740... | ||
4742 | case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/ |
4740 | case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/ |
4743 | case 2: double_data[1] = get_real(infile,0);break; /* y in yrange*/ |
4741 | case 2: double_data[1] = get_real(infile,0);break; /* y in yrange*/ |
4744 | case 3: decimals = find_number_of_digits(precision); |
4742 | case 3: decimals = find_number_of_digits(precision); |
4745 | if(use_affine == TRUE ){ transform(2,2);} |
4743 | if(use_affine == TRUE ){ transform(2,2);} |
4746 | /* rotate is done by HTML5/CANVAS context rotation */ |
4744 | /* rotate is done by HTML5/CANVAS context rotation */ |
4747 | temp = get_string_argument(infile,1); |
4745 | temp = get_string_argument(infile,1); |
4748 | if(strstr(temp,"_") != NULL || strstr(temp,"^") != NULL){js_function[DRAW_SUBSUP] = 1;} |
4746 | if(strstr(temp,"_") != NULL || strstr(temp,"^") != NULL){js_function[DRAW_SUBSUP] = 1;} |
4749 | decimals = find_number_of_digits(precision); |
4747 | decimals = find_number_of_digits(precision); |
4750 | if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */ |
4748 | if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */ |
4751 | string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,14,[%.*f],[%.*f],[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,use_rotate,angle,temp,font_size,font_family,my_sliders,rotation_center,use_offset); |
4749 | string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,14,[%.*f],[%.*f],[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,use_rotate,angle,temp,font_size,font_family,my_sliders,rotation_center,use_offset); |
4752 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
4750 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
4753 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,14,[%.*f],[%.*f],[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,use_rotate,angle,temp,font_size,font_family,my_sliders,rotation_center,use_offset); |
4751 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,14,[%.*f],[%.*f],[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,use_rotate,angle,temp,font_size,font_family,my_sliders,rotation_center,use_offset); |
4754 | add_to_buffer(tmp_buffer); |
4752 | add_to_buffer(tmp_buffer); |
4755 | if(onclick != 0){object_cnt++;} |
4753 | if(onclick != 0){object_cnt++;} |
4756 | //onclick = 0; |
4754 | //onclick = 0; |
4757 | //use_offset = 0; |
4755 | //use_offset = 0; |
Line 4798... | Line 4796... | ||
4798 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,14,[%.*f],[%.*f],[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,use_rotate,angle,temp,font_size,font_family,my_sliders,rotation_center,use_offset); |
4796 | snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,14,[%.*f],[%.*f],[0],[0],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,use_rotate,angle,temp,font_size,font_family,my_sliders,rotation_center,use_offset); |
4799 | add_to_buffer(tmp_buffer); |
4797 | add_to_buffer(tmp_buffer); |
4800 | if(onclick != 0){object_cnt++;} |
4798 | if(onclick != 0){object_cnt++;} |
4801 | //onclick = 0; |
4799 | //onclick = 0; |
4802 | //use_offset = 0; |
4800 | //use_offset = 0; |
4803 | reset(); |
4801 | reset(); |
4804 | break; |
4802 | break; |
4805 | default:break; |
4803 | default:break; |
4806 | } |
4804 | } |
4807 | } |
4805 | } |
4808 | use_rotate = FALSE; |
4806 | use_rotate = FALSE; |
4809 | break; |
4807 | break; |
4810 | 4808 | ||
4811 | case STYLE: |
4809 | case STYLE: |
Line 4855... | Line 4853... | ||
4855 | } |
4853 | } |
4856 | else |
4854 | else |
4857 | { |
4855 | { |
4858 | if(strcmp(fly_font,"large") == 0){ |
4856 | if(strcmp(fly_font,"large") == 0){ |
4859 | fly_font_size = (int)(font_size + 6); |
4857 | fly_font_size = (int)(font_size + 6); |
4860 | } |
4858 | } |
4861 | else |
4859 | else |
4862 | { |
4860 | { |
4863 | if(strcmp(fly_font,"small") == 0){ |
4861 | if(strcmp(fly_font,"small") == 0){ |
4864 | fly_font_size = (int)(font_size - 4); |
4862 | fly_font_size = (int)(font_size - 4); |
4865 | if(fly_font_size<0){fly_font_size = 8;} |
4863 | if(fly_font_size<0){fly_font_size = 8;} |
Line 4908... | Line 4906... | ||
4908 | string_length = 1 + snprintf(NULL,0, "draw_textareas(%d,%d,%d,%d,%d,%d,%d,\"%s\",\"%s\");\n",canvas_root_id,input_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],css_class,temp); |
4906 | string_length = 1 + snprintf(NULL,0, "draw_textareas(%d,%d,%d,%d,%d,%d,%d,\"%s\",\"%s\");\n",canvas_root_id,input_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],css_class,temp); |
4909 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
4907 | check_string_length(string_length);tmp_buffer = my_newmem(string_length); |
4910 | snprintf(tmp_buffer,string_length,"draw_textareas(%d,%d,%d,%d,%d,%d,%d,\"%s\",\"%s\");\n",canvas_root_id,input_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],css_class,temp); |
4908 | snprintf(tmp_buffer,string_length,"draw_textareas(%d,%d,%d,%d,%d,%d,%d,\"%s\",\"%s\");\n",canvas_root_id,input_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],css_class,temp); |
4911 | add_to_buffer(tmp_buffer); |
4909 | add_to_buffer(tmp_buffer); |
4912 | input_cnt++;break; |
4910 | input_cnt++;break; |
4913 | default: break; |
4911 | default: break; |
4914 | } |
4912 | } |
4915 | } |
4913 | } |
4916 | if(reply_format == 0 ){reply_format = 15;} |
4914 | if(reply_format == 0 ){reply_format = 15;} |
4917 | reset(); |
4915 | reset(); |
4918 | break; |
4916 | break; |
Line 6633... | Line 6631... | ||
6633 | i = i/10; |
6631 | i = i/10; |
6634 | } |
6632 | } |
6635 | return digits; |
6633 | return digits; |
6636 | } |
6634 | } |
6637 | 6635 | ||
- | 6636 | int count_substring(char* string, char* substring) { |
|
- | 6637 | int i, j, l1, l2; |
|
- | 6638 | int count = 0; |
|
- | 6639 | l1 = strlen(string); |
|
- | 6640 | l2 = strlen(substring); |
|
- | 6641 | for(i = 0; i < l1 - l2 + 1; i++) { |
|
- | 6642 | if(strstr(string + i, substring) == string + i) { |
|
- | 6643 | count++; |
|
- | 6644 | i = i + l2 -1; |
|
- | 6645 | } |
|
- | 6646 | } |
|
- | 6647 | return count; |
|
- | 6648 | } |
|
6638 | 6649 | ||
6639 | 6650 | ||
6640 | 6651 | ||
6641 | void check_string_length(int L){ |
6652 | void check_string_length(int L){ |
6642 | if( L > MAX_BUFFER-1){ |
6653 | if( L > MAX_BUFFER-1){ |