Subversion Repositories wimsdev

Rev

Rev 7839 | Rev 7848 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7839 Rev 7842
Line 14... Line 14...
14
#include <errno.h>
14
#include <errno.h>
15
#include <string.h>
15
#include <string.h>
16
#include <unistd.h>
16
#include <unistd.h>
17
#include <time.h> /* use for random id's */
17
#include <time.h> /* use for random id's */
18
#include <math.h>
18
#include <math.h>
19
/*
19
/*
20
#include <ctype.h>
20
#include <ctype.h>
21
11/2013
21
11/2013
22
removed: FreeBSD 9.0 / 9.1 C-lib bug...in chroot it will result in: Undefined symbol "_ThreadRuneLocale" implemented own versions of tolower() / toupper()
22
removed: FreeBSD 9.0 / 9.1 C-lib bug...in chroot it will result in: Undefined symbol "_ThreadRuneLocale" implemented own versions of tolower() / toupper()
23
Clang is fine (FreeBSD 10.0)
23
Clang is fine (FreeBSD 10.0)
24
*/
24
*/
25
 
25
 
26
/*
26
/*
27
in case svgdraw is in ~/src/Misc/svgdraw
27
in case svgdraw is in ~/src/Misc/svgdraw
28
#include "../svgdraw/include/matheval.h"
28
#include "../svgdraw/include/matheval.h"
29
*/
29
*/
30
#include "include/matheval.h"
30
#include "include/matheval.h"
31
#include <assert.h> 
31
#include <assert.h>
32
#include "canvasdraw.h"
32
#include "canvasdraw.h"
33
#include<sys/stat.h>
33
#include<sys/stat.h>
34
 
34
 
35
/* needed for gettimeofday */
35
/* needed for gettimeofday */
36
#include <sys/time.h>
36
#include <sys/time.h>
Line 55... Line 55...
55
char    *get_string_argument(FILE *infile,int last); /* the same, but with "comma" as  separator */
55
char    *get_string_argument(FILE *infile,int last); /* the same, but with "comma" as  separator */
56
char    *convert_hex2rgb(char *hexcolor);
56
char    *convert_hex2rgb(char *hexcolor);
57
void    add_read_canvas(int reply_format);
57
void    add_read_canvas(int reply_format);
58
void    make_js_include(int canvas_root_id);
58
void    make_js_include(int canvas_root_id);
59
void    check_string_length(int length);/* checks if the length of string argument of command is correct */
59
void    check_string_length(int length);/* checks if the length of string argument of command is correct */
60
FILE    *js_include_file;
60
FILE    *js_include_file;
61
FILE    *get_file(int *line_number, char **filename);
61
FILE    *get_file(int *line_number, char **filename);
62
FILE    *infile;    /* will be stdin */
62
FILE    *infile;    /* will be stdin */
63
/******************************************************************************
63
/******************************************************************************
64
** global
64
** global
65
******************************************************************************/
65
******************************************************************************/
Line 73... Line 73...
73
double ymin = 0.0;
73
double ymin = 0.0;
74
double ymax = 320.0;
74
double ymax = 320.0;
75
double tmax = 2;
75
double tmax = 2;
76
double tmin = -2;
76
double tmin = -2;
77
/* flag to indicate parsing of line status */
77
/* flag to indicate parsing of line status */
78
int done = FALSE;
78
int done = FALSE;
79
int type; /* eg command number */
79
int type; /* eg command number */
80
int onclick = 0;/* 0 = noninteractive ; 1 = onclick ; 2 = draggable*/
80
int onclick = 0;/* 0 = noninteractive ; 1 = onclick ; 2 = draggable*/
81
int use_affine = FALSE;
81
int use_affine = FALSE;
82
int use_rotate = FALSE;
82
int use_rotate = FALSE;
83
int use_translate = FALSE;
83
int use_translate = FALSE;
Line 126... Line 126...
126
    int dashtype[2] = { 2 , 2 };
126
    int dashtype[2] = { 2 , 2 };
127
    int js_function[MAX_JS_FUNCTIONS]; /* javascript functions include objects on demand basis : only once per object type */
127
    int js_function[MAX_JS_FUNCTIONS]; /* javascript functions include objects on demand basis : only once per object type */
128
    for(i=0;i<MAX_JS_FUNCTIONS;i++){js_function[i]=0;}
128
    for(i=0;i<MAX_JS_FUNCTIONS;i++){js_function[i]=0;}
129
    int arrow_head = 8; /* size in px*/
129
    int arrow_head = 8; /* size in px*/
130
    int crosshair_size = 5; /* size in px*/
130
    int crosshair_size = 5; /* size in px*/
131
    int plot_steps = 250;
131
    int plot_steps = 250;
132
    int found_size_command = 0;
132
    int found_size_command = 0;
133
    int click_cnt = 1;
133
    int click_cnt = 1;
134
    int clock_cnt = 0; /* counts the amount of clocks used -> unique object clock%d */
134
    int clock_cnt = 0; /* counts the amount of clocks used -> unique object clock%d */
135
    int linegraph_cnt = 0; /* identifier for command 'linegraph' ; multiple line graphs may be plotted in a single plot*/
135
    int linegraph_cnt = 0; /* identifier for command 'linegraph' ; multiple line graphs may be plotted in a single plot*/
136
    double angle = 0.0;
136
    double angle = 0.0;
Line 143... Line 143...
143
    double stroke_opacity = 0.8;
143
    double stroke_opacity = 0.8;
144
    double fill_opacity = 0.8;
144
    double fill_opacity = 0.8;
145
    char *URL = "http://localhost/images";
145
    char *URL = "http://localhost/images";
146
    memset(buffer,'\0',MAX_BUFFER);
146
    memset(buffer,'\0',MAX_BUFFER);
147
    void *tmp_buffer = "";
147
    void *tmp_buffer = "";
148
   
148
 
149
    /* default writing a unzipped js-include file into wims getfile directory */
149
    /* default writing a unzipped js-include file into wims getfile directory */
150
    char *w_wims_session = getenv("w_wims_session");
150
    char *w_wims_session = getenv("w_wims_session");
151
    if(  w_wims_session == NULL || *w_wims_session == 0 ){
151
    if(  w_wims_session == NULL || *w_wims_session == 0 ){
152
        canvas_error("Hmmm, your wims environment does not exist...\nCanvasdraw should be used within wims.");
152
        canvas_error("Hmmm, your wims environment does not exist...\nCanvasdraw should be used within wims.");
153
    }
153
    }
154
    int L0=strlen(w_wims_session) + 21;
154
    int L0=strlen(w_wims_session) + 21;
155
    char *getfile_dir = my_newmem(L0); /* create memory to fit string precisely */
155
    char *getfile_dir = my_newmem(L0); /* create memory to fit string precisely */
156
    snprintf(getfile_dir,L0, "../sessions/%s/getfile",w_wims_session);/* string will fit precisely  */
156
    snprintf(getfile_dir,L0, "../sessions/%s/getfile",w_wims_session);/* string will fit precisely  */
157
    mode_t process_mask = umask(0); /* check if file exists */
157
    mode_t process_mask = umask(0); /* check if file exists */
158
    int result = mkdir(getfile_dir, S_IRWXU | S_IRWXG | S_IRWXO);
158
    int result = mkdir(getfile_dir, S_IRWXU | S_IRWXG | S_IRWXO);
159
    if( result == 0 || errno == EEXIST ){
159
    if( result == 0 || errno == EEXIST ){
160
     umask(process_mask); /* be sure to set correct permission */
160
     umask(process_mask); /* be sure to set correct permission */
161
     char *w_session = getenv("w_session");
161
     char *w_session = getenv("w_session");
162
     int L1 = (int) (strlen(w_session)) + find_number_of_digits(canvas_root_id) + 48;
162
     int L1 = (int) (strlen(w_session)) + find_number_of_digits(canvas_root_id) + 48;
163
    char *getfile_cmd = my_newmem(L1); /* create memory to fit string precisely */
163
    char *getfile_cmd = my_newmem(L1); /* create memory to fit string precisely */
164
     snprintf(getfile_cmd,L1,"wims.cgi?session=%s&cmd=getfile&special_parm=%d.js",w_session,canvas_root_id);/* extension ".gz" is MANDATORY for webserver */   
164
     snprintf(getfile_cmd,L1,"wims.cgi?session=%s&cmd=getfile&special_parm=%d.js",w_session,canvas_root_id);/* extension ".gz" is MANDATORY for webserver */
165
    /* write the include tag to html page:<script type="text/javascript" src="wims.cgi?session=%s&cmd=getfile&special_parm=11223344_js"></script> */
165
    /* write the include tag to html page:<script type="text/javascript" src="wims.cgi?session=%s&cmd=getfile&special_parm=11223344_js"></script> */
166
    /* now write file into getfile dir*/
166
    /* now write file into getfile dir*/
167
    char *w_wims_home = getenv("w_wims_home"); /* "/home/users/wims" : we need absolute path for location */
167
    char *w_wims_home = getenv("w_wims_home"); /* "/home/users/wims" : we need absolute path for location */
168
    int L2 = (int) (strlen(w_wims_home)) + (int) (strlen(w_wims_session)) + find_number_of_digits(canvas_root_id) + 23;
168
    int L2 = (int) (strlen(w_wims_home)) + (int) (strlen(w_wims_session)) + find_number_of_digits(canvas_root_id) + 23;
169
    char *location = my_newmem(L2); /* create memory to fit string precisely */
169
    char *location = my_newmem(L2); /* create memory to fit string precisely */
Line 179... Line 179...
179
        if(line_number>1 && found_size_command == FALSE){canvas_error("command \"size xsize,ysize\" needs to come first ! ");}
179
        if(line_number>1 && found_size_command == FALSE){canvas_error("command \"size xsize,ysize\" needs to come first ! ");}
180
        type = get_token(infile);
180
        type = get_token(infile);
181
        done = FALSE;
181
        done = FALSE;
182
        /*
182
        /*
183
        @canvasdraw
183
        @canvasdraw
184
        @will try use the same syntax as flydraw or svgdraw to paint a html5 bitmap image<br />by generating a tailor-made javascript include file: providing only the js-functionality needed to perform the job.<br />thus ensuring a minimal strain on the client browser <br />(unlike some popular 'canvas-do-it-all' libraries, who have proven to be not suitable for low-end computers found in schools...)
184
        @will try use the same syntax as flydraw or svgdraw to paint a html5 bitmap image<br />by generating a tailor-made javascript include file: providing only the js-functionality needed to perform the job.<br />thus ensuring a minimal strain on the client browser <br />(unlike some popular 'canvas-do-it-all' libraries, who have proven to be not suitable for low-end computers found in schools...)
185
        @General syntax <ul><li>The transparency of all objects can be controlled by command 'opacity [0-255],[0,255]'</il><li>a line based object can be controlled by command 'linewidth int'</li><li>a line based object may be dashed by using keyword 'dashed' before the object command.<br />the dashing type can be controled by command 'dashtype int,int'</li><li>a fillable object can be set fillable by starting the object command with an 'f'<br />(like frect,fcircle,ftriangle...)<br />or by using the keyword 'filled' before the object command.<br />The fill colour will be the stroke colour...(19/10/2013)<li> a draggable object can be set draggable by a preceding command 'drag x/y/xy'<br />The translation can be read by javascript:read_dragdrop();<br />Multiple objects may be set draggable / clickable (no limit)<br /> not all flydraw objects may be dragged / clicked<br />Only draggable / clickable objects will be scaled on zoom and will be translated in case of panning</li><li> a 'onclick object' can be set 'clickable' by the preceding keyword 'onclick'<br />not all flydraw objects can be set clickable</li><li><b>remarks using a ';' as command separator</b><br />commands with only numeric or colour arguments may be using a ';' as command separator (in stead of a new line)<br />commands with a string argument may not use a ';' as command separator !<br />these exceptions are not really straight forward... so keep this in mind.<br />example:<br />size 200,200;xrange -5,5;yrange -5,5;hline 0,0,black;vline 0,0,black<br />plot red,sin(x)<br />drag xy<br />html 0,0,5,-5, &amp;euro; <br />lines green,2,0,2,-2,-2,2,-2,0;rectangle 1,1,4,4,purple;frectangle -1,-1,-4,-4,yellow</li></ul>
185
        @General syntax <ul><li>The transparency of all objects can be controlled by command 'opacity [0-255],[0,255]'</il><li>a line based object can be controlled by command 'linewidth int'</li><li>a line based object may be dashed by using keyword 'dashed' before the object command.<br />the dashing type can be controled by command 'dashtype int,int'</li><li>a fillable object can be set fillable by starting the object command with an 'f'<br />(like frect,fcircle,ftriangle...)<br />or by using the keyword 'filled' before the object command.<br />The fill colour will be the stroke colour...(19/10/2013)<li> a draggable object can be set draggable by a preceding command 'drag x/y/xy'<br />The translation can be read by javascript:read_dragdrop();<br />Multiple objects may be set draggable / clickable (no limit)<br /> not all flydraw objects may be dragged / clicked<br />Only draggable / clickable objects will be scaled on zoom and will be translated in case of panning</li><li> a 'onclick object' can be set 'clickable' by the preceding keyword 'onclick'<br />not all flydraw objects can be set clickable</li><li><b>remarks using a ';' as command separator</b><br />commands with only numeric or colour arguments may be using a ';' as command separator (in stead of a new line)<br />commands with a string argument may not use a ';' as command separator !<br />these exceptions are not really straight forward... so keep this in mind.<br />example:<br />size 200,200;xrange -5,5;yrange -5,5;hline 0,0,black;vline 0,0,black<br />plot red,sin(x)<br />drag xy<br />html 0,0,5,-5, &amp;euro; <br />lines green,2,0,2,-2,-2,2,-2,0;rectangle 1,1,4,4,purple;frectangle -1,-1,-4,-4,yellow</li></ul>
186
        */
186
        */
187
        switch(type){
187
        switch(type){
188
        case END:
188
        case END:
189
        finished = 1;
189
        finished = 1;
Line 210... Line 210...
210
            ysize = (int)(abs(round(get_real(infile,1))));
210
            ysize = (int)(abs(round(get_real(infile,1))));
211
            /* sometimes we want xrange / yrange to be in pixels...without telling x/y-range */
211
            /* sometimes we want xrange / yrange to be in pixels...without telling x/y-range */
212
            xmin = 0;xmax = xsize;
212
            xmin = 0;xmax = xsize;
213
            ymin = 0;ymax = ysize;
213
            ymin = 0;ymax = ysize;
214
 
214
 
215
/*
215
/*
216
 The sequence in which stuff is finally printed is important !!
216
 The sequence in which stuff is finally printed is important !!
217
 for example, when writing a 'include.js" the may not be a "script tag <script>" etc etc
217
 for example, when writing a 'include.js" the may not be a "script tag <script>" etc etc
218
*/
218
*/
219
fprintf(stdout,"\n<script type=\"text/javascript\">var wims_status = \"$status\";</script>\n<!-- canvasdraw div and tooltip placeholder, if needed -->\n<div tabindex=\"0\" id=\"canvas_div%d\" style=\"position:relative;width:%dpx;height:%dpx;\" ></div><div id=\"tooltip_placeholder_div%d\" style=\"display:block\"><span id=\"tooltip_placeholder%d\" style=\"display:none\"></span></div>\n",canvas_root_id,xsize,ysize,canvas_root_id,canvas_root_id);
219
fprintf(stdout,"\n<script type=\"text/javascript\">var wims_status = \"$status\";</script>\n<!-- canvasdraw div and tooltip placeholder, if needed -->\n<div tabindex=\"0\" id=\"canvas_div%d\" style=\"position:relative;width:%dpx;height:%dpx;\" ></div><div id=\"tooltip_placeholder_div%d\" style=\"display:block\"><span id=\"tooltip_placeholder%d\" style=\"display:none\"></span></div>\n",canvas_root_id,xsize,ysize,canvas_root_id,canvas_root_id);
220
fprintf(js_include_file,"\n<!-- begin generated javascript include for canvasdraw -->\n");
220
fprintf(js_include_file,"\n<!-- begin generated javascript include for canvasdraw -->\n");
Line 250... Line 250...
250
add_drag_code(js_include_file,DRAG_CANVAS,canvas_root_id);
250
add_drag_code(js_include_file,DRAG_CANVAS,canvas_root_id);
251
            break;
251
            break;
252
        case XRANGE:
252
        case XRANGE:
253
        /*
253
        /*
254
        @ xrange xmin,xmax
254
        @ xrange xmin,xmax
255
        @ if not given: 0,xsize (eg in pixels)
255
        @ if not given: 0,xsize (eg in pixels)
256
        */
256
        */
257
            for(i = 0 ; i<2; i++){
257
            for(i = 0 ; i<2; i++){
258
                switch(i){
258
                switch(i){
259
                    case 0: xmin = get_real(infile,0);break;
259
                    case 0: xmin = get_real(infile,0);break;
260
                    case 1: xmax = get_real(infile,1);break;
260
                    case 1: xmax = get_real(infile,1);break;
Line 314... Line 314...
314
        @ default 10 (px)
314
        @ default 10 (px)
315
        */
315
        */
316
            crosshair_size = (int) (get_real(infile,1));
316
            crosshair_size = (int) (get_real(infile,1));
317
            break;
317
            break;
318
        case CROSSHAIR:
318
        case CROSSHAIR:
319
        /*
319
        /*
320
        @ crosshair x,y,color
320
        @ crosshair x,y,color
321
        @ draw a single crosshair point at (x;y) in color 'color'
321
        @ draw a single crosshair point at (x;y) in color 'color'
322
        @ use command 'crosshairsize int' and / or 'linewidth int'  to adust
322
        @ use command 'crosshairsize int' and / or 'linewidth int'  to adust
323
        @ may be set draggable / onclick
323
        @ may be set draggable / onclick
324
        */
324
        */
Line 338... Line 338...
338
        case CROSSHAIRS:
338
        case CROSSHAIRS:
339
        /*
339
        /*
340
        @ crosshairs color,x1,y1,x2,y2,...,x_n,y_n
340
        @ crosshairs color,x1,y1,x2,y2,...,x_n,y_n
341
        @ draw multiple crosshair points at given coordinates in color 'color'
341
        @ draw multiple crosshair points at given coordinates in color 'color'
342
        @ use command 'crosshairsize int' and / or 'linewidth int'  to adust
342
        @ use command 'crosshairsize int' and / or 'linewidth int'  to adust
343
        @ may be set draggable / onclick individually (!)
343
        @ may be set draggable / onclick individually (!)
344
        */
344
        */
345
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
345
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
346
            fill_color = stroke_color;
346
            fill_color = stroke_color;
347
            i=0;
347
            i=0;
348
            while( ! done ){     /* get next item until EOL*/
348
            while( ! done ){     /* get next item until EOL*/
349
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
349
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
350
                if(i%2 == 0 ){
350
                if(i%2 == 0 ){
351
                    double_data[i] = get_real(infile,0); /* x */
351
                    double_data[i] = get_real(infile,0); /* x */
352
                }
352
                }
353
                else
353
                else
354
                {
354
                {
355
                    double_data[i] = get_real(infile,1); /* y */
355
                    double_data[i] = get_real(infile,1); /* y */
356
                }
356
                }
357
                i++;
357
                i++;
358
            }
358
            }
359
            decimals = find_number_of_digits(precision);
359
            decimals = find_number_of_digits(precision);
360
            for(c=0 ; c < i-1 ; c = c+2){
360
            for(c=0 ; c < i-1 ; c = c+2){
361
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,7,[%.*f],[%.*f],[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+1],crosshair_size,crosshair_size,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,1,0,0,0,use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
361
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,7,[%.*f],[%.*f],[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+1],crosshair_size,crosshair_size,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,1,0,0,0,use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
362
                click_cnt++;
362
                click_cnt++;
363
            }
363
            }
364
            reset();
364
            reset();
365
            break;
365
            break;
366
        case POINT:
366
        case POINT:
367
        /*
367
        /*
368
        @ point x,y,color
368
        @ point x,y,color
369
        @ draw a single point at (x;y) in color 'color'
369
        @ draw a single point at (x;y) in color 'color'
370
        @ use command 'linewidth int'  to adust size
370
        @ use command 'linewidth int'  to adust size
371
        @ may be set draggable / onclick
371
        @ may be set draggable / onclick
372
        @ will not resize on zooming <br />(command 'circle x,y,r,color' will resize on zooming)
372
        @ will not resize on zooming <br />(command 'circle x,y,r,color' will resize on zooming)
373
        */
373
        */
374
            for(i=0;i<3;i++){
374
            for(i=0;i<3;i++){
375
                switch(i){
375
                switch(i){
376
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
376
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
377
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
377
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
Line 403... Line 403...
403
                {
403
                {
404
                    double_data[i] = get_real(infile,1); /* y */
404
                    double_data[i] = get_real(infile,1); /* y */
405
                }
405
                }
406
                i++;
406
                i++;
407
            }
407
            }
408
            decimals = find_number_of_digits(precision);           
408
            decimals = find_number_of_digits(precision);
409
            for(c = 0 ; c < i-1 ; c = c+2){
409
            for(c = 0 ; c < i-1 ; c = c+2){
410
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,2,[%.*f],[%.*f],[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+1],line_width,line_width,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,1,0,0,0,use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
410
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,2,[%.*f],[%.*f],[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+1],line_width,line_width,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,1,0,0,0,use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
411
                click_cnt++;
411
                click_cnt++;
412
            }
412
            }
413
            reset();
413
            reset();
Line 465... Line 465...
465
                        {
465
                        {
466
                        /* m */
466
                        /* m */
467
                        double_data[5] = (double_data[13] - double_data[11]) /(double_data[12] - double_data[10]);
467
                        double_data[5] = (double_data[13] - double_data[11]) /(double_data[12] - double_data[10]);
468
                        /* q */
468
                        /* q */
469
                        double_data[6] = double_data[11] - ((double_data[13] - double_data[11]) /(double_data[12] - double_data[10]))*double_data[10];
469
                        double_data[6] = double_data[11] - ((double_data[13] - double_data[11]) /(double_data[12] - double_data[10]))*double_data[10];
470
                       
470
 
471
                        /*xmin,m*xmin+q,xmax,m*xmax+q*/
471
                        /*xmin,m*xmin+q,xmax,m*xmax+q*/
472
                       
472
 
473
                            double_data[1] = (double_data[5])*(xmin)+(double_data[6]);
473
                            double_data[1] = (double_data[5])*(xmin)+(double_data[6]);
474
                            double_data[3] = (double_data[5])*(xmax)+(double_data[6]);
474
                            double_data[3] = (double_data[5])*(xmax)+(double_data[6]);
475
                            double_data[0] = xmin;
475
                            double_data[0] = xmin;
476
                            double_data[2] = xmax;
476
                            double_data[2] = xmax;
477
                        }
477
                        }
Line 481... Line 481...
481
                    click_cnt++;reset();
481
                    click_cnt++;reset();
482
                    break;
482
                    break;
483
                }
483
                }
484
            }
484
            }
485
            break;
485
            break;
486
        case HLINE:
486
        case HLINE:
487
        /*
487
        /*
488
        @ hline x,y,color
488
        @ hline x,y,color
489
        @ draw a horizontal line through point (x:y) in color 'color'
489
        @ draw a horizontal line through point (x:y) in color 'color'
490
        @ or use command 'curve color,formula' to draw the line <br />(uses more points to draw the line; is however better draggable)
490
        @ or use command 'curve color,formula' to draw the line <br />(uses more points to draw the line; is however better draggable)
491
        @ may be set draggable / onclick
491
        @ may be set draggable / onclick
Line 592... Line 592...
592
            }
592
            }
593
            break;
593
            break;
594
        case POLYLINE:
594
        case POLYLINE:
595
        /*
595
        /*
596
        @ polyline color,x1,y1,x2,y2...x_n,y_n
596
        @ polyline color,x1,y1,x2,y2...x_n,y_n
597
        @ may be set draggable / onclick
597
        @ may be set draggable / onclick
598
        */
598
        */
599
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
599
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
600
            i=0;
600
            i=0;
601
            c=0;
601
            c=0;
602
            while( ! done ){     /* get next item until EOL*/
602
            while( ! done ){     /* get next item until EOL*/
603
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
603
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
604
                for( c = 0 ; c < 2; c++){
604
                for( c = 0 ; c < 2; c++){
605
                    if(c == 0 ){
605
                    if(c == 0 ){
606
                        double_data[i] = get_real(infile,0);
606
                        double_data[i] = get_real(infile,0);
607
                        i++;
607
                        i++;
608
                    }
608
                    }
609
                    else
609
                    else
610
                    {
610
                    {
611
                        double_data[i] = get_real(infile,1);
611
                        double_data[i] = get_real(infile,1);
612
                        i++;
612
                        i++;
613
                    }
613
                    }
614
                }
614
                }
615
            }
615
            }
616
            /* draw path : not closed & not filled */
616
            /* draw path : not closed & not filled */
617
            decimals = find_number_of_digits(precision);
617
            decimals = find_number_of_digits(precision);
Line 631... Line 631...
631
            while( ! done ){     /* get next item until EOL*/
631
            while( ! done ){     /* get next item until EOL*/
632
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
632
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
633
                for( c = 0 ; c < 2; c++){
633
                for( c = 0 ; c < 2; c++){
634
                    if(c == 0 ){
634
                    if(c == 0 ){
635
                        double_data[i] = get_real(infile,0);
635
                        double_data[i] = get_real(infile,0);
636
                        i++;
636
                        i++;
637
                    }
637
                    }
638
                    else
638
                    else
639
                    {
639
                    {
640
                        double_data[i] = get_real(infile,1);
640
                        double_data[i] = get_real(infile,1);
641
                        i++;
641
                        i++;
Line 645... Line 645...
645
            /* draw path :  closed & optional filled */
645
            /* draw path :  closed & optional filled */
646
                decimals = find_number_of_digits(precision);
646
                decimals = find_number_of_digits(precision);
647
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,5,%s,[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,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,use_affine,affine_matrix);
647
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,5,%s,[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,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,use_affine,affine_matrix);
648
                click_cnt++;reset();
648
                click_cnt++;reset();
649
            break;
649
            break;
650
        case ARC:
650
        case ARC:
651
        /*
651
        /*
652
         @ arc xc,yc,width,height,start_angle,end_angle,color
652
         @ arc xc,yc,width,height,start_angle,end_angle,color
653
         @ can not be set "onclick" or "drag xy"
653
         @ can not be set "onclick" or "drag xy"
654
         @ attention: width == height == radius in pixels)
654
         @ attention: width == height == radius in pixels)
655
        */
655
        */
Line 663... Line 663...
663
                    case 5:double_data[3] = get_real(infile,0);break; /* end angle in degrees */
663
                    case 5:double_data[3] = get_real(infile,0);break; /* end angle in degrees */
664
                    case 6:stroke_color = get_color(infile,1);/* name or hex color */
664
                    case 6:stroke_color = get_color(infile,1);/* name or hex color */
665
                    /* in Shape library:
665
                    /* in Shape library:
666
                        x[0] = x[1] = xc
666
                        x[0] = x[1] = xc
667
                        y[0] = y[1] = yc
667
                        y[0] = y[1] = yc
668
                        w[0] = w[1] = radius = width = height  
668
                        w[0] = w[1] = radius = width = height
669
                        h[0] = start_angle ; h[1] = end_engle
669
                        h[0] = start_angle ; h[1] = end_engle
670
                    */
670
                    */
671
                        decimals = find_number_of_digits(precision);
671
                        decimals = find_number_of_digits(precision);
672
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,12,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[0],decimals,double_data[1],decimals,double_data[1],int_data[0],int_data[0],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
672
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,12,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[0],decimals,double_data[1],decimals,double_data[1],int_data[0],int_data[0],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
673
                        reset();
673
                        reset();
674
                    break;
674
                    break;
675
                }
675
                }
676
            }
676
            }
677
            break;
677
            break;
678
        case ELLIPSE:
678
        case ELLIPSE:
679
        /*
679
        /*
680
        @ ellipse xc,yc,radius_x,radius_y,color
680
        @ ellipse xc,yc,radius_x,radius_y,color
681
        @ a ellipse with center xc/yc in x/y-range
681
        @ a ellipse with center xc/yc in x/y-range
682
        @ radius_x and radius_y are in pixels
682
        @ radius_x and radius_y are in pixels
683
        @ may be set draggable / onclick
683
        @ may be set draggable / onclick
684
        @ will shrink / expand on zoom out / zoom in
684
        @ will shrink / expand on zoom out / zoom in
685
        */
685
        */
686
            for(i=0;i<5;i++){
686
            for(i=0;i<5;i++){
687
                switch(i){
687
                switch(i){
688
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
688
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
689
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
689
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
690
                    case 2:double_data[2] = get_real(infile,0);break; /* rx -> px  */
690
                    case 2:double_data[2] = get_real(infile,0);break; /* rx -> px  */
691
                    case 3:double_data[3] = get_real(infile,0);break; /* ry -> px  */
691
                    case 3:double_data[3] = get_real(infile,0);break; /* ry -> px  */
692
                    case 4:stroke_color = get_color(infile,1);/* name or hex color */
692
                    case 4:stroke_color = get_color(infile,1);/* name or hex color */
693
                        decimals = find_number_of_digits(precision);
693
                        decimals = find_number_of_digits(precision);
694
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,3,[%.*f],[%.*f],[%.*f],[%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],decimals,double_data[2],decimals,double_data[3],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,use_affine,affine_matrix);
694
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,3,[%.*f],[%.*f],[%.*f],[%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],decimals,double_data[2],decimals,double_data[3],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,use_affine,affine_matrix);
695
                        click_cnt++;reset();
695
                        click_cnt++;reset();
696
                    break;
696
                    break;
Line 709... Line 709...
709
                    case 1 : dashtype[1] = (int) line_width*( get_real(infile,1)) ; break;
709
                    case 1 : dashtype[1] = (int) line_width*( get_real(infile,1)) ; break;
710
                }
710
                }
711
            }
711
            }
712
        break;
712
        break;
713
        case CIRCLE:
713
        case CIRCLE:
714
        /*
714
        /*
715
        @ circle xc,yc,width (2*r in pixels),color
715
        @ circle xc,yc,width (2*r in pixels),color
716
        @ use command 'fcircle xc,yc,d,color' or command 'filled' for a filled disk
716
        @ use command 'fcircle xc,yc,d,color' or command 'filled' for a filled disk
717
        @ use command 'fillcolor color' to set the fillcolor
717
        @ use command 'fillcolor color' to set the fillcolor
718
        @ may be set draggable / onclick
718
        @ may be set draggable / onclick
719
        @ will shrink / expand on zoom out / zoom in
719
        @ will shrink / expand on zoom out / zoom in
720
        */
720
        */
721
            for(i=0;i<4;i++){
721
            for(i=0;i<4;i++){
722
                switch(i){
722
                switch(i){
723
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
723
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
724
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
724
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
725
                    case 2: double_data[2] = px2x((get_real(infile,0))/2) - px2x(0);break; /* radius in 'dx' xrange*/
725
                    case 2: double_data[2] = px2x((get_real(infile,0))/2) - px2x(0);break; /* radius in 'dx' xrange*/
726
                    case 3: stroke_color = get_color(infile,1);/* name or hex color */
726
                    case 3: stroke_color = get_color(infile,1);/* name or hex color */
727
                        decimals = find_number_of_digits(precision);
727
                        decimals = find_number_of_digits(precision);
728
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,13,[%.*f],[%.*f],[%.3f],[%.3f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],double_data[2],double_data[2],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,use_affine,affine_matrix);
728
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,13,[%.*f],[%.*f],[%.3f],[%.3f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],double_data[2],double_data[2],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,use_affine,affine_matrix);
729
                        click_cnt++;reset();
729
                        click_cnt++;reset();
730
                    break;
730
                    break;
731
                }
731
                }
732
            }
732
            }
Line 734... Line 734...
734
        case RAYS:
734
        case RAYS:
735
        /*
735
        /*
736
         @ rays color,xc,yc,x1,y1,x2,y2,x3,y3...x_n,y_n
736
         @ rays color,xc,yc,x1,y1,x2,y2,x3,y3...x_n,y_n
737
         @ draw rays in color 'color' and center (xc:yc)
737
         @ draw rays in color 'color' and center (xc:yc)
738
         @ may be set draggable or onclick (every individual ray)
738
         @ may be set draggable or onclick (every individual ray)
739
        */
739
        */
740
            stroke_color=get_color(infile,0);
740
            stroke_color=get_color(infile,0);
741
            fill_color = stroke_color;
741
            fill_color = stroke_color;
742
            double_data[0] = get_real(infile,0);/* xc */
742
            double_data[0] = get_real(infile,0);/* xc */
743
            double_data[1] = get_real(infile,0);/* yc */
743
            double_data[1] = get_real(infile,0);/* yc */
744
            i=2;
744
            i=2;
Line 752... Line 752...
752
                    double_data[i] = get_real(infile,1); /* y */
752
                    double_data[i] = get_real(infile,1); /* y */
753
                }
753
                }
754
            fprintf(js_include_file,"/* double_data[%d] = %f */\n",i,double_data[i]);
754
            fprintf(js_include_file,"/* double_data[%d] = %f */\n",i,double_data[i]);
755
                i++;
755
                i++;
756
            }
756
            }
757
           
757
 
758
            if( i%2 != 0 ){canvas_error("in command rays: unpaired x or y value");}
758
            if( i%2 != 0 ){canvas_error("in command rays: unpaired x or y value");}
759
            decimals = find_number_of_digits(precision);           
759
            decimals = find_number_of_digits(precision);
760
            for(c=2; c<i;c = c+2){
760
            for(c=2; c<i;c = c+2){
761
                click_cnt++;
761
                click_cnt++;
762
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[c],decimals,double_data[1],decimals,double_data[c+1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
762
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[c],decimals,double_data[1],decimals,double_data[c+1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
763
            }
763
            }
764
            reset();
764
            reset();
765
            break;
765
            break;
766
        case ARROW:
766
        case ARROW:
767
        /*
767
        /*
768
        @ arrow x1,y1,x2,y2,h,color
768
        @ arrow x1,y1,x2,y2,h,color
769
        @ draw a single headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and in color 'color'
769
        @ draw a single headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and in color 'color'
770
        @ use command 'linewidth int' to adjust thickness of the arrow
770
        @ use command 'linewidth int' to adjust thickness of the arrow
771
        @ may be set draggable / onclick
771
        @ may be set draggable / onclick
772
        */
772
        */
773
            for(i=0;i<6;i++){
773
            for(i=0;i<6;i++){
774
                switch(i){
774
                switch(i){
775
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
775
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
776
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
776
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
777
                    case 2: double_data[2] = get_real(infile,0);break; /* x */
777
                    case 2: double_data[2] = get_real(infile,0);break; /* x */
778
                    case 3: double_data[3] = get_real(infile,0);break; /* y */
778
                    case 3: double_data[3] = get_real(infile,0);break; /* y */
779
                    case 4: arrow_head = (int) get_real(infile,0);break;/* h */
779
                    case 4: arrow_head = (int) get_real(infile,0);break;/* h */
780
                    case 5: stroke_color = get_color(infile,1);/* name or hex color */
780
                    case 5: stroke_color = get_color(infile,1);/* name or hex color */
781
                        decimals = find_number_of_digits(precision);
781
                        decimals = find_number_of_digits(precision);
782
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,8,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%d,%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],arrow_head,arrow_head,arrow_head,arrow_head,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
782
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,8,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%d,%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],arrow_head,arrow_head,arrow_head,arrow_head,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
783
                        click_cnt++;
783
                        click_cnt++;
Line 785... Line 785...
785
                        break;
785
                        break;
786
                }
786
                }
787
            }
787
            }
788
            break;
788
            break;
789
        case ARROW2:
789
        case ARROW2:
790
        /*
790
        /*
791
        @ arrow2 x1,y1,x2,y2,h,color
791
        @ arrow2 x1,y1,x2,y2,h,color
792
        @ draw a double headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and  in color 'color'
792
        @ draw a double headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and  in color 'color'
793
        @ use command 'arrowhead int' to adjust the arrow head size
793
        @ use command 'arrowhead int' to adjust the arrow head size
794
        @ use command 'linewidth int' to adjust thickness of the arrow
794
        @ use command 'linewidth int' to adjust thickness of the arrow
795
        @ may be set draggable / onclick
795
        @ may be set draggable / onclick
Line 807... Line 807...
807
                        click_cnt++;reset();
807
                        click_cnt++;reset();
808
                        break;
808
                        break;
809
                }
809
                }
810
            }
810
            }
811
            break;
811
            break;
812
        case PARALLEL:
812
        case PARALLEL:
813
        /*
813
        /*
814
         @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor]
814
         @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor]
815
         @ can not be set "onclick" or "drag xy"
815
         @ can not be set "onclick" or "drag xy"
816
        */
816
        */
817
            for( i = 0;i < 8; i++ ){
817
            for( i = 0;i < 8; i++ ){
818
                switch(i){
818
                switch(i){
819
                    case 0: double_data[0] = get_real(infile,0);break; /* x1-values  -> x-pixels*/
819
                    case 0: double_data[0] = get_real(infile,0);break; /* x1-values  -> x-pixels*/
820
                    case 1: double_data[1] = get_real(infile,0);break; /* y1-values  -> y-pixels*/
820
                    case 1: double_data[1] = get_real(infile,0);break; /* y1-values  -> y-pixels*/
Line 855... Line 855...
855
            }
855
            }
856
            break;
856
            break;
857
        case LATTICE:
857
        case LATTICE:
858
        /*
858
        /*
859
         @lattice x0,y0,xv1,yv1,xv2,yv2,n1,n2,color
859
         @lattice x0,y0,xv1,yv1,xv2,yv2,n1,n2,color
860
         @can not be set "onclick" or "drag xy"
860
         @can not be set "onclick" or "drag xy"
861
        */
861
        */
862
            if( js_function[DRAW_LATTICE] != 1 ){ js_function[DRAW_LATTICE] = 1;}
862
            if( js_function[DRAW_LATTICE] != 1 ){ js_function[DRAW_LATTICE] = 1;}
863
            for( i = 0; i<9; i++){
863
            for( i = 0; i<9; i++){
864
                switch(i){
864
                switch(i){
865
                    case 0: int_data[0] = x2px(get_real(infile,0));break; /* x0-values  -> x-pixels*/
865
                    case 0: int_data[0] = x2px(get_real(infile,0));break; /* x0-values  -> x-pixels*/
Line 910... Line 910...
910
        fprintf(js_include_file,"\ny_use_snap_to_grid = 1;if (typeof snap_x === 'undefined') { var snap_x = 1;};var snap_y = 1;\nfunction snap_to_y(y){return y2px(snap_y*(Math.round((px2y(y))/snap_y)));};\n");
910
        fprintf(js_include_file,"\ny_use_snap_to_grid = 1;if (typeof snap_x === 'undefined') { var snap_x = 1;};var snap_y = 1;\nfunction snap_to_y(y){return y2px(snap_y*(Math.round((px2y(y))/snap_y)));};\n");
911
        break;
911
        break;
912
        case USERTEXTAREA_XY:
912
        case USERTEXTAREA_XY:
913
        /*
913
        /*
914
        @ usertextarea_xy
914
        @ usertextarea_xy
915
        @ keyword
915
        @ keyword
916
        @ to be used in combination with command "userdraw object_type,color" wherein object_type is only segment / polyline for the time being...
916
        @ to be used in combination with command "userdraw object_type,color" wherein object_type is only segment / polyline for the time being...
917
        @ if set two textareas are added to the document<br />(one for x-values , one for y-values)
917
        @ if set two textareas are added to the document<br />(one for x-values , one for y-values)
918
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
918
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
919
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
919
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
920
        @ user drawings will not zoom on zooming (or pan on panning)
920
        @ user drawings will not zoom on zooming (or pan on panning)
921
        */
921
        */
922
            if(use_tooltip == TRUE){canvas_error("usertextarea_xy can not be combined with intooltip command");}
922
            if(use_tooltip == TRUE){canvas_error("usertextarea_xy can not be combined with intooltip command");}
923
            if( use_input_xy == 1 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
923
            if( use_input_xy == 1 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
924
            fprintf(js_include_file,"function safe_eval(exp){if(exp.indexOf('^') != -1){exp = exp.replace(/\\s*(.*)\\^\\s*(.*)/ig, \"pow($1, $2)\");};var reg = /(?:[a-z$_][a-z0-9$_]*)|(?:[;={}\\[\\]\"'!&<>^\\\\?:])/ig;var valid = true;exp = exp.replace(reg,function($0){if (Math.hasOwnProperty($0)){return \"Math.\"+$0;}else{valid = false;};});if (!valid){alert(\"hmmm \"+exp+\" ?\"); exp = null;}else{try { exp = eval(exp); } catch (e) {alert(\"Invalid arithmetic expression\"); exp = null;};};return exp;};");
924
            fprintf(js_include_file,"function safe_eval(exp){if(exp.indexOf('^') != -1){exp = exp.replace(/\\s*(.*)\\^\\s*(.*)/ig, \"pow($1, $2)\");};var reg = /(?:[a-z$_][a-z0-9$_]*)|(?:[;={}\\[\\]\"'!&<>^\\\\?:])/ig;var valid = true;exp = exp.replace(reg,function($0){if (Math.hasOwnProperty($0)){return \"Math.\"+$0;}else{valid = false;};});if (!valid){alert(\"hmmm \"+exp+\" ?\"); exp = null;}else{try { exp = eval(exp); } catch (e) {alert(\"Invalid arithmetic expression\"); exp = null;};};return exp;};");
925
            use_input_xy = 2;
925
            use_input_xy = 2;
926
            break;
926
            break;
927
        case USERINPUT_XY:
927
        case USERINPUT_XY:
928
        /*
928
        /*
929
        @ userinput_xy
929
        @ userinput_xy
930
        @ keyword
930
        @ keyword
931
        @ to be used in combination with command "userdraw object_type,color"
931
        @ to be used in combination with command "userdraw object_type,color"
932
        @ if set two (or three) input fields are added to the document<br />(one for x-values , one for y-values and in case of drawing circle one for radius-values)
932
        @ if set two (or three) input fields are added to the document<br />(one for x-values , one for y-values and in case of drawing circle one for radius-values)
933
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
933
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
934
        @ math input is allowed (e.g something like: 1+3,2*6,1/3,sqrt(3), sin(pi/4),10^-2,log(2)...)<br />eval function is 'protected' against code injection.
934
        @ math input is allowed (e.g something like: 1+3,2*6,1/3,sqrt(3), sin(pi/4),10^-2,log(2)...)<br />eval function is 'protected' against code injection.
935
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
935
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
936
        @ user drawings will not zoom on zooming (or pan on panning)
936
        @ user drawings will not zoom on zooming (or pan on panning)
937
        */
937
        */
938
            if(use_tooltip == TRUE){canvas_error("userinput_xy can not be combined with intooltip command");}
938
            if(use_tooltip == TRUE){canvas_error("userinput_xy can not be combined with intooltip command");}
939
            /* add simple eval check to avoid code injection with unprotected eval(string) */
939
            /* add simple eval check to avoid code injection with unprotected eval(string) */
940
            fprintf(js_include_file,"function safe_eval(exp){if(exp.indexOf('^') != -1){exp = exp.replace(/\\s*(.*)\\^\\s*(.*)/ig, \"pow($1, $2)\");};var reg = /(?:[a-z$_][a-z0-9$_]*)|(?:[;={}\\[\\]\"'!&<>^\\\\?:])/ig;var valid = true;exp = exp.replace(reg,function($0){if (Math.hasOwnProperty($0)){return \"Math.\"+$0;}else{valid = false;};});if (!valid){alert(\"hmmm \"+exp+\" ?\"); exp = null;}else{try { exp = eval(exp); } catch (e) {alert(\"Invalid arithmetic expression\"); exp = null;};};return exp;};");
940
            fprintf(js_include_file,"function safe_eval(exp){if(exp.indexOf('^') != -1){exp = exp.replace(/\\s*(.*)\\^\\s*(.*)/ig, \"pow($1, $2)\");};var reg = /(?:[a-z$_][a-z0-9$_]*)|(?:[;={}\\[\\]\"'!&<>^\\\\?:])/ig;var valid = true;exp = exp.replace(reg,function($0){if (Math.hasOwnProperty($0)){return \"Math.\"+$0;}else{valid = false;};});if (!valid){alert(\"hmmm \"+exp+\" ?\"); exp = null;}else{try { exp = eval(exp); } catch (e) {alert(\"Invalid arithmetic expression\"); exp = null;};};return exp;};");
941
            use_input_xy = 1;
941
            use_input_xy = 1;
Line 944... Line 944...
944
        /*
944
        /*
945
        @ userdraw object_type,color
945
        @ userdraw object_type,color
946
        @ implemented object_type: <ul><li>point</li><li>points</li><li>crosshair</li><li>crosshairs</li><li>line</li><li>lines</li><li>segment</li><li>segments</li><li>polyline</li><li>circle</li><li>circles</li><li>arrow</li><li>arrows</li><li>triangle</li><li>polygon</li><li>poly[3-9]</li><li>rect</li><li>roundrect</li><li>rects</li><li>roundrects</li><li>freehandline</li><li>freehandlines</li><li>path</li><li>paths</li><li>text</li></ul>
946
        @ implemented object_type: <ul><li>point</li><li>points</li><li>crosshair</li><li>crosshairs</li><li>line</li><li>lines</li><li>segment</li><li>segments</li><li>polyline</li><li>circle</li><li>circles</li><li>arrow</li><li>arrows</li><li>triangle</li><li>polygon</li><li>poly[3-9]</li><li>rect</li><li>roundrect</li><li>rects</li><li>roundrects</li><li>freehandline</li><li>freehandlines</li><li>path</li><li>paths</li><li>text</li></ul>
947
        @ 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)
947
        @ 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)
948
        @ note: object_type text: Any string or multiple strings may be placed anywhere on the canvas.<br />while typing the background of every typed char will be lightblue..."backspace / delete / esc" will remove typed text.<br />You will need to hit "enter" to add the text to the array "userdraw_txt()" : lightblue background will disappear<br />Placing the cursor somewhere on a typed text and hitting "delete/backspace/esc" , a confirm will popup asking to delete the selected text.This text will be removed from the "userdraw_txt()" answer array.<br />Use commands 'fontsize' and 'fontfamily' to control the text appearance
948
        @ note: object_type text: Any string or multiple strings may be placed anywhere on the canvas.<br />while typing the background of every typed char will be lightblue..."backspace / delete / esc" will remove typed text.<br />You will need to hit "enter" to add the text to the array "userdraw_txt()" : lightblue background will disappear<br />Placing the cursor somewhere on a typed text and hitting "delete/backspace/esc" , a confirm will popup asking to delete the selected text.This text will be removed from the "userdraw_txt()" answer array.<br />Use commands 'fontsize' and 'fontfamily' to control the text appearance
949
        @ note: object_type polygone: Will be finished (the object is closed) when clicked on the first point of the polygone again.
949
        @ note: object_type polygone: Will be finished (the object is closed) when clicked on the first point of the polygone again.
950
        @ note: all objects will be removed -after a javascript confirm box- when clicked on an object point with middle or right mouse butten (e.g. event.which != 1 : all buttons but left)
950
        @ note: all objects will be removed -after a javascript confirm box- when clicked on an object point with middle or right mouse butten (e.g. event.which != 1 : all buttons but left)
951
        @ use command "filled", "opacity int,int"  and "fillcolor color" to trigger coloured filling of fillable objects
951
        @ use command "filled", "opacity int,int"  and "fillcolor color" to trigger coloured filling of fillable objects
952
        @ use command "dashed" and/or "dashtype int,int" to trigger dashing
952
        @ use command "dashed" and/or "dashtype int,int" to trigger dashing
953
        @ use command "replyformat int" to control / adjust output formatting of javascript function read_canvas();
953
        @ use command "replyformat int" to control / adjust output formatting of javascript function read_canvas();
954
        @ may be combined with onclick or drag xy  of other components of flyscript objects (although not very usefull...)
954
        @ may be combined with onclick or drag xy  of other components of flyscript objects (although not very usefull...)
955
        @ may be combined with keyword 'userinput_xy' or
955
        @ may be combined with keyword 'userinput_xy' or
956
        @ note: when zooming / panning after a drawing, the drawing will NOT be zoomed / panned...this is a "design" flaw and not a feature <br />To avoid trouble do not use zooming / panning together width userdraw.!
956
        @ note: when zooming / panning after a drawing, the drawing will NOT be zoomed / panned...this is a "design" flaw and not a feature <br />To avoid trouble do not use zooming / panning together width userdraw.!
957
        */
957
        */
958
            if( use_userdraw == TRUE ){ /* only one object type may be drawn*/
958
            if( use_userdraw == TRUE ){ /* only one object type may be drawn*/
959
                canvas_error("Only one userdraw primitive may be used: read documentation !!");
959
                canvas_error("Only one userdraw primitive may be used: read documentation !!");
960
            }
960
            }
Line 964... Line 964...
964
            stroke_color = get_color(infile,1);
964
            stroke_color = get_color(infile,1);
965
            if( strcmp(draw_type,"point") == 0 ){
965
            if( strcmp(draw_type,"point") == 0 ){
966
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
966
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
967
                if(reply_format < 1 ){reply_format = 8;}
967
                if(reply_format < 1 ){reply_format = 8;}
968
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
968
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
969
                if(use_input_xy == 1){
969
                if(use_input_xy == 1){
970
                    add_input_circle(js_include_file,1,1);
970
                    add_input_circle(js_include_file,1,1);
971
                    add_input_xy(js_include_file,canvas_root_id);
971
                    add_input_xy(js_include_file,canvas_root_id);
972
                }
972
                }
973
                add_js_points(js_include_file,1,draw_type,line_width,line_width,stroke_color,stroke_opacity,1,stroke_color,stroke_opacity,0,1,1);
973
                add_js_points(js_include_file,1,draw_type,line_width,line_width,stroke_color,stroke_opacity,1,stroke_color,stroke_opacity,0,1,1);
974
            }
974
            }
975
            else
975
            else
976
            if( strcmp(draw_type,"points") == 0 ){
976
            if( strcmp(draw_type,"points") == 0 ){
977
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
977
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
978
                if(reply_format < 1 ){reply_format = 8;}
978
                if(reply_format < 1 ){reply_format = 8;}
979
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
979
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
980
                if(use_input_xy == 1){
980
                if(use_input_xy == 1){
981
                    add_input_circle(js_include_file,1,2);
981
                    add_input_circle(js_include_file,1,2);
982
                    add_input_xy(js_include_file,canvas_root_id);
982
                    add_input_xy(js_include_file,canvas_root_id);
983
                }
983
                }
984
                add_js_points(js_include_file,2,draw_type,line_width,line_width,stroke_color,stroke_opacity,1,stroke_color,stroke_opacity,0,1,1);
984
                add_js_points(js_include_file,2,draw_type,line_width,line_width,stroke_color,stroke_opacity,1,stroke_color,stroke_opacity,0,1,1);
985
            }
985
            }
986
            else
986
            else
987
            if( strcmp(draw_type,"segment") == 0 ){
987
            if( strcmp(draw_type,"segment") == 0 ){
988
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
988
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
989
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
989
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
990
                if(reply_format < 1){reply_format = 11;}
990
                if(reply_format < 1){reply_format = 11;}
991
                if(use_input_xy == 1){
991
                if(use_input_xy == 1){
992
                    add_input_segment(js_include_file,1);
992
                    add_input_segment(js_include_file,1);
993
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
993
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
994
                }
994
                }
995
                add_js_segments(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
995
                add_js_segments(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
996
            }
996
            }
Line 1007... Line 1007...
1007
            else
1007
            else
1008
            if( strcmp(draw_type,"segments") == 0 ){
1008
            if( strcmp(draw_type,"segments") == 0 ){
1009
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1009
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1010
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
1010
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
1011
                if(reply_format < 1){reply_format = 11;}
1011
                if(reply_format < 1){reply_format = 11;}
1012
                if(use_input_xy == 1){
1012
                if(use_input_xy == 1){
1013
                    add_input_segment(js_include_file,2);
1013
                    add_input_segment(js_include_file,2);
1014
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1014
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1015
                }
1015
                }
1016
                add_js_segments(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1016
                add_js_segments(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1017
            }
1017
            }
1018
            else
1018
            else
1019
            if( strcmp(draw_type,"circle") == 0 ){
1019
            if( strcmp(draw_type,"circle") == 0 ){
1020
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1020
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1021
                if(reply_format < 1){reply_format = 10;}
1021
                if(reply_format < 1){reply_format = 10;}
1022
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1022
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1023
                if(use_input_xy == 1){
1023
                if(use_input_xy == 1){
1024
                    add_input_circle(js_include_file,2,1);
1024
                    add_input_circle(js_include_file,2,1);
1025
                    add_input_xyr(js_include_file,canvas_root_id);
1025
                    add_input_xyr(js_include_file,canvas_root_id);
1026
                }
1026
                }
1027
                add_js_circles(js_include_file,1,draw_type,line_width,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1027
                add_js_circles(js_include_file,1,draw_type,line_width,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1028
            }
1028
            }
Line 1030... Line 1030...
1030
            if( strcmp(draw_type,"circles") == 0 ){
1030
            if( strcmp(draw_type,"circles") == 0 ){
1031
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1031
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1032
                if(reply_format < 1){reply_format = 10;}
1032
                if(reply_format < 1){reply_format = 10;}
1033
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1033
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1034
                add_js_circles(js_include_file,2,draw_type,line_width,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1034
                add_js_circles(js_include_file,2,draw_type,line_width,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1035
                if(use_input_xy == 1){
1035
                if(use_input_xy == 1){
1036
                    add_input_circle(js_include_file,2,2);
1036
                    add_input_circle(js_include_file,2,2);
1037
                    add_input_xyr(js_include_file,canvas_root_id);
1037
                    add_input_xyr(js_include_file,canvas_root_id);
1038
                }
1038
                }
1039
            }
1039
            }
1040
            else
1040
            else
1041
            if(strcmp(draw_type,"crosshair") == 0 ){
1041
            if(strcmp(draw_type,"crosshair") == 0 ){
1042
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1042
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1043
                if(reply_format < 1){reply_format = 8;}
1043
                if(reply_format < 1){reply_format = 8;}
1044
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1044
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1045
                add_js_crosshairs(js_include_file,1,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1045
                add_js_crosshairs(js_include_file,1,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1046
                if(use_input_xy == 1){
1046
                if(use_input_xy == 1){
1047
                    add_input_crosshair(js_include_file,1);
1047
                    add_input_crosshair(js_include_file,1);
1048
                    add_input_xy(js_include_file,canvas_root_id);
1048
                    add_input_xy(js_include_file,canvas_root_id);
1049
                }
1049
                }
1050
            }
1050
            }
1051
            else
1051
            else
1052
            if(strcmp(draw_type,"crosshairs") == 0 ){
1052
            if(strcmp(draw_type,"crosshairs") == 0 ){
1053
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1053
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1054
                if(reply_format < 1){reply_format = 8;}
1054
                if(reply_format < 1){reply_format = 8;}
1055
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1055
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1056
                add_js_crosshairs(js_include_file,2,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1056
                add_js_crosshairs(js_include_file,2,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1057
                if(use_input_xy == 1){
1057
                if(use_input_xy == 1){
1058
                    add_input_crosshair(js_include_file,2);
1058
                    add_input_crosshair(js_include_file,2);
1059
                    add_input_xy(js_include_file,canvas_root_id);
1059
                    add_input_xy(js_include_file,canvas_root_id);
1060
                }
1060
                }
1061
            }
1061
            }
1062
            else
1062
            else
1063
            if(strcmp(draw_type,"freehandline") == 0 ){
1063
            if(strcmp(draw_type,"freehandline") == 0 ){
1064
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1064
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1065
                if(reply_format < 1){reply_format = 6;}
1065
                if(reply_format < 1){reply_format = 6;}
1066
                add_js_paths(js_include_file,1,draw_type,line_width,0,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);  
1066
                add_js_paths(js_include_file,1,draw_type,line_width,0,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1067
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1067
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1068
            }
1068
            }
1069
            else
1069
            else
1070
            if(strcmp(draw_type,"freehandlines") == 0 ){
1070
            if(strcmp(draw_type,"freehandlines") == 0 ){
1071
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1071
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1072
                if(reply_format < 1){reply_format = 6;}
1072
                if(reply_format < 1){reply_format = 6;}
1073
                add_js_paths(js_include_file,2,draw_type,line_width,0,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);  
1073
                add_js_paths(js_include_file,2,draw_type,line_width,0,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1074
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1074
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1075
            }
1075
            }
1076
            else
1076
            else
1077
            if(strcmp(draw_type,"path") == 0 ){
1077
            if(strcmp(draw_type,"path") == 0 ){
1078
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1078
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1079
                if(reply_format < 1){reply_format = 6;}
1079
                if(reply_format < 1){reply_format = 6;}
1080
                add_js_paths(js_include_file,1,draw_type,line_width,1,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);  
1080
                add_js_paths(js_include_file,1,draw_type,line_width,1,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1081
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1081
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1082
            }
1082
            }
1083
            else
1083
            else
1084
            if(strcmp(draw_type,"paths") == 0 ){
1084
            if(strcmp(draw_type,"paths") == 0 ){
1085
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1085
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1086
                if(reply_format < 1){reply_format = 6;}
1086
                if(reply_format < 1){reply_format = 6;}
1087
                add_js_paths(js_include_file,2,draw_type,line_width,1,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);  
1087
                add_js_paths(js_include_file,2,draw_type,line_width,1,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1088
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1088
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1089
            }
1089
            }
1090
            else
1090
            else
1091
            if(strcmp(draw_type,"arrows") == 0 ){
1091
            if(strcmp(draw_type,"arrows") == 0 ){
1092
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1092
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1093
                if(reply_format < 1){reply_format = 11;}
1093
                if(reply_format < 1){reply_format = 11;}
1094
                add_js_arrows(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1094
                add_js_arrows(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1095
                if(use_input_xy == 1){
1095
                if(use_input_xy == 1){
1096
                    add_input_arrow(js_include_file,2);
1096
                    add_input_arrow(js_include_file,2);
1097
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1097
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1098
                }
1098
                }
1099
            }
1099
            }
1100
            else
1100
            else
1101
            if(strcmp(draw_type,"arrow") == 0 ){
1101
            if(strcmp(draw_type,"arrow") == 0 ){
1102
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1102
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1103
                if(reply_format < 1){reply_format = 11;}
1103
                if(reply_format < 1){reply_format = 11;}
1104
                add_js_arrows(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1104
                add_js_arrows(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1105
                if(use_input_xy == 1){
1105
                if(use_input_xy == 1){
1106
                    add_input_arrow(js_include_file,1);
1106
                    add_input_arrow(js_include_file,1);
1107
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1107
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1108
                }
1108
                }
1109
            }
1109
            }
1110
            else
1110
            else
Line 1115... Line 1115...
1115
                if( use_input_xy == 2 ){
1115
                if( use_input_xy == 2 ){
1116
                  add_textarea_polygon(js_include_file);
1116
                  add_textarea_polygon(js_include_file);
1117
                  add_textarea_xy(js_include_file,canvas_root_id);
1117
                  add_textarea_xy(js_include_file,canvas_root_id);
1118
                }
1118
                }
1119
            }
1119
            }
1120
            else
1120
            else
1121
            if(strncmp(draw_type,"poly",4) == 0){
1121
            if(strncmp(draw_type,"poly",4) == 0){
1122
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1122
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1123
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1123
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1124
                if(reply_format < 1){reply_format = 2;}
1124
                if(reply_format < 1){reply_format = 2;}
1125
                add_js_poly(js_include_file,(int) (draw_type[4]-'0'),draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1125
                add_js_poly(js_include_file,(int) (draw_type[4]-'0'),draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1126
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1126
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1127
            }
1127
            }
1128
            else
1128
            else
1129
            if(strcmp(draw_type,"triangle") == 0){
1129
            if(strcmp(draw_type,"triangle") == 0){
1130
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1130
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1131
                if(reply_format < 1){reply_format = 2;}
1131
                if(reply_format < 1){reply_format = 2;}
1132
                add_js_poly(js_include_file,3,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1132
                add_js_poly(js_include_file,3,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1133
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1133
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1134
            }
1134
            }
1135
            else
1135
            else
1136
            if( strcmp(draw_type,"line") == 0 ){
1136
            if( strcmp(draw_type,"line") == 0 ){
1137
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1137
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1138
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1138
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1139
                if(reply_format < 1){reply_format = 11;}
1139
                if(reply_format < 1){reply_format = 11;}
1140
                add_js_lines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1140
                add_js_lines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
Line 1151... Line 1151...
1151
                add_js_lines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1151
                add_js_lines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1152
                if( use_input_xy == 1 ){
1152
                if( use_input_xy == 1 ){
1153
                    add_input_line(js_include_file,2);
1153
                    add_input_line(js_include_file,2);
1154
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1154
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1155
                }
1155
                }
1156
            }
1156
            }
1157
            else
1157
            else
1158
            if( strcmp(draw_type,"rects") == 0){
1158
            if( strcmp(draw_type,"rects") == 0){
1159
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1159
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1160
                if(reply_format < 1){reply_format = 2;}
1160
                if(reply_format < 1){reply_format = 2;}
1161
                add_js_rect(js_include_file,2,0,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1161
                add_js_rect(js_include_file,2,0,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1162
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1162
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1163
            }
1163
            }
1164
            else
1164
            else
1165
            if( strcmp(draw_type,"roundrects") == 0){
1165
            if( strcmp(draw_type,"roundrects") == 0){
1166
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1166
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1167
                if(reply_format < 1){reply_format = 2;}
1167
                if(reply_format < 1){reply_format = 2;}
1168
                add_js_rect(js_include_file,2,1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1168
                add_js_rect(js_include_file,2,1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1169
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1169
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1170
            }
1170
            }
1171
            else
1171
            else
1172
            if( strcmp(draw_type,"rect") == 0){
1172
            if( strcmp(draw_type,"rect") == 0){
1173
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1173
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1174
                if(reply_format < 1){reply_format = 2;}
1174
                if(reply_format < 1){reply_format = 2;}
1175
                add_js_rect(js_include_file,1,0,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1175
                add_js_rect(js_include_file,1,0,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1176
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1176
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1177
            }
1177
            }
1178
            else
1178
            else
1179
            if( strcmp(draw_type,"roundrect") == 0){
1179
            if( strcmp(draw_type,"roundrect") == 0){
1180
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1180
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1181
                if(reply_format < 1){reply_format = 2;}
1181
                if(reply_format < 1){reply_format = 2;}
1182
                add_js_rect(js_include_file,1,1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1182
                add_js_rect(js_include_file,1,1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1183
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1183
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1184
            }
1184
            }
1185
            else
1185
            else
1186
            if( strcmp(draw_type,"text") == 0){
1186
            if( strcmp(draw_type,"text") == 0){
1187
                if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}      
1187
                if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}
1188
                if(reply_format < 1){reply_format = 17;}
1188
                if(reply_format < 1){reply_format = 17;}
1189
                add_js_text(js_include_file,canvas_root_id,font_size,font_family,font_color,stroke_opacity,use_rotate,angle,use_translate,translate_x,translate_y);
1189
                add_js_text(js_include_file,canvas_root_id,font_size,font_family,font_color,stroke_opacity,use_rotate,angle,use_translate,translate_x,translate_y);
1190
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1190
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1191
            }
1191
            }
1192
            else
1192
            else
1193
            {
1193
            {
1194
                canvas_error("unknown drawtype or typo? ");
1194
                canvas_error("unknown drawtype or typo? ");
1195
            }
1195
            }
1196
            reset();
1196
            reset();
1197
        break;
1197
        break;
Line 1257... Line 1257...
1257
        case TRACE_JSMATH:
1257
        case TRACE_JSMATH:
1258
        /*
1258
        /*
1259
         @trace_jsmath some_javascript_math_function
1259
         @trace_jsmath some_javascript_math_function
1260
         @will use a crosshair to trace the jsmath curve
1260
         @will use a crosshair to trace the jsmath curve
1261
         @two inputfields will display the current x/y-values (approximated)
1261
         @two inputfields will display the current x/y-values (approximated)
1262
         @default labels 'x' and 'y'<br />the commands 'xlabel some_x_axis_name' and 'ylabel some_y_axis_name' will set the label for the input fields  
1262
         @default labels 'x' and 'y'<br />the commands 'xlabel some_x_axis_name' and 'ylabel some_y_axis_name' will set the label for the input fields
1263
         @use linewidth,strokecolor,crosshairsize to adjust the corsshair.
1263
         @use linewidth,strokecolor,crosshairsize to adjust the corsshair.
1264
         @example: trace_jsmath Math.pow(x,2)+4*x+16
1264
         @example: trace_jsmath Math.pow(x,2)+4*x+16
1265
         @example: trace_jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1265
         @example: trace_jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1266
         @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1266
         @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1267
         @can not be combined with commands 'mouse color,fontsize' and 'intooltip tip_text'
1267
         @can not be combined with commands 'mouse color,fontsize' and 'intooltip tip_text'
Line 1272... Line 1272...
1272
            break;
1272
            break;
1273
        case JSMATH:
1273
        case JSMATH:
1274
        /*
1274
        /*
1275
            @jsmath some_javascript_math_function
1275
            @jsmath some_javascript_math_function
1276
            @will calculate an y-value from a userinput x-value and draws a crosshairs on these coordinates.
1276
            @will calculate an y-value from a userinput x-value and draws a crosshairs on these coordinates.
1277
            @default labels 'x' and 'y'<br />the commands 'xlabel some_x_axis_name' and 'ylabel some_y_axis_name' will set the label for the input fields  
1277
            @default labels 'x' and 'y'<br />the commands 'xlabel some_x_axis_name' and 'ylabel some_y_axis_name' will set the label for the input fields
1278
            @example: jsmath Math.pow(x,2)+4*x+16
1278
            @example: jsmath Math.pow(x,2)+4*x+16
1279
            @example: jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1279
            @example: jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1280
            @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1280
            @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1281
            @can not be combined with commands 'mouse color,fontsize' and 'intooltip tip_text'
1281
            @can not be combined with commands 'mouse color,fontsize' and 'intooltip tip_text'
1282
        */
1282
        */
Line 1303... Line 1303...
1303
            }
1303
            }
1304
            else
1304
            else
1305
            {
1305
            {
1306
                stroke_color = get_color(infile,0);
1306
                stroke_color = get_color(infile,0);
1307
                char *fun1 = get_string_argument(infile,1);
1307
                char *fun1 = get_string_argument(infile,1);
1308
                if( strlen(fun1) == 0 ){canvas_error("function is NOT OK !");} 
1308
                if( strlen(fun1) == 0 ){canvas_error("function is NOT OK !");}
1309
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,%d,%s,[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,animation_type,eval(xsize,ysize,fun1,xmin,xmax,ymin,ymax,plot_steps,precision),line_width,line_width,line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
1309
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,%d,%s,[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,animation_type,eval(xsize,ysize,fun1,xmin,xmax,ymin,ymax,plot_steps,precision),line_width,line_width,line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
1310
                click_cnt++;
1310
                click_cnt++;
1311
            }
1311
            }
1312
            animation_type = 9;/* reset to curve plotting without animation */
1312
            animation_type = 9;/* reset to curve plotting without animation */
1313
            reset();
1313
            reset();
1314
            break;
1314
            break;
1315
        case FLY_TEXT:
1315
        case FLY_TEXT:
1316
        /*
1316
        /*
1317
        @ text fontcolor,x,y,font,text_string
1317
        @ text fontcolor,x,y,font,text_string
1318
        @ font may be described by keywords : giant,huge,normal,small,tiny
1318
        @ font may be described by keywords : giant,huge,normal,small,tiny
1319
        @ use command 'fontsize' to increase base fontsize for the keywords
1319
        @ use command 'fontsize' to increase base fontsize for the keywords
1320
        @ may be set "onclick" or "drag xy"
1320
        @ may be set "onclick" or "drag xy"
1321
        @ backwards compatible with flydraw
1321
        @ backwards compatible with flydraw
1322
        @ unicode supported: text red,0,0,huge,\\u2232
1322
        @ unicode supported: text red,0,0,huge,\\u2232
1323
        @ use command 'string' and 'fontfamily' for a more fine grained control over html5 canvas text element
1323
        @ use command 'string' and 'fontfamily' for a more fine grained control over html5 canvas text element
1324
        @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1324
        @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
Line 1326... Line 1326...
1326
            for(i = 0; i < 5 ;i++){
1326
            for(i = 0; i < 5 ;i++){
1327
                switch(i){
1327
                switch(i){
1328
                    case 0: stroke_color = get_color(infile,0);break;/* font_color == stroke_color name or hex color */
1328
                    case 0: stroke_color = get_color(infile,0);break;/* font_color == stroke_color name or hex color */
1329
                    case 1: double_data[0] = get_real(infile,0);break; /* x */
1329
                    case 1: double_data[0] = get_real(infile,0);break; /* x */
1330
                    case 2: double_data[1] = get_real(infile,0);break; /* y */
1330
                    case 2: double_data[1] = get_real(infile,0);break; /* y */
1331
                    case 3: fly_font = get_string_argument(infile,0);
1331
                    case 3: fly_font = get_string_argument(infile,0);
1332
                            if(strcmp(fly_font,"giant") == 0){
1332
                            if(strcmp(fly_font,"giant") == 0){
1333
                                font_size = (int)(font_size + 24);
1333
                                font_size = (int)(font_size + 24);
1334
                            }
1334
                            }
1335
                            else
1335
                            else
1336
                            {
1336
                            {
1337
                                if(strcmp(fly_font,"huge") == 0){
1337
                                if(strcmp(fly_font,"huge") == 0){
1338
                                    font_size = (int)(font_size + 14);
1338
                                    font_size = (int)(font_size + 14);
1339
                                }
1339
                                }
1340
                                else
1340
                                else
1341
                                {
1341
                                {
1342
                                    if(strcmp(fly_font,"large") == 0){
1342
                                    if(strcmp(fly_font,"large") == 0){
1343
                                        font_size = (int)(font_size + 6);
1343
                                        font_size = (int)(font_size + 6);
1344
                                        }
1344
                                        }
1345
                                        else
1345
                                        else
1346
                                        {
1346
                                        {
1347
                                            if(strcmp(fly_font,"small") == 0){
1347
                                            if(strcmp(fly_font,"small") == 0){
1348
                                                font_size = (int)(font_size - 4);
1348
                                                font_size = (int)(font_size - 4);
1349
                                                if(font_size<0){font_size = 8;}
1349
                                                if(font_size<0){font_size = 8;}
1350
                                        }
1350
                                        }
1351
                                    }
1351
                                    }
1352
                                }
1352
                                }
1353
                            }
1353
                            }
1354
                            break; /* font_size ! */
1354
                            break; /* font_size ! */
1355
                    case 4:
1355
                    case 4:
1356
                        temp = get_string_argument(infile,1);
1356
                        temp = get_string_argument(infile,1);
1357
                        decimals = find_number_of_digits(precision);
1357
                        decimals = find_number_of_digits(precision);
1358
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,14,[%.*f],[%.*f],[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%d,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,0,0,temp,font_size,font_family,use_affine,affine_matrix);
1358
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,14,[%.*f],[%.*f],[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%d,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,0,0,temp,font_size,font_family,use_affine,affine_matrix);
1359
                        click_cnt++;reset();break;
1359
                        click_cnt++;reset();break;
1360
                    default:break;
1360
                    default:break;
Line 1364... Line 1364...
1364
        case FLY_TEXTUP:
1364
        case FLY_TEXTUP:
1365
        /*
1365
        /*
1366
         @ textup fontcolor,x,y,font,text_string
1366
         @ textup fontcolor,x,y,font,text_string
1367
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1367
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1368
         @ font may be described by keywords : giant,huge,normal,small,tiny
1368
         @ font may be described by keywords : giant,huge,normal,small,tiny
1369
         @ use command 'fontsize' to increase base fontsize for the keywords
1369
         @ use command 'fontsize' to increase base fontsize for the keywords
1370
         @ backwards compatible with flydraw
1370
         @ backwards compatible with flydraw
1371
         @ unicode supported: textup red,0,0,huge,\\u2232
1371
         @ unicode supported: textup red,0,0,huge,\\u2232
1372
         @ use command 'stringup' and 'fontfamily' for a more fine grained control over html5 canvas text element
1372
         @ use command 'stringup' and 'fontfamily' for a more fine grained control over html5 canvas text element
1373
         @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1373
         @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1374
        */
1374
        */
1375
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}  
1375
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}
1376
            for(i = 0; i<5 ;i++){
1376
            for(i = 0; i<5 ;i++){
1377
                switch(i){
1377
                switch(i){
1378
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1378
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1379
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1379
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1380
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
1380
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
Line 1400... Line 1400...
1400
                                        }
1400
                                        }
1401
                                    }
1401
                                    }
1402
                                }
1402
                                }
1403
                            }
1403
                            }
1404
                            break; /* font_size ! */
1404
                            break; /* font_size ! */
1405
                    case 4:
1405
                    case 4:
1406
                    decimals = find_number_of_digits(precision);
1406
                    decimals = find_number_of_digits(precision);
1407
                    temp = get_string_argument(infile,1);
1407
                    temp = get_string_argument(infile,1);
1408
                    string_length = snprintf(NULL,0,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
1408
                    string_length = snprintf(NULL,0,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
1409
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1409
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1410
                    snprintf(tmp_buffer,string_length,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
1410
                    snprintf(tmp_buffer,string_length,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
Line 1424... Line 1424...
1424
         @ use correct syntax : 'font style' 'font size'px 'fontfamily'
1424
         @ use correct syntax : 'font style' 'font size'px 'fontfamily'
1425
        */
1425
        */
1426
            font_family = get_string(infile,1);
1426
            font_family = get_string(infile,1);
1427
            break;
1427
            break;
1428
        case STRINGUP:
1428
        case STRINGUP:
1429
        /*
1429
        /*
1430
         @ stringup color,x,y,rotation_degrees,the text string
1430
         @ stringup color,x,y,rotation_degrees,the text string
1431
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1431
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1432
         @ unicode supported: stringup red,0,0,45,\\u2232
1432
         @ unicode supported: stringup red,0,0,45,\\u2232
1433
         @ use a command like 'fontfamily bold 34px Courier' <br />to set fonts on browser that support font change
1433
         @ use a command like 'fontfamily bold 34px Courier' <br />to set fonts on browser that support font change
1434
 
1434
 
1435
        */
1435
        */
Line 1451... Line 1451...
1451
                }
1451
                }
1452
            }
1452
            }
1453
            reset();
1453
            reset();
1454
            break;
1454
            break;
1455
        case STRING:
1455
        case STRING:
1456
        /*
1456
        /*
1457
         @ string color,x,y,the text string
1457
         @ string color,x,y,the text string
1458
         @ may be set "onclick" or "drag xy"
1458
         @ may be set "onclick" or "drag xy"
1459
         @ unicode supported: string red,0,0,\\u2232
1459
         @ unicode supported: string red,0,0,\\u2232
1460
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1460
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1461
        */
1461
        */
1462
            for(i=0;i<5;i++){
1462
            for(i=0;i<5;i++){
1463
                switch(i){
1463
                switch(i){
1464
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1464
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1465
                    case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/
1465
                    case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/
1466
                    case 2: double_data[1] = get_real(infile,0);break; /* y in yrange*/
1466
                    case 2: double_data[1] = get_real(infile,0);break; /* y in yrange*/
1467
                    case 3: decimals = find_number_of_digits(precision);
1467
                    case 3: decimals = find_number_of_digits(precision);
1468
                        temp = get_string_argument(infile,1);
1468
                        temp = get_string_argument(infile,1);
Line 1475... Line 1475...
1475
            }
1475
            }
1476
            break;
1476
            break;
1477
        case MATHML:
1477
        case MATHML:
1478
        /*
1478
        /*
1479
        @ mathml x1,y1,x2,y2,mathml_string
1479
        @ mathml x1,y1,x2,y2,mathml_string
1480
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1480
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1481
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1481
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1482
        @ if inputfields are incorporated in mathml (with id's : id='mathml0',id='mathml1',...id='mathml_n')<br />the user_input values will be read by javascript:read_mathml();<br />attention: if after this mathml-input object other user-interactions are included, these will read mathml too using "read_canvas();"
1482
        @ if inputfields are incorporated in mathml (with id's : id='mathml0',id='mathml1',...id='mathml_n')<br />the user_input values will be read by javascript:read_mathml();<br />attention: if after this mathml-input object other user-interactions are included, these will read mathml too using "read_canvas();"
1483
        @ If other inputfields (command input / command textarea) or userdraw is performed, the function read_canvas() will not read mathml. Use some generic function to read it....
1483
        @ If other inputfields (command input / command textarea) or userdraw is performed, the function read_canvas() will not read mathml. Use some generic function to read it....
1484
       
1484
 
1485
        */
1485
        */
1486
            if( js_function[DRAW_XML] != 1 ){ js_function[DRAW_XML] = 1;}
1486
            if( js_function[DRAW_XML] != 1 ){ js_function[DRAW_XML] = 1;}
1487
            for(i=0;i<5;i++){
1487
            for(i=0;i<5;i++){
1488
                switch(i){
1488
                switch(i){
1489
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1489
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1490
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1490
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1491
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1491
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1492
                    case 3: int_data[3]=y2px(get_real(infile,0)) - int_data[1];break; /* height in x/y-range coord system  -> pixel height */
1492
                    case 3: int_data[3]=y2px(get_real(infile,0)) - int_data[1];break; /* height in x/y-range coord system  -> pixel height */
1493
                    case 4: decimals = find_number_of_digits(precision);
1493
                    case 4: decimals = find_number_of_digits(precision);
1494
                            if(onclick == 1 ){ onclick = click_cnt;click_cnt++;}
1494
                            if(onclick == 1 ){ onclick = click_cnt;click_cnt++;}
1495
                            temp = get_string(infile,1);
1495
                            temp = get_string(infile,1);
1496
                            if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","'"); }
1496
                            if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","'"); }
1497
                            string_length = snprintf(NULL,0,"draw_xml(%d,%d,%d,%d,%d,\"%s\",%d);\n",canvas_root_id,int_data[0],int_data[1],int_data[2],int_data[3],temp,onclick);
1497
                            string_length = snprintf(NULL,0,"draw_xml(%d,%d,%d,%d,%d,\"%s\",%d);\n",canvas_root_id,int_data[0],int_data[1],int_data[2],int_data[3],temp,onclick);
1498
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1498
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1499
                            snprintf(tmp_buffer,string_length,"draw_xml(%d,%d,%d,%d,%d,\"%s\",%d);\n",canvas_root_id,int_data[0],int_data[1],int_data[2],int_data[3],temp,onclick);
1499
                            snprintf(tmp_buffer,string_length,"draw_xml(%d,%d,%d,%d,%d,\"%s\",%d);\n",canvas_root_id,int_data[0],int_data[1],int_data[2],int_data[3],temp,onclick);
1500
                            add_to_buffer(tmp_buffer);
1500
                            add_to_buffer(tmp_buffer);
1501
                            /*
1501
                            /*
1502
                             in case inputs are present , trigger adding the read_mathml()
1502
                             in case inputs are present , trigger adding the read_mathml()
1503
                             if no other reply_format is defined
1503
                             if no other reply_format is defined
1504
                             note: all other reply types will include a reading of elements with id='mathml'+p)
1504
                             note: all other reply types will include a reading of elements with id='mathml'+p)
1505
                             */
1505
                             */
1506
                            if(strstr(temp,"mathml0") != NULL){
1506
                            if(strstr(temp,"mathml0") != NULL){
1507
                             if(reply_format < 1 ){reply_format = 16;} /* no other reply type is defined */
1507
                             if(reply_format < 1 ){reply_format = 16;} /* no other reply type is defined */
Line 1513... Line 1513...
1513
            reset();
1513
            reset();
1514
            break;
1514
            break;
1515
        case HTTP:
1515
        case HTTP:
1516
        /*
1516
        /*
1517
         @http x1,y1,x2,y2,http://some_adress.com
1517
         @http x1,y1,x2,y2,http://some_adress.com
1518
         @an active html-page will be displayed in an "iframe" rectangle left top (x1:y1) , right bottom (x2:y2)
1518
         @an active html-page will be displayed in an "iframe" rectangle left top (x1:y1) , right bottom (x2:y2)
1519
         @do not use interactivity (or mouse) if the mouse needs to be active in the iframe
1519
         @do not use interactivity (or mouse) if the mouse needs to be active in the iframe
1520
         @can not be 'set onclick' or 'drag xy'
1520
         @can not be 'set onclick' or 'drag xy'
1521
        */
1521
        */
1522
            if( js_function[DRAW_HTTP] != 1 ){ js_function[DRAW_HTTP] = 1;}    
1522
            if( js_function[DRAW_HTTP] != 1 ){ js_function[DRAW_HTTP] = 1;}
1523
            for(i=0;i<5;i++){
1523
            for(i=0;i<5;i++){
1524
                switch(i){
1524
                switch(i){
1525
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1525
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1526
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1526
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1527
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1527
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
Line 1542... Line 1542...
1542
        /*
1542
        /*
1543
         @ html x1,y1,x2,y2,html_string
1543
         @ html x1,y1,x2,y2,html_string
1544
         @ all tags are allowed
1544
         @ all tags are allowed
1545
         @ can be set onclick <br />(dragging not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1545
         @ can be set onclick <br />(dragging not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1546
         @ if inputfields are incorporated  (with id's : id='mathml0',id='mathml1',...id='mathml_n')<br />the user_input values will be read by javascript:read_canvas(); <br />If other inputfields (command input / command textarea) or userdraw is performed, these values will NOT be read as well.
1546
         @ if inputfields are incorporated  (with id's : id='mathml0',id='mathml1',...id='mathml_n')<br />the user_input values will be read by javascript:read_canvas(); <br />If other inputfields (command input / command textarea) or userdraw is performed, these values will NOT be read as well.
1547
         
1547
 
1548
         note: uses the same code as 'mathml'
1548
         note: uses the same code as 'mathml'
1549
        */
1549
        */
1550
            break;
1550
            break;
1551
        case X_AXIS_STRINGS:
1551
        case X_AXIS_STRINGS:
1552
        /*
1552
        /*
1553
         @ xaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1553
         @ xaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1554
         @ xaxistext num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1554
         @ xaxistext num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1555
         @ use these x-axis values in stead of default xmin...xmax
1555
         @ use these x-axis values in stead of default xmin...xmax
1556
         @ use command "fontcolor", "fontsize" , "fontfamily" to adjust font <br />defaults: black,12,Ariel
1556
         @ use command "fontcolor", "fontsize" , "fontfamily" to adjust font <br />defaults: black,12,Ariel
1557
         @ if the 'x-axis words' are to big amd will overlap, a simple alternating offset will be applied
1557
         @ if the 'x-axis words' are to big amd will overlap, a simple alternating offset will be applied
1558
         @ example:<br />size 400,400<br />xrange 0,13<br />yrange -100,500<br />axis<br />xaxis 1:january:2:february:3:march:5:may:6:june:7:july:8:august:9:september:10:october:11:november:12:december<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid 1,100,grey,1,4,6,grey
1558
         @ example:<br />size 400,400<br />xrange 0,13<br />yrange -100,500<br />axis<br />xaxis 1:january:2:february:3:march:5:may:6:june:7:july:8:august:9:september:10:october:11:november:12:december<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid 1,100,grey,1,4,6,grey
1559
         @ example:<br />size 400,400<br />xrange -5*pi,5*pi<br />yrange -100,500<br />axis<br />xaxis -4*pi:-4\\u03c0:-3*pi:-3\\u03c0:-2*pi:-2\\u03c0:-1*pi:-\\u03c0:0:0:pi:\\u03c0:2*pi:2\\u03c01:3*pi:3\\u03c0:4*pi:4\\u03c0<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid pi,1,grey,1,3,6,grey
1559
         @ example:<br />size 400,400<br />xrange -5*pi,5*pi<br />yrange -100,500<br />axis<br />xaxis -4*pi:-4\\u03c0:-3*pi:-3\\u03c0:-2*pi:-2\\u03c0:-1*pi:-\\u03c0:0:0:pi:\\u03c0:2*pi:2\\u03c01:3*pi:3\\u03c0:4*pi:4\\u03c0<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid pi,1,grey,1,3,6,grey
1560
        */
1560
        */
1561
            temp = get_string(infile,1);
1561
            temp = get_string(infile,1);
1562
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1562
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1563
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1563
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1564
            fprintf(js_include_file,"x_strings = [\"%s\"];\n ",temp);
1564
            fprintf(js_include_file,"x_strings = [\"%s\"];\n ",temp);
1565
            use_axis_numbering = 1;
1565
            use_axis_numbering = 1;
Line 1576... Line 1576...
1576
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1576
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1577
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1577
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1578
            fprintf(js_include_file,"y_strings = [\"%s\"];\n ",temp);
1578
            fprintf(js_include_file,"y_strings = [\"%s\"];\n ",temp);
1579
            use_axis_numbering = 1;
1579
            use_axis_numbering = 1;
1580
            break;
1580
            break;
1581
         
1581
 
1582
        case AXIS_NUMBERING:
1582
        case AXIS_NUMBERING:
1583
        /*
1583
        /*
1584
            @ axisnumbering
1584
            @ axisnumbering
1585
            @ keyword, no aguments required
1585
            @ keyword, no aguments required
1586
        */
1586
        */
1587
            use_axis_numbering = 1;
1587
            use_axis_numbering = 1;
1588
            break;
1588
            break;
1589
        case AXIS:
1589
        case AXIS:
Line 1599... Line 1599...
1599
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
1599
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
1600
         @ primitive implementation of a 'broken scale' graph...
1600
         @ primitive implementation of a 'broken scale' graph...
1601
         @ not very versatile.
1601
         @ not very versatile.
1602
         @ example:<br />size 400,400<br />xrange 0,10000<br />yrange 0,100<br />sgraph 9000,50,100,10,4,4,grey,blue<br />userinput_xy<br />linewidth 2<br />userdraw segments,red
1602
         @ example:<br />size 400,400<br />xrange 0,10000<br />yrange 0,100<br />sgraph 9000,50,100,10,4,4,grey,blue<br />userinput_xy<br />linewidth 2<br />userdraw segments,red
1603
        */
1603
        */
1604
            if( js_function[DRAW_SGRAPH] != 1 ){ js_function[DRAW_SGRAPH] = 1;}
1604
            if( js_function[DRAW_SGRAPH] != 1 ){ js_function[DRAW_SGRAPH] = 1;}
1605
            for(i = 0 ; i < 8 ;i++){
1605
            for(i = 0 ; i < 8 ;i++){
1606
                switch(i){
1606
                switch(i){
1607
                    case 0:double_data[0] = get_real(infile,0);break;
1607
                    case 0:double_data[0] = get_real(infile,0);break;
1608
                    case 1:double_data[1] = get_real(infile,0);break;
1608
                    case 1:double_data[1] = get_real(infile,0);break;
1609
                    case 2:double_data[2] = get_real(infile,0);break;
1609
                    case 2:double_data[2] = get_real(infile,0);break;
Line 1700... Line 1700...
1700
        /*
1700
        /*
1701
        @ killaffine
1701
        @ killaffine
1702
        @ keyword : resets the transformation matrix to 1,0,0,1,0,0
1702
        @ keyword : resets the transformation matrix to 1,0,0,1,0,0
1703
        */
1703
        */
1704
            use_affine = FALSE;
1704
            use_affine = FALSE;
1705
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");    
1705
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");
1706
            break;
1706
            break;
1707
        case AFFINE:
1707
        case AFFINE:
1708
        /*
1708
        /*
1709
         @affine a,b,c,d,tx,ty
1709
         @affine a,b,c,d,tx,ty
1710
         @ defines a transformation matrix for subsequent objects
1710
         @ defines a transformation matrix for subsequent objects
1711
         @ use keyword 'killaffine' to end the transformation
1711
         @ use keyword 'killaffine' to end the transformation
1712
         @ note 1: only 'draggable' / 'noclick' objects can be transformed.
1712
         @ note 1: only 'draggable' / 'noclick' objects can be transformed.
1713
         @ note 2: do not use 'onclick' or 'drag xy' with tranformation objects : the mouse coordinates do not get transformed (yet)
1713
         @ note 2: do not use 'onclick' or 'drag xy' with tranformation objects : the mouse coordinates do not get transformed (yet)
1714
         @ note 3: no matrix operations on the transformation matrix implemented (yet)
1714
         @ note 3: no matrix operations on the transformation matrix implemented (yet)
1715
         @ a : Scales the drawings horizontally
1715
         @ a : Scales the drawings horizontally
Line 1728... Line 1728...
1728
                    case 4: int_data[0] = (int)(get_real(infile,0));break;
1728
                    case 4: int_data[0] = (int)(get_real(infile,0));break;
1729
                    case 5: int_data[1] = (int)(get_real(infile,1));
1729
                    case 5: int_data[1] = (int)(get_real(infile,1));
1730
                        use_affine = TRUE;
1730
                        use_affine = TRUE;
1731
                        string_length = snprintf(NULL,0,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);
1731
                        string_length = snprintf(NULL,0,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);
1732
                        check_string_length(string_length);affine_matrix = my_newmem(string_length+1);
1732
                        check_string_length(string_length);affine_matrix = my_newmem(string_length+1);
1733
                        snprintf(affine_matrix,string_length,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);    
1733
                        snprintf(affine_matrix,string_length,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);
1734
                    break;
1734
                    break;
1735
                    default: break;
1735
                    default: break;
1736
                }
1736
                }
1737
            }
1737
            }
1738
        break;
1738
        break;
Line 1758... Line 1758...
1758
        */
1758
        */
1759
            use_dashed = TRUE;
1759
            use_dashed = TRUE;
1760
            break;
1760
            break;
1761
        case FILLED:
1761
        case FILLED:
1762
        /*
1762
        /*
1763
        @ keyword "filled"
1763
        @ keyword "filled"
1764
        @ the next 'fillable' object (only) will be filled
1764
        @ the next 'fillable' object (only) will be filled
1765
        @ use command "fillcolor color" to set fillcolor
1765
        @ use command "fillcolor color" to set fillcolor
1766
        @ use command "opacity 0-255,0-255" to set stroke and fill-opacity
1766
        @ use command "opacity 0-255,0-255" to set stroke and fill-opacity
1767
        @ use command "fill x,y,color" or "floodfill x,y,color" to fill the space around (x;y) with color <br />pixel operation implemented in javascript: use with care !
1767
        @ use command "fill x,y,color" or "floodfill x,y,color" to fill the space around (x;y) with color <br />pixel operation implemented in javascript: use with care !
1768
        */
1768
        */
1769
            use_filled = TRUE;
1769
            use_filled = TRUE;
Line 1788... Line 1788...
1788
        @ strokecolor colorname or #hex
1788
        @ strokecolor colorname or #hex
1789
        @ to be used for commands that do not supply a color argument (like command 'linegraph')
1789
        @ to be used for commands that do not supply a color argument (like command 'linegraph')
1790
        */
1790
        */
1791
            stroke_color = get_color(infile,1);
1791
            stroke_color = get_color(infile,1);
1792
            break;
1792
            break;
1793
        case BGIMAGE:
1793
        case BGIMAGE:
1794
        /*
1794
        /*
1795
         @bgimage image_location
1795
         @bgimage image_location
1796
         @use an image as background .<br />(we use the background of 'canvas_div' )
1796
         @use an image as background .<br />(we use the background of 'canvas_div' )
1797
         @the background image will be resized to match "width = xsize" and "height = ysize"
1797
         @the background image will be resized to match "width = xsize" and "height = ysize"
1798
        */
1798
        */
1799
        URL = get_string(infile,1);
1799
        URL = get_string(infile,1);
1800
        fprintf(js_include_file,"<!-- set background image to canvas div -->\ncanvas_div.style.backgroundImage = \"url(%s)\";canvas_div.style.backgroundSize = \"%dpx %dpx\";\n",URL,xsize,ysize);
1800
        fprintf(js_include_file,"<!-- set background image to canvas div -->\ncanvas_div.style.backgroundImage = \"url(%s)\";canvas_div.style.backgroundSize = \"%dpx %dpx\";\n",URL,xsize,ysize);
1801
            break;
1801
            break;
1802
        case BGCOLOR:
1802
        case BGCOLOR:
1803
        /*
1803
        /*
1804
         @bgcolor colorname or #hex
1804
         @bgcolor colorname or #hex
1805
         @use this color as background of the "div" containing the canvas(es)
1805
         @use this color as background of the "div" containing the canvas(es)
1806
        */
1806
        */
1807
        /* [255,255,255]*/
1807
        /* [255,255,255]*/
Line 1822... Line 1822...
1822
        case COPY:
1822
        case COPY:
1823
        /*
1823
        /*
1824
        @ copy x,y,x1,y1,x2,y2,[filename URL]
1824
        @ copy x,y,x1,y1,x2,y2,[filename URL]
1825
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y) in x/y-range
1825
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y) in x/y-range
1826
        @ If x1=y1=x2=y2=-1, the whole [filename URL] is copied.
1826
        @ If x1=y1=x2=y2=-1, the whole [filename URL] is copied.
1827
        @ [filename] is the URL of the image   
1827
        @ [filename] is the URL of the image
1828
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1828
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1829
        @ if command 'drag x/y/xy' is set before command 'copy', the images will be draggable<br />javascript function read_canvas(); will return the x/y coordinate data in xrange/yrange of all -including non draggable- images<br />the command drag is only valuid for the next image<br />draggable / non-draggable images may be mixed
1829
        @ if command 'drag x/y/xy' is set before command 'copy', the images will be draggable<br />javascript function read_canvas(); will return the x/y coordinate data in xrange/yrange of all -including non draggable- images<br />the command drag is only valuid for the next image<br />draggable / non-draggable images may be mixed
1830
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1830
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1831
 
1831
 
1832
        context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1832
        context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1833
        draw_external_image(canvas_type,URL,sx,sy,swidth,sheight,x,y,width,height,drag_drop){
1833
        draw_external_image(canvas_type,URL,sx,sy,swidth,sheight,x,y,width,height,drag_drop){
1834
        */
1834
        */
1835
            for(i = 0 ; i<7;i++){
1835
            for(i = 0 ; i<7;i++){
Line 1846... Line 1846...
1846
                            if( drag_type > -1 ){
1846
                            if( drag_type > -1 ){
1847
                                if( js_function[DRAG_EXTERNAL_IMAGE] != 1 ){ js_function[DRAG_EXTERNAL_IMAGE] = 1;}
1847
                                if( js_function[DRAG_EXTERNAL_IMAGE] != 1 ){ js_function[DRAG_EXTERNAL_IMAGE] = 1;}
1848
                                if(reply_format < 1 ){reply_format = 20;}
1848
                                if(reply_format < 1 ){reply_format = 20;}
1849
                                string_length = snprintf(NULL,0,"drag_external_image(\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d);\n",URL,int_data[2],int_data[3],int_data[6],int_data[7],int_data[0],int_data[1],int_data[6],int_data[7],ext_img_cnt,1);
1849
                                string_length = snprintf(NULL,0,"drag_external_image(\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d);\n",URL,int_data[2],int_data[3],int_data[6],int_data[7],int_data[0],int_data[1],int_data[6],int_data[7],ext_img_cnt,1);
1850
                                check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1850
                                check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1851
                                snprintf(tmp_buffer,string_length,"drag_external_image(\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d);\n",URL,int_data[2],int_data[3],int_data[6],int_data[7],int_data[0],int_data[1],int_data[6],int_data[7],ext_img_cnt,1);                       
1851
                                snprintf(tmp_buffer,string_length,"drag_external_image(\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d);\n",URL,int_data[2],int_data[3],int_data[6],int_data[7],int_data[0],int_data[1],int_data[6],int_data[7],ext_img_cnt,1);
1852
                                drag_type = -1;
1852
                                drag_type = -1;
1853
                                ext_img_cnt++;
1853
                                ext_img_cnt++;
1854
                            }
1854
                            }
1855
                            else
1855
                            else
1856
                            {
1856
                            {
Line 1872... Line 1872...
1872
/*
1872
/*
1873
context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1873
context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1874
img     Specifies the image, canvas, or video element to use
1874
img     Specifies the image, canvas, or video element to use
1875
sx      The x coordinate where to start clipping : x1 = int_data[0]
1875
sx      The x coordinate where to start clipping : x1 = int_data[0]
1876
sy      The y coordinate where to start clipping : x2 = int_data[1]
1876
sy      The y coordinate where to start clipping : x2 = int_data[1]
1877
swidth  The width of the clipped image : int_data[2] - int_data[0]
1877
swidth  The width of the clipped image : int_data[2] - int_data[0]
1878
sheight The height of the clipped image : int_data[3] - int_data[1]
1878
sheight The height of the clipped image : int_data[3] - int_data[1]
1879
x       The x coordinate where to place the image on the canvas : dx1 = int_data[4]
1879
x       The x coordinate where to place the image on the canvas : dx1 = int_data[4]
1880
y       The y coordinate where to place the image on the canvas : dy1 = int_data[5]
1880
y       The y coordinate where to place the image on the canvas : dy1 = int_data[5]
1881
width   The width of the image to use (stretch or reduce the image) : dx2 - dx1 = int_data[6]
1881
width   The width of the image to use (stretch or reduce the image) : dx2 - dx1 = int_data[6]
1882
height  The height of the image to use (stretch or reduce the image) : dy2 - dy1 = int_data[7]
1882
height  The height of the image to use (stretch or reduce the image) : dy2 - dy1 = int_data[7]
1883
*/
1883
*/
1884
        case COPYRESIZED:
1884
        case COPYRESIZED:
1885
        /*
1885
        /*
1886
        @ copyresized x1,y2,x2,y2,dx1,dy1,dx2,dy2,image_file_url
1886
        @ copyresized x1,y2,x2,y2,dx1,dy1,dx2,dy2,image_file_url
1887
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [ filename], <br />possibly resized,<br />to the region of (dx1,dy1) to (dx2,dy2) in x/y-range
1887
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [ filename], <br />possibly resized,<br />to the region of (dx1,dy1) to (dx2,dy2) in x/y-range
1888
        @ If x1=y1=x2=y2=-1, the whole [filename / URL ] is copied and resized.
1888
        @ If x1=y1=x2=y2=-1, the whole [filename / URL ] is copied and resized.
1889
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1889
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1890
        @ if command 'drag x/y/xy' is set before command 'copy', the images will be draggable<br />javascript function read_canvas(); will return the x/y coordinate data in xrange/yrange of all -including non draggable- images<br />the command drag is only valuid for the next image<br />draggable / non-draggable images may be mixed
1890
        @ if command 'drag x/y/xy' is set before command 'copy', the images will be draggable<br />javascript function read_canvas(); will return the x/y coordinate data in xrange/yrange of all -including non draggable- images<br />the command drag is only valuid for the next image<br />draggable / non-draggable images may be mixed
1891
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1891
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1892
        */
1892
        */
1893
            for(i = 0 ; i<9;i++){
1893
            for(i = 0 ; i<9;i++){
1894
                switch(i){
1894
                switch(i){
1895
                    case 0: int_data[0] = (int)(get_real(infile,0));break; /* x1 */
1895
                    case 0: int_data[0] = (int)(get_real(infile,0));break; /* x1 */
1896
                    case 1: int_data[1] = (int)(get_real(infile,0));break; /* y1 */
1896
                    case 1: int_data[1] = (int)(get_real(infile,0));break; /* y1 */
Line 1934... Line 1934...
1934
        @ example: inputstyle color:blue;font-weight:bold;font-style:italic;font-size:16pt
1934
        @ example: inputstyle color:blue;font-weight:bold;font-style:italic;font-size:16pt
1935
        */
1935
        */
1936
            input_style = get_string(infile,1);
1936
            input_style = get_string(infile,1);
1937
            break;
1937
            break;
1938
        case INPUT:
1938
        case INPUT:
1939
        /*
1939
        /*
1940
         @ input x,y,size,editable,value
1940
         @ input x,y,size,editable,value
1941
         @ to set inputfield "readonly", use editable = 0
1941
         @ to set inputfield "readonly", use editable = 0
1942
         @ only active inputfields (editable = 1) will be read with read_canvas();
1942
         @ only active inputfields (editable = 1) will be read with read_canvas();
1943
         @ may be further controlled by "inputstyle" (inputcss is not yet implemented...)
1943
         @ may be further controlled by "inputstyle" (inputcss is not yet implemented...)
1944
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1944
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1945
        */
1945
        */
1946
        if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}    
1946
        if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}
1947
            for(i = 0 ; i<5;i++){
1947
            for(i = 0 ; i<5;i++){
1948
                switch(i){
1948
                switch(i){
1949
                    case 0: int_data[0]=x2px(get_real(infile,0));break;/* x in px */
1949
                    case 0: int_data[0]=x2px(get_real(infile,0));break;/* x in px */
1950
                    case 1: int_data[1]=y2px(get_real(infile,0));break;/* y in px */
1950
                    case 1: int_data[1]=y2px(get_real(infile,0));break;/* y in px */
1951
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break; /* size */
1951
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break; /* size */
1952
                    case 3: if( get_real(infile,1) >0){int_data[3] = 1;}else{int_data[3] = 0;};break; /* readonly */
1952
                    case 3: if( get_real(infile,1) >0){int_data[3] = 1;}else{int_data[3] = 0;};break; /* readonly */
1953
                    case 4:
1953
                    case 4:
1954
                            temp = get_string_argument(infile,1);
1954
                            temp = get_string_argument(infile,1);
1955
                            string_length = snprintf(NULL,0,  "draw_inputs(%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],input_style,temp);
1955
                            string_length = snprintf(NULL,0,  "draw_inputs(%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],input_style,temp);
1956
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1956
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1957
                            snprintf(tmp_buffer,string_length,"draw_inputs(%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],input_style,temp);
1957
                            snprintf(tmp_buffer,string_length,"draw_inputs(%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],input_style,temp);
1958
                            add_to_buffer(tmp_buffer);
1958
                            add_to_buffer(tmp_buffer);
Line 1962... Line 1962...
1962
            }
1962
            }
1963
            if(reply_format < 1 ){reply_format = 15;}
1963
            if(reply_format < 1 ){reply_format = 15;}
1964
            reset();
1964
            reset();
1965
            break;
1965
            break;
1966
        case TEXTAREA:
1966
        case TEXTAREA:
1967
        /*
1967
        /*
1968
         @ textarea x,y,cols,rows,readonly,value
1968
         @ textarea x,y,cols,rows,readonly,value
1969
         @ may be further controlled by "inputstyle"
1969
         @ may be further controlled by "inputstyle"
1970
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1970
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1971
        */
1971
        */
1972
            if( js_function[DRAW_TEXTAREAS] != 1 ){ js_function[DRAW_TEXTAREAS] = 1;}  
1972
            if( js_function[DRAW_TEXTAREAS] != 1 ){ js_function[DRAW_TEXTAREAS] = 1;}
1973
            for(i = 0 ; i<6;i++){
1973
            for(i = 0 ; i<6;i++){
1974
                switch(i){
1974
                switch(i){
1975
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in px */
1975
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in px */
1976
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in px */
1976
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in px */
1977
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break;/* cols */
1977
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break;/* cols */
Line 1997... Line 1997...
1997
        */
1997
        */
1998
            precision = (int) (get_real(infile,1));
1998
            precision = (int) (get_real(infile,1));
1999
            break;
1999
            break;
2000
        case SETLIMITS:
2000
        case SETLIMITS:
2001
        /*
2001
        /*
2002
            @setlimits
2002
            @setlimits
2003
            @keyword : if set, it will produce 4 inputfields for 'xmin,xmax,ymin,ymax' and an 'ok' button
2003
            @keyword : if set, it will produce 4 inputfields for 'xmin,xmax,ymin,ymax' and an 'ok' button
2004
            @may be used for inputfield based zooming / panning
2004
            @may be used for inputfield based zooming / panning
2005
            @note:the input value will not be checked on validity
2005
            @note:the input value will not be checked on validity
2006
        */
2006
        */
2007
            add_setlimits(js_include_file,canvas_root_id);
2007
            add_setlimits(js_include_file,canvas_root_id);
2008
            /* add_setlimits provides 'fprintf(js_include_file,"use_pan_and_zoom = 1;");' */
2008
            /* add_setlimits provides 'fprintf(js_include_file,"use_pan_and_zoom = 1;");' */
2009
            use_pan_and_zoom = TRUE;
2009
            use_pan_and_zoom = TRUE;
2010
            done = TRUE;
2010
            done = TRUE;
Line 2014... Line 2014...
2014
         @ zoom button_color
2014
         @ zoom button_color
2015
         @ introduce a controlpanel at the lower right corner
2015
         @ introduce a controlpanel at the lower right corner
2016
         @ giving six 15x15pixel 'active' rectangle areas<br />(for x,leftarrow,rightarrow,uparrow,downarrow and a '-' and a '+' sign ) for zooming and/or panning of the image
2016
         @ giving six 15x15pixel 'active' rectangle areas<br />(for x,leftarrow,rightarrow,uparrow,downarrow and a '-' and a '+' sign ) for zooming and/or panning of the image
2017
         @ the 'x' symbol will do a 'location.reload' of the page, and thus reset all canvas drawings.
2017
         @ the 'x' symbol will do a 'location.reload' of the page, and thus reset all canvas drawings.
2018
         @ choose an appropriate colour, so the small 'x,arrows,-,+' are clearly visible
2018
         @ choose an appropriate colour, so the small 'x,arrows,-,+' are clearly visible
2019
         @ command 'opacity' may be used to set stroke_opacity of 'buttons
2019
         @ command 'opacity' may be used to set stroke_opacity of 'buttons
2020
         @ NOTE: only objects that may be set draggable / clickable will be zoomed / panned
2020
         @ NOTE: only objects that may be set draggable / clickable will be zoomed / panned
2021
         @ NOTE: when an object is dragged, zooming / panning will cause the coordinates to be reset to the original position :( <br />e.g. dragging / panning will get lost. (array with 'drag data' is erased)<br />This is a design flaw and not a feature !!
2021
         @ NOTE: when an object is dragged, zooming / panning will cause the coordinates to be reset to the original position :( <br />e.g. dragging / panning will get lost. (array with 'drag data' is erased)<br />This is a design flaw and not a feature !!
2022
        */
2022
        */
2023
            fprintf(js_include_file,"use_pan_and_zoom = 1;");
2023
            fprintf(js_include_file,"use_pan_and_zoom = 1;");
2024
            use_pan_and_zoom = TRUE;
2024
            use_pan_and_zoom = TRUE;
Line 2034... Line 2034...
2034
        case ONCLICK:
2034
        case ONCLICK:
2035
        /*
2035
        /*
2036
         @ onclick
2036
         @ onclick
2037
         @ keyword, no arguments
2037
         @ keyword, no arguments
2038
         @ if the next object is clicked, it's 'object sequence number' in fly script is returned <br /> by javascript:read_canvas();
2038
         @ if the next object is clicked, it's 'object sequence number' in fly script is returned <br /> by javascript:read_canvas();
2039
         @ Line based object will show an increase in linewidth<br />Font based objects will show the text in 'bold' when clicked.
2039
         @ Line based object will show an increase in linewidth<br />Font based objects will show the text in 'bold' when clicked.
2040
         @ NOTE: not all objects  may be set clickable
2040
         @ NOTE: not all objects  may be set clickable
2041
        */
2041
        */
2042
           
2042
 
2043
            onclick = 1;
2043
            onclick = 1;
2044
            break;
2044
            break;
2045
        case DRAG:
2045
        case DRAG:
2046
        /*
2046
        /*
2047
         @ drag [x][y][xy]
2047
         @ drag [x][y][xy]
2048
         @ the next object will be draggable in x / y / xy direction
2048
         @ the next object will be draggable in x / y / xy direction
2049
         @ the displacement can be read by 'javascript:read_dragdrop();'
2049
         @ the displacement can be read by 'javascript:read_dragdrop();'
2050
         @ in case of external images (commands copy / copyresized) the external image can be set draggable ; always xy. <br />The function javascript;read_canvas() will return the xy-coordinates of all images.
2050
         @ in case of external images (commands copy / copyresized) the external image can be set draggable ; always xy. <br />The function javascript;read_canvas() will return the xy-coordinates of all images.
2051
         @ NOTE: in case an object is dragged , zooming or panning will cause the coordinates to be reset to the original position :( <br />e.g. dragging / panning will get lost. (array with 'drag data' is erased)<br />This is a design flaw and not a feature !!
2051
         @ NOTE: in case an object is dragged , zooming or panning will cause the coordinates to be reset to the original position :( <br />e.g. dragging / panning will get lost. (array with 'drag data' is erased)<br />This is a design flaw and not a feature !!
2052
        */
2052
        */
2053
            temp = get_string(infile,1);
2053
            temp = get_string(infile,1);
2054
            if(strstr(temp,"xy") != NULL ){
2054
            if(strstr(temp,"xy") != NULL ){
2055
                drag_type = 0;
2055
                drag_type = 0;
2056
            }
2056
            }
2057
            else
2057
            else
2058
            {
2058
            {
2059
                if(strstr(temp,"x") != NULL ){
2059
                if(strstr(temp,"x") != NULL ){
2060
                    drag_type = 1;
2060
                    drag_type = 1;
2061
                }
2061
                }
2062
                else
2062
                else
2063
                {
2063
                {
2064
                    drag_type = 2;
2064
                    drag_type = 2;
Line 2118... Line 2118...
2118
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y in x/y-range coord system  -> pixel */
2118
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y in x/y-range coord system  -> pixel */
2119
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* pixel width */
2119
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* pixel width */
2120
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* height pixel height */
2120
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* height pixel height */
2121
                    case 4: int_data[4] = (int) (get_real(infile,0)); if(int_data[4] != TRUE){int_data[4] = FALSE;} break; /* loop boolean */
2121
                    case 4: int_data[4] = (int) (get_real(infile,0)); if(int_data[4] != TRUE){int_data[4] = FALSE;} break; /* loop boolean */
2122
                    case 5: int_data[5] = (int) (get_real(infile,0)); if(int_data[5] != TRUE){int_data[5] = FALSE;} break; /* visible boolean */
2122
                    case 5: int_data[5] = (int) (get_real(infile,0)); if(int_data[5] != TRUE){int_data[5] = FALSE;} break; /* visible boolean */
2123
                    case 6:
2123
                    case 6:
2124
                    temp = get_string(infile,1);
2124
                    temp = get_string(infile,1);
2125
                    if( strstr(temp,".mp3") != 0 ){ temp = str_replace(temp,".mp3","");}
2125
                    if( strstr(temp,".mp3") != 0 ){ temp = str_replace(temp,".mp3","");}
2126
                    if( strstr(temp,".ogg") != 0 ){ temp = str_replace(temp,".ogg","");}
2126
                    if( strstr(temp,".ogg") != 0 ){ temp = str_replace(temp,".ogg","");}
2127
                    string_length = snprintf(NULL,0,  "draw_audio(%d,%d,%d,%d,%d,%d,%d,\"%s.ogg\",\"%s.mp3\");\n",canvas_root_id,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],int_data[5],temp,temp);
2127
                    string_length = snprintf(NULL,0,  "draw_audio(%d,%d,%d,%d,%d,%d,%d,\"%s.ogg\",\"%s.mp3\");\n",canvas_root_id,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],int_data[5],temp,temp);
2128
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2128
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
Line 2176... Line 2176...
2176
                    case 4: stroke_color = get_color(infile,1);
2176
                    case 4: stroke_color = get_color(infile,1);
2177
                    /* draw_hatchfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2177
                    /* draw_hatchfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2178
                    string_length = snprintf(NULL,0,  "draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2178
                    string_length = snprintf(NULL,0,  "draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2179
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2179
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2180
                    snprintf(tmp_buffer,string_length,"draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2180
                    snprintf(tmp_buffer,string_length,"draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2181
                    add_to_buffer(tmp_buffer);
2181
                    add_to_buffer(tmp_buffer);
2182
                    break;
2182
                    break;
2183
                    default:break;
2183
                    default:break;
2184
                }
2184
                }
2185
            }
2185
            }
2186
            reset();
2186
            reset();
2187
        break;
2187
        break;
2188
        case DIAMONDFILL:
2188
        case DIAMONDFILL:
2189
        /*
2189
        /*
2190
        @ diamondfill x0,y0,dx,dy,color
2190
        @ diamondfill x0,y0,dx,dy,color
2191
        @ x0,y0 in xrange / yrange
2191
        @ x0,y0 in xrange / yrange
2192
        @ distances dx,dy in pixels
2192
        @ distances dx,dy in pixels
2193
        */
2193
        */
2194
            if( js_function[DRAW_DIAMONDFILL] != 1 ){ js_function[DRAW_DIAMONDFILL] = 1;}
2194
            if( js_function[DRAW_DIAMONDFILL] != 1 ){ js_function[DRAW_DIAMONDFILL] = 1;}
2195
            for(i=0;i<5;i++){
2195
            for(i=0;i<5;i++){
2196
                switch(i){
2196
                switch(i){
2197
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2197
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2198
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2198
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2199
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2199
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2200
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
2200
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
Line 2209... Line 2209...
2209
                }
2209
                }
2210
            }
2210
            }
2211
            reset();
2211
            reset();
2212
        break;
2212
        break;
2213
        case GRIDFILL:
2213
        case GRIDFILL:
2214
        /*
2214
        /*
2215
        @ gridfill x0,y0,dx,dy,color
2215
        @ gridfill x0,y0,dx,dy,color
2216
        @ x0,y0 in xrange / yrange
2216
        @ x0,y0 in xrange / yrange
2217
        @ distances dx,dy in pixels
2217
        @ distances dx,dy in pixels
2218
        */
2218
        */
2219
            if( js_function[DRAW_GRIDFILL] != 1 ){ js_function[DRAW_GRIDFILL] = 1;}
2219
            if( js_function[DRAW_GRIDFILL] != 1 ){ js_function[DRAW_GRIDFILL] = 1;}
2220
            for(i=0;i<5;i++){
2220
            for(i=0;i<5;i++){
2221
                switch(i){
2221
                switch(i){
2222
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2222
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2223
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2223
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2224
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2224
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2225
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
2225
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
2226
                    case 4: stroke_color = get_color(infile,1);
2226
                    case 4: stroke_color = get_color(infile,1);
2227
                    /* draw_gridfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2227
                    /* draw_gridfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2228
                    string_length = snprintf(NULL,0,  "draw_gridfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2228
                    string_length = snprintf(NULL,0,  "draw_gridfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2229
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2229
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
Line 2253... Line 2253...
2253
                    /* draw_dotfill(ctx,x0,y0,dx,dy,radius,color,opacity,xsize,ysize) */
2253
                    /* draw_dotfill(ctx,x0,y0,dx,dy,radius,color,opacity,xsize,ysize) */
2254
                    string_length = snprintf(NULL,0,  "draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2254
                    string_length = snprintf(NULL,0,  "draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2255
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2255
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2256
                    snprintf(tmp_buffer,string_length,"draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2256
                    snprintf(tmp_buffer,string_length,"draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2257
                    add_to_buffer(tmp_buffer);
2257
                    add_to_buffer(tmp_buffer);
2258
                    break;
2258
                    break;
2259
                    default:break;
2259
                    default:break;
2260
                }
2260
                }
2261
            }
2261
            }
2262
            reset();
2262
            reset();
2263
        break;
2263
        break;
2264
        case IMAGEFILL:
2264
        case IMAGEFILL:
2265
        /*
2265
        /*
2266
        @ imagefill dx,dy,image_url
2266
        @ imagefill dx,dy,image_url
2267
        @ The next suitable <b>filled object</b> will be filled with "image_url" tiled
2267
        @ The next suitable <b>filled object</b> will be filled with "image_url" tiled
Line 2286... Line 2286...
2286
            }
2286
            }
2287
        break;
2287
        break;
2288
        case FILLTOBORDER:
2288
        case FILLTOBORDER:
2289
        /*
2289
        /*
2290
        @ filltoborder x,y,bordercolor,color
2290
        @ filltoborder x,y,bordercolor,color
2291
        @ fill the region  of point (x:y) bounded by 'bordercolor' with color 'color'
2291
        @ fill the region  of point (x:y) bounded by 'bordercolor' with color 'color'
2292
        @ any other color will not act as border to the bucket fill
2292
        @ any other color will not act as border to the bucket fill
2293
        @ use this command  after all boundary objects are declared.
2293
        @ use this command  after all boundary objects are declared.
2294
        @ NOTE: filltoborder is a very (client) cpu intensive operation!<br />filling is done pixel by pixel<br/>e.g. image size of 400x400 uses 160000 pixels : each pixel contains 4 data (R,G,B,Opacity) = 640000 data.<br />on every data a few operations / comparisons are done...<br />So have pity on your students CPU..
2294
        @ NOTE: filltoborder is a very (client) cpu intensive operation!<br />filling is done pixel by pixel<br/>e.g. image size of 400x400 uses 160000 pixels : each pixel contains 4 data (R,G,B,Opacity) = 640000 data.<br />on every data a few operations / comparisons are done...<br />So have pity on your students CPU..
2295
        */
2295
        */
2296
            for(i=0 ;i < 4 ; i++){
2296
            for(i=0 ;i < 4 ; i++){
Line 2335... Line 2335...
2335
                           }
2335
                           }
2336
                           decimals = find_number_of_digits(precision);/*floodfill(interaction,x,y,[R,G,B,A]) */
2336
                           decimals = find_number_of_digits(precision);/*floodfill(interaction,x,y,[R,G,B,A]) */
2337
                           string_length = snprintf(NULL,0,  "floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2337
                           string_length = snprintf(NULL,0,  "floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2338
                           check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2338
                           check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2339
                           snprintf(tmp_buffer,string_length,"floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2339
                           snprintf(tmp_buffer,string_length,"floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2340
                           add_to_buffer(tmp_buffer);
2340
                           add_to_buffer(tmp_buffer);
2341
                           break;
2341
                           break;
2342
                    default:break;
2342
                    default:break;
2343
                    }
2343
                    }
2344
                }
2344
                }
2345
        break;
2345
        break;
Line 2444... Line 2444...
2444
        case LEGENDCOLORS:
2444
        case LEGENDCOLORS:
2445
        /*
2445
        /*
2446
        @ legendcolors color1:color2:color3:...:color_n
2446
        @ legendcolors color1:color2:color3:...:color_n
2447
        @ will be used to colour a legend
2447
        @ will be used to colour a legend
2448
        @ make sure the number of colours match the number of legend items
2448
        @ make sure the number of colours match the number of legend items
2449
        @ command 'legend' in case of 'piechart' and 'barchart' will use these colours per default (no need to specify 'legendcolors'
2449
        @ command 'legend' in case of 'piechart' and 'barchart' will use these colours per default (no need to specify 'legendcolors'
2450
        */
2450
        */
2451
            temp = get_string(infile,1);
2451
            temp = get_string(infile,1);
2452
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2452
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2453
            fprintf(js_include_file,"var legendcolors%d = [\"%s\"];",canvas_root_id,temp);
2453
            fprintf(js_include_file,"var legendcolors%d = [\"%s\"];",canvas_root_id,temp);
2454
            break;
2454
            break;
2455
        case LEGEND:
2455
        case LEGEND:
2456
        /*
2456
        /*
2457
        @ legend string1:string2:string3....string_n
2457
        @ legend string1:string2:string3....string_n
2458
        @ will be used to create a legend for a graph
2458
        @ will be used to create a legend for a graph
2459
        @ also see command 'piechart'  
2459
        @ also see command 'piechart'
2460
        */
2460
        */
2461
            temp = get_string(infile,1);
2461
            temp = get_string(infile,1);
2462
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2462
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2463
            fprintf(js_include_file,"var legend%d = [\"%s\"];",canvas_root_id,temp);
2463
            fprintf(js_include_file,"var legend%d = [\"%s\"];",canvas_root_id,temp);
2464
            break;
2464
            break;
2465
        case XLABEL:
2465
        case XLABEL:
2466
        /*
2466
        /*
2467
        @ xlabel some_string
2467
        @ xlabel some_string
2468
        @ will be used to create a label for the x-axis (label is in quadrant I)
2468
        @ will be used to create a label for the x-axis (label is in quadrant I)
2469
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2469
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2470
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2470
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2471
        */
2471
        */
2472
            temp = get_string(infile,1);
2472
            temp = get_string(infile,1);
2473
            fprintf(js_include_file,"var xaxislabel = \"%s\";",temp);
2473
            fprintf(js_include_file,"var xaxislabel = \"%s\";",temp);
2474
            break;
2474
            break;
2475
        case YLABEL:
2475
        case YLABEL:
2476
        /*
2476
        /*
2477
        @ ylabel some_string
2477
        @ ylabel some_string
2478
        @ will be used to create a (vertical) label for the y-axis (label is in quadrant I)
2478
        @ will be used to create a (vertical) label for the y-axis (label is in quadrant I)
2479
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2479
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2480
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2480
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2481
        */
2481
        */
2482
            temp = get_string(infile,1);
2482
            temp = get_string(infile,1);
2483
            fprintf(js_include_file,"var yaxislabel = \"%s\";",temp);
2483
            fprintf(js_include_file,"var yaxislabel = \"%s\";",temp);
2484
            break;
2484
            break;
2485
        case LINEGRAPH: /* scheme: var linegraph_0 = [ 'stroke_color','line_width','use_dashed' ,'dashtype0','dashtype1','x1','y1',...,'x_n','y_n'];*/
2485
        case LINEGRAPH: /* scheme: var linegraph_0 = [ 'stroke_color','line_width','use_dashed' ,'dashtype0','dashtype1','x1','y1',...,'x_n','y_n'];*/
Line 2490... Line 2490...
2490
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2490
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2491
        @ use command 'legend' to provide an optional legend in right-top-corner
2491
        @ use command 'legend' to provide an optional legend in right-top-corner
2492
        @ also see command 'piechart'
2492
        @ also see command 'piechart'
2493
        @ multiple linegraphs may be used in a single plot
2493
        @ multiple linegraphs may be used in a single plot
2494
        @ <ul><li>use command 'strokecolor' before command 'linegraph' to set the color of this graph</li><li>use command 'linewidth' before command 'linegraph' to set linewidth of this graph</li><li>use command 'dashed' before command 'linegraph' to set dashing of the graph</li><li>if dashing is set, use command 'dashtype' before command 'linegraph' to set the type of dashing of the graph</li></ul>
2494
        @ <ul><li>use command 'strokecolor' before command 'linegraph' to set the color of this graph</li><li>use command 'linewidth' before command 'linegraph' to set linewidth of this graph</li><li>use command 'dashed' before command 'linegraph' to set dashing of the graph</li><li>if dashing is set, use command 'dashtype' before command 'linegraph' to set the type of dashing of the graph</li></ul>
2495
        */    
2495
        */
2496
            temp = get_string(infile,1);
2496
            temp = get_string(infile,1);
2497
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2497
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2498
            fprintf(js_include_file,"var linegraph_%d = [\"%s\",\"%d\",\"%d\",\"%d\",\"%d\",\"%s\"];",linegraph_cnt,stroke_color,line_width,use_dashed,dashtype[0],dashtype[1],temp);
2498
            fprintf(js_include_file,"var linegraph_%d = [\"%s\",\"%d\",\"%d\",\"%d\",\"%d\",\"%s\"];",linegraph_cnt,stroke_color,line_width,use_dashed,dashtype[0],dashtype[1],temp);
2499
            linegraph_cnt++;
2499
            linegraph_cnt++;
2500
            reset();
2500
            reset();
Line 2553... Line 2553...
2553
                            }
2553
                            }
2554
                     break;
2554
                     break;
2555
                     default: canvas_error("interactive must be set 0,1 or 2");break;
2555
                     default: canvas_error("interactive must be set 0,1 or 2");break;
2556
                }
2556
                }
2557
                break;
2557
                break;
2558
                case 8:
2558
                case 8:
2559
                        temp = get_string(infile,1);
2559
                        temp = get_string(infile,1);
2560
                        if( strstr( temp,",") != 0 ){ temp = str_replace(temp,",","\",\""); }
2560
                        if( strstr( temp,",") != 0 ){ temp = str_replace(temp,",","\",\""); }
2561
                        if( strlen(temp) < 1 ){temp = ",\"\",\"\",\"\",\"\",\"\"";}
2561
                        if( strlen(temp) < 1 ){temp = ",\"\",\"\",\"\",\"\",\"\"";}
2562
                        string_length = snprintf(NULL,0,"clocks%d = new clock(%d,%d,%d,%d,%d,%d,%d,%d,\"%s\");\n",clock_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],int_data[5],int_data[6],int_data[7],temp);
2562
                        string_length = snprintf(NULL,0,"clocks%d = new clock(%d,%d,%d,%d,%d,%d,%d,%d,\"%s\");\n",clock_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],int_data[5],int_data[6],int_data[7],temp);
2563
                        check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2563
                        check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
Line 2574... Line 2574...
2574
        @ barchart x_1:y_1:color_1:x_2:y_2:color_2:...x_n:y_n:color_n
2574
        @ barchart x_1:y_1:color_1:x_2:y_2:color_2:...x_n:y_n:color_n
2575
        @ will be used to create a legend for bar graph
2575
        @ will be used to create a legend for bar graph
2576
        @ may only to be used together with command 'grid'
2576
        @ may only to be used together with command 'grid'
2577
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2577
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2578
        @ use command 'legend' to provide an optional legend in right-top-corner
2578
        @ use command 'legend' to provide an optional legend in right-top-corner
2579
        @ also see command 'piechart'  
2579
        @ also see command 'piechart'
2580
        */
2580
        */
2581
            temp = get_string(infile,1);
2581
            temp = get_string(infile,1);
2582
            if( strstr( temp,":" ) != 0 ){ temp = str_replace(temp,":","\",\""); }
2582
            if( strstr( temp,":" ) != 0 ){ temp = str_replace(temp,":","\",\""); }
2583
            fprintf(js_include_file,"var barchart%d = [\"%s\"];",canvas_root_id,temp);
2583
            fprintf(js_include_file,"var barchart%d = [\"%s\"];",canvas_root_id,temp);
2584
            reset();
2584
            reset();
Line 2592... Line 2592...
2592
        @ example data+colorlist : 132:red:23565:green:323:black:234324:orange:23434:yellow:2543:white
2592
        @ example data+colorlist : 132:red:23565:green:323:black:234324:orange:23434:yellow:2543:white
2593
        @ the number of colors must match the number of data.
2593
        @ the number of colors must match the number of data.
2594
        @ use command "opacity 0-255,0-255" to adjust fill_opacity of colours
2594
        @ use command "opacity 0-255,0-255" to adjust fill_opacity of colours
2595
        @ use command "legend string1:string2:...:string_n" to automatically create a legend <br />using the same colours as pie segments<br />unicode allowed in legend<br />expect javascript trouble if the amount of 'pie-slices', 'pie-colours' 'pie-legend-titles' do not match<br />a javascript console is your best friend...
2595
        @ use command "legend string1:string2:...:string_n" to automatically create a legend <br />using the same colours as pie segments<br />unicode allowed in legend<br />expect javascript trouble if the amount of 'pie-slices', 'pie-colours' 'pie-legend-titles' do not match<br />a javascript console is your best friend...
2596
        */
2596
        */
2597
            if( js_function[DRAW_PIECHART] != 1 ){ js_function[DRAW_PIECHART] = 1;}    
2597
            if( js_function[DRAW_PIECHART] != 1 ){ js_function[DRAW_PIECHART] = 1;}
2598
            for(i=0;i<5;i++){
2598
            for(i=0;i<5;i++){
2599
                switch(i){
2599
                switch(i){
2600
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2600
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2601
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2601
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2602
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
2602
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
Line 2639... Line 2639...
2639
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2639
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2640
         @ ymajor is the major step on the y-axis; yminor is the divisor for the y-step
2640
         @ ymajor is the major step on the y-axis; yminor is the divisor for the y-step
2641
         @ the linewidth is set using command 'linewidth int'
2641
         @ the linewidth is set using command 'linewidth int'
2642
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2642
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2643
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number'
2643
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number'
2644
         @ the x/y- axis numbering is triggered by keyword 'axisnumbering'<ul><li>use command 'precision' before 'xlogscale' command to set the precision (decimals) of the axis numbering</li><li>use commands 'xlabel some_text' and/or 'ylabel some_text' for text on axis : use command 'fontsize int' to set the fontsize (default 12px)</li><li>use command 'fontfamily fnt_family_string' to set the fonts for axis-numbering</li><li>use command'fontcolor' to set the colour</li></ul>
2644
         @ the x/y- axis numbering is triggered by keyword 'axisnumbering'<ul><li>use command 'precision' before 'xlogscale' command to set the precision (decimals) of the axis numbering</li><li>use commands 'xlabel some_text' and/or 'ylabel some_text' for text on axis : use command 'fontsize int' to set the fontsize (default 12px)</li><li>use command 'fontfamily fnt_family_string' to set the fonts for axis-numbering</li><li>use command'fontcolor' to set the colour</li></ul>
2645
         @ note: the complete canvas will be used for the 'log paper'
2645
         @ note: the complete canvas will be used for the 'log paper'
2646
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2646
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2647
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2647
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2648
         @ note: when using something like 'xrange 0.0001,0.01'...combined with commands 'mouse color,fontsize' and/or 'userdraw type,color'...<br /> make sure the precision is set accordingly (eg command 'precision 10000')  
2648
         @ note: when using something like 'xrange 0.0001,0.01'...combined with commands 'mouse color,fontsize' and/or 'userdraw type,color'...<br /> make sure the precision is set accordingly (eg command 'precision 10000')
2649
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2649
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2650
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2650
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2651
        */
2651
        */
2652
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2652
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2653
            if( js_function[DRAW_XLOGSCALE] != 1 ){ js_function[DRAW_XLOGSCALE] = 1;}
2653
            if( js_function[DRAW_XLOGSCALE] != 1 ){ js_function[DRAW_XLOGSCALE] = 1;}
2654
            for(i=0;i<4;i++){
2654
            for(i=0;i<4;i++){
2655
                switch(i){
2655
                switch(i){
2656
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2656
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2657
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2657
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2658
                    case 2: stroke_color = get_color(infile,0); break;
2658
                    case 2: stroke_color = get_color(infile,0); break;
2659
                    case 3: fill_color = get_color(infile,1);
2659
                    case 3: fill_color = get_color(infile,1);
2660
                        string_length = snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2660
                        string_length = snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2661
                        tmp_buffer = my_newmem(string_length+1);
2661
                        tmp_buffer = my_newmem(string_length+1);
2662
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2662
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2663
                        fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]);
2663
                        fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]);
2664
                        add_to_buffer(tmp_buffer);
2664
                        add_to_buffer(tmp_buffer);
Line 2673... Line 2673...
2673
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2673
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2674
         @ xmajor is the major step on the x-axis; xminor is the divisor for the x-step
2674
         @ xmajor is the major step on the x-axis; xminor is the divisor for the x-step
2675
         @ the linewidth is set using command 'linewidth int'
2675
         @ the linewidth is set using command 'linewidth int'
2676
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2676
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2677
         @ default logbase number = 10 ... when needed , set the logbase number with command 'ylogbase number'
2677
         @ default logbase number = 10 ... when needed , set the logbase number with command 'ylogbase number'
2678
         @ the x/y- axis numbering is triggered by keyword 'axisnumbering'<ul><li>use command 'precision' before 'ylogscale' command to set the precision (decimals) of the axis numbering</li><li>use commands 'xlabel some_text' and/or 'ylabel some_text' for text on axis : use command 'fontsize int' to set the fontsize (default 12px)</li><li>use command 'fontfamily fnt_family_string' to set the fonts for axis-numbering</li><li>use command'fontcolor' to set the colour</li></ul>
2678
         @ the x/y- axis numbering is triggered by keyword 'axisnumbering'<ul><li>use command 'precision' before 'ylogscale' command to set the precision (decimals) of the axis numbering</li><li>use commands 'xlabel some_text' and/or 'ylabel some_text' for text on axis : use command 'fontsize int' to set the fontsize (default 12px)</li><li>use command 'fontfamily fnt_family_string' to set the fonts for axis-numbering</li><li>use command'fontcolor' to set the colour</li></ul>
2679
         @ note: the complete canvas will be used for the 'log paper'
2679
         @ note: the complete canvas will be used for the 'log paper'
2680
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2680
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2681
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2681
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2682
         @ note: when using something like 'yrange 0.0001,0.01'...combined with commands 'mouse color,fontsize' and/or 'userdraw type,color'...<br /> make sure the precision is set accordingly (eg command 'precision 10000')  
2682
         @ note: when using something like 'yrange 0.0001,0.01'...combined with commands 'mouse color,fontsize' and/or 'userdraw type,color'...<br /> make sure the precision is set accordingly (eg command 'precision 10000')
2683
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2683
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2684
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2684
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2685
        */
2685
        */
2686
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2686
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2687
            if( js_function[DRAW_YLOGSCALE] != 1 ){ js_function[DRAW_YLOGSCALE] = 1;}
2687
            if( js_function[DRAW_YLOGSCALE] != 1 ){ js_function[DRAW_YLOGSCALE] = 1;}
2688
            for(i=0;i<4;i++){
2688
            for(i=0;i<4;i++){
2689
                switch(i){
2689
                switch(i){
2690
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2690
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2691
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2691
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2692
                    case 2: stroke_color = get_color(infile,0); break;
2692
                    case 2: stroke_color = get_color(infile,0); break;
2693
                    case 3: fill_color = get_color(infile,1);
2693
                    case 3: fill_color = get_color(infile,1);
2694
                        string_length = snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2694
                        string_length = snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2695
                        tmp_buffer = my_newmem(string_length+1);
2695
                        tmp_buffer = my_newmem(string_length+1);
2696
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2696
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision);
2697
                        fprintf(js_include_file,"use_ylogscale=1;snap_x = %f;snap_y = ylogbase;",double_data[0]/int_data[0]);
2697
                        fprintf(js_include_file,"use_ylogscale=1;snap_x = %f;snap_y = ylogbase;",double_data[0]/int_data[0]);
2698
                        add_to_buffer(tmp_buffer);
2698
                        add_to_buffer(tmp_buffer);
Line 2706... Line 2706...
2706
         @ xylogscale majorcolor,minorcolor
2706
         @ xylogscale majorcolor,minorcolor
2707
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2707
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2708
         @ the linewidth is set using command 'linewidth int'
2708
         @ the linewidth is set using command 'linewidth int'
2709
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2709
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2710
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number' and/or 'ylogbase number'
2710
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number' and/or 'ylogbase number'
2711
         @ the x/y- axis numbering is triggered by keyword 'axisnumbering'<ul><li>use commands 'xlabel some_text' and/or 'ylabel some_text' for text on axis : use command 'fontsize int' to set the fontsize (default 12px)</li><li>use command 'fontfamily fnt_family_string' to set the fonts for axis-numbering</li><li>use command'fontcolor' to set the colour</li></ul>
2711
         @ the x/y- axis numbering is triggered by keyword 'axisnumbering'<ul><li>use commands 'xlabel some_text' and/or 'ylabel some_text' for text on axis : use command 'fontsize int' to set the fontsize (default 12px)</li><li>use command 'fontfamily fnt_family_string' to set the fonts for axis-numbering</li><li>use command'fontcolor' to set the colour</li></ul>
2712
         @ note: the complete canvas will be used for the 'log paper'
2712
         @ note: the complete canvas will be used for the 'log paper'
2713
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2713
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2714
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2714
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2715
         @ note: when using something like 'yrange 0.0001,0.01'...combined with commands 'mouse color,fontsize' and/or 'userdraw type,color'...<br /> make sure the precision is set accordingly (eg command 'precision 10000')  
2715
         @ note: when using something like 'yrange 0.0001,0.01'...combined with commands 'mouse color,fontsize' and/or 'userdraw type,color'...<br /> make sure the precision is set accordingly (eg command 'precision 10000')
2716
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2716
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2717
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2717
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2718
        */
2718
        */
2719
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2719
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2720
            if( js_function[DRAW_XYLOGSCALE] != 1 ){ js_function[DRAW_XYLOGSCALE] = 1;}
2720
            if( js_function[DRAW_XYLOGSCALE] != 1 ){ js_function[DRAW_XYLOGSCALE] = 1;}
2721
            for(i=0;i<2;i++){
2721
            for(i=0;i<2;i++){
2722
                switch(i){
2722
                switch(i){
2723
                    case 0: stroke_color = get_color(infile,0); break;
2723
                    case 0: stroke_color = get_color(infile,0); break;
2724
                    case 1: fill_color = get_color(infile,1);
2724
                    case 1: fill_color = get_color(infile,1);
2725
                        string_length = snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
2725
                        string_length = snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
2726
                        tmp_buffer = my_newmem(string_length+1);
2726
                        tmp_buffer = my_newmem(string_length+1);
2727
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
2727
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
2728
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
2728
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
2729
                        add_to_buffer(tmp_buffer);
2729
                        add_to_buffer(tmp_buffer);
Line 2733... Line 2733...
2733
            }
2733
            }
2734
        break;
2734
        break;
2735
        default:sync_input(infile);
2735
        default:sync_input(infile);
2736
        break;
2736
        break;
2737
    }
2737
    }
2738
  }
2738
  }
2739
  /* we are done parsing script file */
2739
  /* we are done parsing script file */
2740
 
2740
 
2741
  /* if needed, add generic draw functions (grid / xml etc) to buffer : these are no draggable shapes / objects  ! */
2741
  /* if needed, add generic draw functions (grid / xml etc) to buffer : these are no draggable shapes / objects  ! */
2742
  add_javascript_functions(js_function,canvas_root_id);
2742
  add_javascript_functions(js_function,canvas_root_id);
2743
   /* add read_canvas() etc functions if needed */
2743
   /* add read_canvas() etc functions if needed */
2744
  if( reply_format > 0 ){ add_read_canvas(reply_format);}
2744
  if( reply_format > 0 ){ add_read_canvas(reply_format);}
2745
  if( use_pan_and_zoom == TRUE ){
2745
  if( use_pan_and_zoom == TRUE ){
Line 2834... Line 2834...
2834
    if (oldlen != newlen){
2834
    if (oldlen != newlen){
2835
        for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){
2835
        for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){
2836
            count++;
2836
            count++;
2837
            retlen = p - str + strlen(p) + count * (newlen - oldlen);
2837
            retlen = p - str + strlen(p) + count * (newlen - oldlen);
2838
        }
2838
        }
2839
    }
2839
    }
2840
    else
2840
    else
2841
    {
2841
    {
2842
        retlen = strlen(str);
2842
        retlen = strlen(str);
2843
    }
2843
    }
2844
   
2844
 
2845
    if ((ret = malloc(retlen + 1)) == NULL){
2845
    if ((ret = malloc(retlen + 1)) == NULL){
2846
        ret = NULL;
2846
        ret = NULL;
2847
        canvas_error("string argument is NULL");
2847
        canvas_error("string argument is NULL");
2848
    }
2848
    }
2849
    else
2849
    else
Line 2856... Line 2856...
2856
            r += newlen;
2856
            r += newlen;
2857
        }
2857
        }
2858
        strcpy(r, p);
2858
        strcpy(r, p);
2859
    }
2859
    }
2860
    return ret;
2860
    return ret;
2861
}
2861
}
2862
 
2862
 
2863
/******************************************************************************/
2863
/******************************************************************************/
2864
/*
2864
/*
2865
avoid the use of ctypes.h for tolower() toupper();
2865
avoid the use of ctypes.h for tolower() toupper();
2866
it gives trouble in FreeBSD 9.0 / 9.1 when used in a chroot environment (C library bug) : Undefined symbol "_ThreadRuneLocale"
2866
it gives trouble in FreeBSD 9.0 / 9.1 when used in a chroot environment (C library bug) : Undefined symbol "_ThreadRuneLocale"
Line 2872... Line 2872...
2872
  if (c >= 'A'){
2872
  if (c >= 'A'){
2873
   return c - 'A' + 'a';
2873
   return c - 'A' + 'a';
2874
  }
2874
  }
2875
 }
2875
 }
2876
 return c;
2876
 return c;
2877
}
2877
}
2878
 
2878
 
2879
int toupper(int c){
2879
int toupper(int c){
2880
 if(c >= 'a' && c <= 'z'){
2880
 if(c >= 'a' && c <= 'z'){
2881
   return c + 'A' - 'a';
2881
   return c + 'A' - 'a';
2882
 }
2882
 }
2883
 return c;
2883
 return c;
2884
}
2884
}
2885
 
2885
 
2886
char *get_color(FILE *infile , int last){
2886
char *get_color(FILE *infile , int last){
2887
    int c,i = 0,is_hex = 0;
2887
    int c,i = 0,is_hex = 0;
2888
    char temp[MAX_COLOR_STRING], *string;
2888
    char temp[MAX_COLOR_STRING], *string;
2889
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',' ) && ( c != ';' ) ){
2889
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',' ) && ( c != ';' ) ){
Line 2894... Line 2894...
2894
        if( c != ' '){
2894
        if( c != ' '){
2895
            temp[i]=tolower(c);
2895
            temp[i]=tolower(c);
2896
            i++;
2896
            i++;
2897
        }
2897
        }
2898
    }
2898
    }
2899
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
2899
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
2900
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
2900
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
2901
    if( c == EOF ){finished = 1;}
2901
    if( c == EOF ){finished = 1;}
2902
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2902
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2903
    temp[i]='\0';
2903
    temp[i]='\0';
2904
    if( strlen(temp) == 0 ){ canvas_error("expected a colorname or hexnumber, but found nothing !!");}
2904
    if( strlen(temp) == 0 ){ canvas_error("expected a colorname or hexnumber, but found nothing !!");}
Line 2936... Line 2936...
2936
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){
2936
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){
2937
        temp[i]=c;
2937
        temp[i]=c;
2938
        i++;
2938
        i++;
2939
        if(i > MAX_BUFFER){ canvas_error("string size too big...repeat command to fit string");break;}
2939
        if(i > MAX_BUFFER){ canvas_error("string size too big...repeat command to fit string");break;}
2940
    }
2940
    }
2941
    if( ( c == '\n' || c == EOF ) && last == 0){canvas_error("expecting more arguments in command");}
2941
    if( ( c == '\n' || c == EOF ) && last == 0){canvas_error("expecting more arguments in command");}
2942
    if( c == '\n') { done = TRUE; line_number++; }
2942
    if( c == '\n') { done = TRUE; line_number++; }
2943
    if( c == EOF ) {
2943
    if( c == EOF ) {
2944
        finished = 1;
2944
        finished = 1;
2945
        if( last != 1 ){ canvas_error("expected more arguments");}
2945
        if( last != 1 ){ canvas_error("expected more arguments");}
2946
    }
2946
    }
Line 2957... Line 2957...
2957
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',')){
2957
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',')){
2958
        temp[i]=c;
2958
        temp[i]=c;
2959
        i++;
2959
        i++;
2960
        if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;}
2960
        if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;}
2961
    }
2961
    }
2962
    if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");}
2962
    if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");}
2963
    if( c == '\n') { line_number++; }
2963
    if( c == '\n') { line_number++; }
2964
    if( c == EOF ) {finished = 1;}
2964
    if( c == EOF ) {finished = 1;}
2965
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2965
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2966
    temp[i]='\0';
2966
    temp[i]='\0';
2967
    if( strlen(temp) == 0 ){ canvas_error("expected a word or string (without comma) , but found nothing !!");}
2967
    if( strlen(temp) == 0 ){ canvas_error("expected a word or string (without comma) , but found nothing !!");}
Line 2975... Line 2975...
2975
    int c,i=0,found_calc = 0;
2975
    int c,i=0,found_calc = 0;
2976
    double y;
2976
    double y;
2977
    char tmp[MAX_INT];
2977
    char tmp[MAX_INT];
2978
    while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){
2978
    while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){
2979
     if( c != ' ' ){
2979
     if( c != ' ' ){
2980
     /*
2980
     /*
2981
     libmatheval will segfault when for example: "xrange -10,+10" or "xrange -10,10+" is used
2981
     libmatheval will segfault when for example: "xrange -10,+10" or "xrange -10,10+" is used
2982
     We will check after assert() if it's a NULL pointer...and exit program via :
2982
     We will check after assert() if it's a NULL pointer...and exit program via :
2983
     canvas_error("I'm having trouble parsing your \"expression\" ");
2983
     canvas_error("I'm having trouble parsing your \"expression\" ");
2984
     */
2984
     */
2985
      if( i == 0 &&  c == '+' ){
2985
      if( i == 0 &&  c == '+' ){
2986
       continue;
2986
       continue;
2987
      }
2987
      }
2988
      else
2988
      else
2989
      {
2989
      {
2990
       if(canvas_iscalculation(c) != 0){
2990
       if(canvas_iscalculation(c) != 0){
2991
        found_calc = 1;
2991
        found_calc = 1;
2992
        c = tolower(c);
2992
        c = tolower(c);
Line 2995... Line 2995...
2995
       i++;
2995
       i++;
2996
      }
2996
      }
2997
     }
2997
     }
2998
     if( i > MAX_INT - 1){canvas_error("number too large");}
2998
     if( i > MAX_INT - 1){canvas_error("number too large");}
2999
    }
2999
    }
3000
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
3000
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
3001
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
3001
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
3002
    if( c == EOF ){done = TRUE ; finished = 1;}
3002
    if( c == EOF ){done = TRUE ; finished = 1;}
3003
    tmp[i]='\0';
3003
    tmp[i]='\0';
3004
    if( strlen(tmp) == 0 ){canvas_error("expected a number , but found nothing !!");}
3004
    if( strlen(tmp) == 0 ){canvas_error("expected a number , but found nothing !!");}
3005
    if( found_calc == 1 ){ /* use libmatheval to calculate 2*pi/3 */
3005
    if( found_calc == 1 ){ /* use libmatheval to calculate 2*pi/3 */
Line 3077... Line 3077...
3077
 
3077
 
3078
3 = x1,x2,x3,x4....x_n
3078
3 = x1,x2,x3,x4....x_n
3079
    y1,y2,y3,y4....y_n
3079
    y1,y2,y3,y4....y_n
3080
    r1,r2,r3,r4....r_n
3080
    r1,r2,r3,r4....r_n
3081
 
3081
 
3082
    x/y in pixels
3082
    x/y in pixels
3083
    r in pixels
3083
    r in pixels
3084
 
3084
 
3085
4 = x1,x2,x3,x4....x_n
3085
4 = x1,x2,x3,x4....x_n
3086
    y1,y2,y3,y4....y_n
3086
    y1,y2,y3,y4....y_n
3087
    r1,r2,r3,r4....r_n
3087
    r1,r2,r3,r4....r_n
3088
 
3088
 
3089
    x/y in  xrange / yrange coordinate system
3089
    x/y in  xrange / yrange coordinate system
3090
    r in pixels
3090
    r in pixels
3091
 
3091
 
3092
5 = Ax1,Ax2,Ax3,Ax4....Ax_n
3092
5 = Ax1,Ax2,Ax3,Ax4....Ax_n
3093
    Ay1,Ay2,Ay3,Ay4....Ay_n
3093
    Ay1,Ay2,Ay3,Ay4....Ay_n
3094
    Bx1,Bx2,Bx3,Bx4....Bx_n
3094
    Bx1,Bx2,Bx3,Bx4....Bx_n
3095
    By1,By2,By3,By4....By_n
3095
    By1,By2,By3,By4....By_n
3096
    Cx1,Cx2,Cx3,Cx4....Cx_n
3096
    Cx1,Cx2,Cx3,Cx4....Cx_n
3097
    Cy1,Cy2,Cy3,Cy4....Cy_n
3097
    Cy1,Cy2,Cy3,Cy4....Cy_n
3098
    ....
3098
    ....
3099
    Zx1,Zx2,Zx3,Zx4....Zx_n
3099
    Zx1,Zx2,Zx3,Zx4....Zx_n
3100
    Zy1,Zy2,Zy3,Zy4....Zy_n
3100
    Zy1,Zy2,Zy3,Zy4....Zy_n
3101
   
3101
 
3102
    x/y in pixels
3102
    x/y in pixels
3103
 
3103
 
3104
6 = Ax1,Ax2,Ax3,Ax4....Ax_n
3104
6 = Ax1,Ax2,Ax3,Ax4....Ax_n
3105
    Ay1,Ay2,Ay3,Ay4....Ay_n
3105
    Ay1,Ay2,Ay3,Ay4....Ay_n
3106
    Bx1,Bx2,Bx3,Bx4....Bx_n
3106
    Bx1,Bx2,Bx3,Bx4....Bx_n
Line 3110... Line 3110...
3110
    ....
3110
    ....
3111
    Zx1,Zx2,Zx3,Zx4....Zx_n
3111
    Zx1,Zx2,Zx3,Zx4....Zx_n
3112
    Zy1,Zy2,Zy3,Zy4....Zy_n
3112
    Zy1,Zy2,Zy3,Zy4....Zy_n
3113
 
3113
 
3114
    x/y in  xrange / yrange coordinate system
3114
    x/y in  xrange / yrange coordinate system
3115
   
3115
 
3116
7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
3116
7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
3117
   
-
 
3118
    x/y in pixels
-
 
3119
 
3117
 
3120
8 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
-
 
3121
   
-
 
3122
    x/y in  xrange / yrange coordinate system
-
 
3123
 
-
 
3124
9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n    
-
 
3125
 
-
 
3126
    x/y in pixels
3118
    x/y in pixels
3127
 
3119
 
-
 
3120
8 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
-
 
3121
 
-
 
3122
    x/y in  xrange / yrange coordinate system
-
 
3123
 
-
 
3124
9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n
-
 
3125
 
-
 
3126
    x/y in pixels
-
 
3127
 
3128
10 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n    
3128
10 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n
3129
 
3129
 
3130
    x/y in  xrange / yrange coordinate system
3130
    x/y in  xrange / yrange coordinate system
3131
 
3131
 
3132
11 = Ax1,Ay1,Ax2,Ay2
3132
11 = Ax1,Ay1,Ax2,Ay2
3133
     Bx1,By1,Bx2,By2
3133
     Bx1,By1,Bx2,By2
3134
     Cx1,Cy1,Cx2,Cy2
3134
     Cx1,Cy1,Cx2,Cy2
3135
     Dx1,Dy1,Dx2,Dy2
3135
     Dx1,Dy1,Dx2,Dy2
3136
     ......
3136
     ......
3137
     Zx1,Zy1,Zx2,Zy2
3137
     Zx1,Zy1,Zx2,Zy2
3138
     
3138
 
3139
    x/y in  xrange / yrange coordinate system
3139
    x/y in  xrange / yrange coordinate system
3140
 
3140
 
3141
12 = Ax1,Ay1,Ax2,Ay2
3141
12 = Ax1,Ay1,Ax2,Ay2
3142
     Bx1,By1,Bx2,By2
3142
     Bx1,By1,Bx2,By2
3143
     Cx1,Cy1,Cx2,Cy2
3143
     Cx1,Cy1,Cx2,Cy2
3144
     Dx1,Dy1,Dx2,Dy2
3144
     Dx1,Dy1,Dx2,Dy2
3145
     ......
3145
     ......
3146
     Zx1,Zy1,Zx2,Zy2
3146
     Zx1,Zy1,Zx2,Zy2
3147
     
3147
 
3148
    x/y in pixels
3148
    x/y in pixels
3149
 
3149
 
3150
13 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2
3150
13 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2
3151
 
3151
 
3152
    x/y in  xrange / yrange coordinate system
3152
    x/y in  xrange / yrange coordinate system
3153
14 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2....Zx1:Zy1:Zx2:Zy2
3153
14 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2....Zx1:Zy1:Zx2:Zy2
3154
    x/y in pixels
3154
    x/y in pixels
3155
15 = reply from inputfields,textareas
3155
15 = reply from inputfields,textareas
3156
    reply1,reply2,reply3,...,reply_n
3156
    reply1,reply2,reply3,...,reply_n
Line 3164... Line 3164...
3164
19 = return clicked object number (analogue to shape-library onclick)
3164
19 = return clicked object number (analogue to shape-library onclick)
3165
20 = return x/y-data in x-range/y-range of all 'draggable' images
3165
20 = return x/y-data in x-range/y-range of all 'draggable' images
3166
21 = return verbatim coordinates (x1:y1) (x2:y2)...(x_n:y_n)
3166
21 = return verbatim coordinates (x1:y1) (x2:y2)...(x_n:y_n)
3167
22 = array : x1,y1,x2,y2,x3,y3,x4,y4...x_n,y_n
3167
22 = array : x1,y1,x2,y2,x3,y3,x4,y4...x_n,y_n
3168
    x/y in  xrange / yrange coordinate system
3168
    x/y in  xrange / yrange coordinate system
3169
23 = answertype for a polyline : remove multiple occurences  due to reclick on a point to create next polyline segment
3169
23 = answertype for a polyline : remove multiple occurences  due to reclick on a point to create next polyline segment
3170
*/
3170
*/
3171
 
3171
 
3172
 
3172
 
3173
void add_read_canvas(int type_reply){
3173
void add_read_canvas(int type_reply){
3174
/* just 1 reply type allowed */
3174
/* just 1 reply type allowed */
3175
switch(type_reply){
3175
switch(type_reply){
3176
/*  TO DO
3176
/*  TO DO
3177
!!!!  NEED TO SIMPLIFY !!!!  
3177
!!!!  NEED TO SIMPLIFY !!!!
3178
answers may have:
3178
answers may have:
3179
x-values,y-values,r-values,input-fields,mathml-inputfields,text-typed answers
3179
x-values,y-values,r-values,input-fields,mathml-inputfields,text-typed answers
3180
*/
3180
*/
3181
    case 1: fprintf(js_include_file,"\
3181
    case 1: fprintf(js_include_file,"\
3182
\n<!-- begin function 1 read_canvas() -->\n\
3182
\n<!-- begin function 1 read_canvas() -->\n\
Line 3194... Line 3194...
3194
    t++;\
3194
    t++;\
3195
   };\
3195
   };\
3196
  };\
3196
  };\
3197
  if( typeof userdraw_text != 'undefined' ){\
3197
  if( typeof userdraw_text != 'undefined' ){\
3198
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply + \"\\n\"+userdraw_text;\
3198
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply + \"\\n\"+userdraw_text;\
3199
  }\
3199
  }\
3200
  else\
3200
  else\
3201
  {\
3201
  {\
3202
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply;\
3202
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply;\
3203
  }\
3203
  }\
3204
 }\
3204
 }\
3205
 else\
3205
 else\
3206
 {\
3206
 {\
3207
  if( typeof userdraw_text != 'undefined' ){\
3207
  if( typeof userdraw_text != 'undefined' ){\
3208
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_text;\
3208
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_text;\
3209
  }\
3209
  }\
3210
  else\
3210
  else\
3211
  {\
3211
  {\
3212
   return userdraw_x+\"\\n\"+userdraw_y;\
3212
   return userdraw_x+\"\\n\"+userdraw_y;\
3213
  }\
3213
  }\
3214
 };\
3214
 };\
Line 3226... Line 3226...
3226
  reply_y[p] = px2y(userdraw_y[p]);\
3226
  reply_y[p] = px2y(userdraw_y[p]);\
3227
  p++;\
3227
  p++;\
3228
 };\
3228
 };\
3229
 if(p == 0){alert(\"nothing drawn...\");return;};\
3229
 if(p == 0){alert(\"nothing drawn...\");return;};\
3230
 if( document.getElementById(\"canvas_input0\")){\
3230
 if( document.getElementById(\"canvas_input0\")){\
3231
  var p = 0;var input_reply = new Array();\
3231
  var p = 0;var input_reply = new Array();\
3232
  if( document.getElementById(\"canvas_input0\")){\
3232
  if( document.getElementById(\"canvas_input0\")){\
3233
   var t = 0;\
3233
   var t = 0;\
3234
   while(document.getElementById(\"canvas_input\"+t)){\
3234
   while(document.getElementById(\"canvas_input\"+t)){\
3235
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3235
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3236
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3236
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3237
     p++;\
3237
     p++;\
3238
    };\
3238
    };\
3239
    t++;\
3239
    t++;\
3240
   };\
3240
   };\
3241
  };\
3241
  };\
3242
  if( typeof userdraw_text != 'undefined' ){\
3242
  if( typeof userdraw_text != 'undefined' ){\
3243
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3243
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3244
  }\
3244
  }\
3245
  else\
3245
  else\
3246
  {\
3246
  {\
3247
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\
3247
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\
3248
  }\
3248
  }\
3249
 }\
3249
 }\
3250
 else\
3250
 else\
3251
 {\
3251
 {\
3252
  if( typeof userdraw_text != 'undefined' ){\
3252
  if( typeof userdraw_text != 'undefined' ){\
3253
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_text;\
3253
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_text;\
3254
  }\
3254
  }\
3255
  else\
3255
  else\
Line 3277... Line 3277...
3277
    t++;\
3277
    t++;\
3278
   };\
3278
   };\
3279
  };\
3279
  };\
3280
  if( typeof userdraw_text != 'undefined' ){\
3280
  if( typeof userdraw_text != 'undefined' ){\
3281
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3281
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3282
  }\
3282
  }\
3283
  else\
3283
  else\
3284
  {\
3284
  {\
3285
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3285
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3286
  }\
3286
  }\
3287
 }\
3287
 }\
3288
 else\
3288
 else\
3289
 {\
3289
 {\
3290
  if( typeof userdraw_text != 'undefined' ){\
3290
  if( typeof userdraw_text != 'undefined' ){\
3291
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+userdrawW_text;\
3291
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+userdrawW_text;\
3292
  }\
3292
  }\
3293
  else\
3293
  else\
Line 3296... Line 3296...
3296
  }\
3296
  }\
3297
 }\
3297
 }\
3298
};\
3298
};\
3299
this.read_canvas = read_canvas;\n\
3299
this.read_canvas = read_canvas;\n\
3300
<!-- end function 3 read_canvas() -->");
3300
<!-- end function 3 read_canvas() -->");
3301
    break;
3301
    break;
3302
    case 4: fprintf(js_include_file,"\
3302
    case 4: fprintf(js_include_file,"\
3303
\n<!-- begin function 4 read_canvas() -->\n\
3303
\n<!-- begin function 4 read_canvas() -->\n\
3304
function read_canvas(){\
3304
function read_canvas(){\
3305
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
3305
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
3306
 while(userdraw_x[p]){\
3306
 while(userdraw_x[p]){\
3307
  reply_x[p] = px2x(userdraw_x[p]);\
3307
  reply_x[p] = px2x(userdraw_x[p]);\
3308
  reply_y[p] = px2y(userdraw_y[p]);\
3308
  reply_y[p] = px2y(userdraw_y[p]);\
3309
  p++;\
3309
  p++;\
3310
 };\
3310
 };\
3311
 if(p == 0){alert(\"nothing drawn...\");return;};\
3311
 if(p == 0){alert(\"nothing drawn...\");return;};\
3312
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3312
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3313
  var p = 0;var input_reply = new Array();\
3313
  var p = 0;var input_reply = new Array();\
3314
  if( document.getElementById(\"canvas_input0\")){\
3314
  if( document.getElementById(\"canvas_input0\")){\
3315
   var t = 0;\
3315
   var t = 0;\
3316
   while(document.getElementById(\"canvas_input\"+t)){\
3316
   while(document.getElementById(\"canvas_input\"+t)){\
3317
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3317
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3318
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3318
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3319
     p++;\
3319
     p++;\
3320
    };\
3320
    };\
3321
    t++;\
3321
    t++;\
3322
   };\
3322
   };\
3323
  };\
3323
  };\
3324
  if( typeof userdraw_text != 'undefined' ){\
3324
  if( typeof userdraw_text != 'undefined' ){\
3325
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3325
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3326
  }\
3326
  }\
3327
  else\
3327
  else\
3328
  {\
3328
  {\
3329
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3329
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3330
  }\
3330
  }\
3331
 }\
3331
 }\
3332
 else\
3332
 else\
3333
 {\
3333
 {\
3334
  if( typeof userdraw_text != 'undefined' ){\
3334
  if( typeof userdraw_text != 'undefined' ){\
3335
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius+\"\\n\"+userdraw_text;\
3335
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius+\"\\n\"+userdraw_text;\
3336
  }\
3336
  }\
3337
  else\
3337
  else\
3338
  {\
3338
  {\
3339
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius;\
3339
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius;\
3340
  }\
3340
  }\
3341
 };\
3341
 };\
3342
};\
3342
};\
3343
this.read_canvas = read_canvas;\n\
3343
this.read_canvas = read_canvas;\n\
3344
<!-- end function 4 read_canvas() -->");
3344
<!-- end function 4 read_canvas() -->");
3345
    break;
3345
    break;
3346
    /*
3346
    /*
3347
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3347
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3348
        used for userdraw multiple paths
3348
        used for userdraw multiple paths
3349
    */
3349
    */
3350
    case 5: fprintf(js_include_file,"\
3350
    case 5: fprintf(js_include_file,"\
3351
\n<!-- begin function 5 read_canvas() -->\n\
3351
\n<!-- begin function 5 read_canvas() -->\n\
3352
function read_canvas(){\
3352
function read_canvas(){\
3353
 var p = 0;\
3353
 var p = 0;\
Line 3358... Line 3358...
3358
  };\
3358
  };\
3359
 };\
3359
 };\
3360
 if(p == 0){alert(\"nothing drawn...\");return;};\
3360
 if(p == 0){alert(\"nothing drawn...\");return;};\
3361
 userdraw_x = [];userdraw_y = [];\
3361
 userdraw_x = [];userdraw_y = [];\
3362
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3362
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3363
  var p = 0;var input_reply = new Array();\
3363
  var p = 0;var input_reply = new Array();\
3364
  if( document.getElementById(\"canvas_input0\")){\
3364
  if( document.getElementById(\"canvas_input0\")){\
3365
   var t = 0;\
3365
   var t = 0;\
3366
   while(document.getElementById(\"canvas_input\"+t)){\
3366
   while(document.getElementById(\"canvas_input\"+t)){\
3367
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3367
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3368
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3368
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3369
     p++;\
3369
     p++;\
3370
    };\
3370
    };\
3371
    t++;\
3371
    t++;\
3372
   };\
3372
   };\
3373
  };\
3373
  };\
3374
  if( typeof userdraw_text != 'undefined' ){\
3374
  if( typeof userdraw_text != 'undefined' ){\
3375
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3375
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3376
  }\
3376
  }\
3377
  else\
3377
  else\
3378
  {\
3378
  {\
3379
   return reply +\"\\n\"+input_reply;\
3379
   return reply +\"\\n\"+input_reply;\
3380
  }\
3380
  }\
3381
 }\
3381
 }\
3382
 else\
3382
 else\
3383
 {\
3383
 {\
3384
  if( typeof userdraw_text != 'undefined' ){\
3384
  if( typeof userdraw_text != 'undefined' ){\
3385
   return reply+\"\\n\"+userdraw_text;\
3385
   return reply+\"\\n\"+userdraw_text;\
3386
  }\
3386
  }\
3387
  else\
3387
  else\
3388
  {\
3388
  {\
3389
   return reply;\
3389
   return reply;\
3390
  }\
3390
  }\
3391
 };\
3391
 };\
3392
};\
3392
};\
3393
this.read_canvas = rdad_canvas;\n\
3393
this.read_canvas = rdad_canvas;\n\
3394
<!-- end function 5 read_canvas() -->");
3394
<!-- end function 5 read_canvas() -->");
3395
    break;
3395
    break;
3396
    /*
3396
    /*
3397
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3397
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3398
        used for userdraw multiple paths
3398
        used for userdraw multiple paths
3399
    */
3399
    */
3400
    case 6: fprintf(js_include_file,"\
3400
    case 6: fprintf(js_include_file,"\
3401
\n<!-- begin function 6 read_canvas() -->\n\
3401
\n<!-- begin function 6 read_canvas() -->\n\
3402
function read_canvas(){\
3402
function read_canvas(){\
3403
 var p = 0;\
3403
 var p = 0;\
Line 3456... Line 3456...
3456
function read_canvas(){\
3456
function read_canvas(){\
3457
 var reply = new Array();\
3457
 var reply = new Array();\
3458
 var p = 0;\
3458
 var p = 0;\
3459
 while(userdraw_x[p]){\
3459
 while(userdraw_x[p]){\
3460
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p];\
3460
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p];\
3461
  p++;\
3461
  p++;\
3462
 };\
3462
 };\
3463
 if(p == 0){alert(\"nothing drawn...\");return;};\
3463
 if(p == 0){alert(\"nothing drawn...\");return;};\
3464
 if( document.getElementById(\"canvas_input0\") ){\
3464
 if( document.getElementById(\"canvas_input0\") ){\
3465
  var p = 0;var input_reply = new Array();\
3465
  var p = 0;var input_reply = new Array();\
3466
  if( document.getElementById(\"canvas_input0\")){\
3466
  if( document.getElementById(\"canvas_input0\")){\
3467
   var t = 0;\
3467
   var t = 0;\
3468
   while(document.getElementById(\"canvas_input\"+t)){\
3468
   while(document.getElementById(\"canvas_input\"+t)){\
3469
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3469
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3470
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3470
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3471
     p++;\
3471
     p++;\
3472
    };\
3472
    };\
3473
    t++;\
3473
    t++;\
3474
   };\
3474
   };\
3475
  };\
3475
  };\
3476
  if( typeof userdraw_text != 'undefined' ){\
3476
  if( typeof userdraw_text != 'undefined' ){\
3477
   return reply+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3477
   return reply+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3478
  }\
3478
  }\
3479
  else\
3479
  else\
3480
  {\
3480
  {\
3481
   return reply+\"\\n\"+input_reply;\
3481
   return reply+\"\\n\"+input_reply;\
3482
  }\
3482
  }\
3483
 };\
-
 
3484
 else\
-
 
3485
 {\
-
 
3486
  if( typeof userdraw_text != 'undefined' ){\
-
 
3487
   return reply+\"\\n\"+userdraw_text;\
-
 
3488
  }\
-
 
3489
  else\
-
 
3490
  {\
-
 
3491
   return reply;\
-
 
3492
  }\
-
 
3493
 };\
-
 
3494
};\
-
 
3495
this.read_canvas = read_canvas;\n\
-
 
3496
<!-- end function 7 read_canvas() -->");
-
 
3497
    break;
-
 
3498
    case 8: fprintf(js_include_file,"\
-
 
3499
\n<!-- begin function 8 read_canvas() -->\n\
-
 
3500
function read_canvas(){\
-
 
3501
 var reply = new Array();\
-
 
3502
 var p = 0;\
-
 
3503
 while(userdraw_x[p]){\
-
 
3504
  reply[p] = px2x(userdraw_x[p]) +\":\" + px2y(userdraw_y[p]);\
-
 
3505
  p++;\
-
 
3506
 };\
3483
 };\
3507
 if(p == 0){alert(\"nothing drawn...\");return;};\
-
 
3508
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
-
 
3509
  var p = 0;var input_reply = new Array();\
-
 
3510
  if( document.getElementById(\"canvas_input0\")){\
-
 
3511
   var t = 0;\
-
 
3512
   while(document.getElementById(\"canvas_input\"+t)){\
-
 
3513
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
-
 
3514
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
-
 
3515
     p++;\
-
 
3516
    };\
-
 
3517
    t++;\
-
 
3518
   };\
-
 
3519
  };\
-
 
3520
  if( typeof userdraw_text != 'undefined' ){\
-
 
3521
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
-
 
3522
  }\
-
 
3523
  else\
-
 
3524
  {\
-
 
3525
   return reply +\"\\n\"+input_reply;\
-
 
3526
  }\
-
 
3527
 }\
-
 
3528
 else\
3484
 else\
3529
 {\
3485
 {\
3530
  if( typeof userdraw_text != 'undefined' ){\
3486
  if( typeof userdraw_text != 'undefined' ){\
3531
   return reply +\"\\n\"+userdraw_text;\
3487
   return reply+\"\\n\"+userdraw_text;\
3532
  }\
3488
  }\
3533
  else\
3489
  else\
3534
  {\
3490
  {\
3535
   return reply;\
3491
   return reply;\
3536
  }\
3492
  }\
3537
 };\
3493
 };\
3538
};\
3494
};\
3539
this.read_canvas = read_canvas;\n\
3495
this.read_canvas = read_canvas;\n\
3540
<!-- end function 8 read_canvas() -->");
3496
<!-- end function 7 read_canvas() -->");
3541
    break;
3497
    break;
3542
    case 9: fprintf(js_include_file,"\
3498
    case 8: fprintf(js_include_file,"\
3543
\n<!-- begin function 9 read_canvas() -->\n\
3499
\n<!-- begin function 8 read_canvas() -->\n\
3544
function read_canvas(){\
3500
function read_canvas(){\
3545
 var reply = new Array();\
3501
 var reply = new Array();\
3546
 var p = 0;\
3502
 var p = 0;\
3547
 while(userdraw_x[p]){\
3503
 while(userdraw_x[p]){\
3548
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p] + \":\" + userdraw_radius[p];\
3504
  reply[p] = px2x(userdraw_x[p]) +\":\" + px2y(userdraw_y[p]);\
3549
  p++;\
3505
  p++;\
3550
 };\
3506
 };\
3551
 if(p == 0){alert(\"nothing drawn...\");return;};\
3507
 if(p == 0){alert(\"nothing drawn...\");return;};\
-
 
3508
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
-
 
3509
  var p = 0;var input_reply = new Array();\
-
 
3510
  if( document.getElementById(\"canvas_input0\")){\
-
 
3511
   var t = 0;\
-
 
3512
   while(document.getElementById(\"canvas_input\"+t)){\
-
 
3513
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
-
 
3514
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
-
 
3515
     p++;\
-
 
3516
    };\
-
 
3517
    t++;\
-
 
3518
   };\
-
 
3519
  };\
-
 
3520
  if( typeof userdraw_text != 'undefined' ){\
-
 
3521
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
-
 
3522
  }\
-
 
3523
  else\
-
 
3524
  {\
-
 
3525
   return reply +\"\\n\"+input_reply;\
-
 
3526
  }\
-
 
3527
 }\
-
 
3528
 else\
-
 
3529
 {\
-
 
3530
  if( typeof userdraw_text != 'undefined' ){\
-
 
3531
   return reply +\"\\n\"+userdraw_text;\
-
 
3532
  }\
-
 
3533
  else\
-
 
3534
  {\
-
 
3535
   return reply;\
-
 
3536
  }\
-
 
3537
 };\
-
 
3538
};\
-
 
3539
this.read_canvas = read_canvas;\n\
-
 
3540
<!-- end function 8 read_canvas() -->");
-
 
3541
    break;
-
 
3542
    case 9: fprintf(js_include_file,"\
-
 
3543
\n<!-- begin function 9 read_canvas() -->\n\
-
 
3544
function read_canvas(){\
-
 
3545
 var reply = new Array();\
-
 
3546
 var p = 0;\
-
 
3547
 while(userdraw_x[p]){\
-
 
3548
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p] + \":\" + userdraw_radius[p];\
-
 
3549
  p++;\
-
 
3550
 };\
-
 
3551
 if(p == 0){alert(\"nothing drawn...\");return;};\
3552
 if( document.getElementById(\"canvas_input0\") ){\
3552
 if( document.getElementById(\"canvas_input0\") ){\
3553
  var p = 0;var input_reply = new Array();\
3553
  var p = 0;var input_reply = new Array();\
3554
  if( document.getElementById(\"canvas_input0\")){\
3554
  if( document.getElementById(\"canvas_input0\")){\
3555
   var t = 0;\
3555
   var t = 0;\
3556
   while(document.getElementById(\"canvas_input\"+t)){\
3556
   while(document.getElementById(\"canvas_input\"+t)){\
3557
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3557
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
Line 3765... Line 3765...
3765
function read_canvas(){\
3765
function read_canvas(){\
3766
 var reply = new Array();\
3766
 var reply = new Array();\
3767
 var p = 0;var i = 0;\
3767
 var p = 0;var i = 0;\
3768
 while(userdraw_x[p]){\
3768
 while(userdraw_x[p]){\
3769
  reply[i] = userdraw_x[p] +\":\" + userdraw_y[p] +\":\" + userdraw_x[p+1] +\":\" + userdraw_y[p+1];\
3769
  reply[i] = userdraw_x[p] +\":\" + userdraw_y[p] +\":\" + userdraw_x[p+1] +\":\" + userdraw_y[p+1];\
3770
  p = p+2;i++;\
3770
  p = p+2;i++;\
3771
 };\
3771
 };\
3772
 if(p == 0){alert(\"nothing drawn...\");return;};\
3772
 if(p == 0){alert(\"nothing drawn...\");return;};\
3773
 if( document.getElementById(\"canvas_input0\") ){\
3773
 if( document.getElementById(\"canvas_input0\") ){\
3774
  var p = 0;var input_reply = new Array();\
3774
  var p = 0;var input_reply = new Array();\
3775
  if( document.getElementById(\"canvas_input0\")){\
3775
  if( document.getElementById(\"canvas_input0\")){\
3776
   var t = 0;\
3776
   var t = 0;\
3777
   while(document.getElementById(\"canvas_input\"+t)){\
3777
   while(document.getElementById(\"canvas_input\"+t)){\
3778
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3778
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3779
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3779
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3780
     p++;\
3780
     p++;\
3781
    };\
3781
    };\
3782
    t++;\
3782
    t++;\
3783
   };\
3783
   };\
Line 3786... Line 3786...
3786
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3786
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3787
  }\
3787
  }\
3788
  else\
3788
  else\
3789
  {\
3789
  {\
3790
   return reply +\"\\n\"+input_reply;\
3790
   return reply +\"\\n\"+input_reply;\
3791
  }\
3791
  }\
3792
 }\
3792
 }\
3793
 else\
3793
 else\
3794
 {\
3794
 {\
3795
  if( typeof userdraw_text != 'undefined' ){\
3795
  if( typeof userdraw_text != 'undefined' ){\
3796
   return reply +\"\\n\"+userdraw_text;\
3796
   return reply +\"\\n\"+userdraw_text;\
3797
  }\
3797
  }\
3798
  else\
3798
  else\
3799
  {\
3799
  {\
3800
   return reply;\
3800
   return reply;\
3801
  }\
3801
  }\
3802
 };\
3802
 };\
3803
};\
3803
};\
3804
 this.read_canvas = read_canvas;\n\
3804
 this.read_canvas = read_canvas;\n\
3805
<!-- end function 14 read_canvas() -->");
3805
<!-- end function 14 read_canvas() -->");
3806
    break;
3806
    break;
3807
    case 15: fprintf(js_include_file,"\
3807
    case 15: fprintf(js_include_file,"\
3808
\n<!-- begin function 15  read_canvas() -->\n\
3808
\n<!-- begin function 15  read_canvas() -->\n\
3809
function read_canvas(){\
3809
function read_canvas(){\
Line 3823... Line 3823...
3823
   return input_reply +\"\\n\"+userdraw_text;\
3823
   return input_reply +\"\\n\"+userdraw_text;\
3824
 }\
3824
 }\
3825
 else\
3825
 else\
3826
 {\
3826
 {\
3827
  return input_reply;\
3827
  return input_reply;\
3828
 };\
3828
 };\
3829
};\
3829
};\
3830
 this.read_canvas = read_canvas;\n\
3830
 this.read_canvas = read_canvas;\n\
3831
<!-- end function 15 read_canvas() -->");
3831
<!-- end function 15 read_canvas() -->");
3832
    break;
3832
    break;
3833
    case 16: fprintf(js_include_file,"\
3833
    case 16: fprintf(js_include_file,"\
3834
\n<!-- begin function 16 read_mathml() -->\n\
3834
\n<!-- begin function 16 read_mathml() -->\n\
Line 3849... Line 3849...
3849
    case 17:  fprintf(js_include_file,"\
3849
    case 17:  fprintf(js_include_file,"\
3850
\n<!-- begin function 17 read_canvas() -->\n\
3850
\n<!-- begin function 17 read_canvas() -->\n\
3851
function read_canvas(){\
3851
function read_canvas(){\
3852
 if( userdraw_text.length == 0){alert(\"no text typed...\");return;}\
3852
 if( userdraw_text.length == 0){alert(\"no text typed...\");return;}\
3853
 return userdraw_text;\
3853
 return userdraw_text;\
3854
};\
3854
};\
3855
this.read_canvas = read_canvas;\n\
3855
this.read_canvas = read_canvas;\n\
3856
<!-- end function 17 read_canvas() -->");
3856
<!-- end function 17 read_canvas() -->");
3857
    break;
3857
    break;
3858
    case 18: fprintf(js_include_file,"\
3858
    case 18: fprintf(js_include_file,"\
3859
\n<!-- begin function 18 read_canvas() -->\n\
3859
\n<!-- begin function 18 read_canvas() -->\n\
3860
function read_canvas(){\
3860
function read_canvas(){\
Line 3874... Line 3874...
3874
    break;
3874
    break;
3875
    case 19: fprintf(js_include_file,"\
3875
    case 19: fprintf(js_include_file,"\
3876
\n<!-- begin function 19 read_canvas() -->\n\
3876
\n<!-- begin function 19 read_canvas() -->\n\
3877
function read_canvas(){\
3877
function read_canvas(){\
3878
 return reply[0];\
3878
 return reply[0];\
3879
};\
3879
};\
3880
this.read_canvas = read_canvas;\n\
3880
this.read_canvas = read_canvas;\n\
3881
<!-- end function 19 read_canvas() -->");
3881
<!-- end function 19 read_canvas() -->");
3882
    case 20: fprintf(js_include_file,"\
3882
    case 20: fprintf(js_include_file,"\
3883
\n<!-- begin function 20 read_canvas() -->\n\
3883
\n<!-- begin function 20 read_canvas() -->\n\
3884
function read_canvas(){\
3884
function read_canvas(){\
3885
 var len  = ext_drag_images.length;\
3885
 var len  = ext_drag_images.length;\
Line 3899... Line 3899...
3899
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3899
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3900
 var reply_coord = new Array();var p = 0;\
3900
 var reply_coord = new Array();var p = 0;\
3901
 while(userdraw_x[p]){\
3901
 while(userdraw_x[p]){\
3902
  reply_coord[p] = \"(\"+px2x(userdraw_x[p])+\":\"+px2y(userdraw_y[p])+\")\";\
3902
  reply_coord[p] = \"(\"+px2x(userdraw_x[p])+\":\"+px2y(userdraw_y[p])+\")\";\
3903
  p++;\
3903
  p++;\
3904
 };\
3904
 };\
3905
 if(p == 0){alert(\"nothing drawn...\");return;};\
3905
 if(p == 0){alert(\"nothing drawn...\");return;};\
3906
 if( document.getElementById(\"canvas_input0\") ){\
3906
 if( document.getElementById(\"canvas_input0\") ){\
3907
  var p = 0;var input_reply = new Array();\
3907
  var p = 0;var input_reply = new Array();\
3908
  if( document.getElementById(\"canvas_input0\")){\
3908
  if( document.getElementById(\"canvas_input0\")){\
3909
   var t = 0;\
3909
   var t = 0;\
3910
   while(document.getElementById(\"canvas_input\"+t)){\
3910
   while(document.getElementById(\"canvas_input\"+t)){\
3911
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3911
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3912
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3912
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3913
     p++;\
3913
     p++;\
3914
    };\
3914
    };\
3915
    t++;\
3915
    t++;\
3916
   };\
3916
   };\
3917
  };\
3917
  };\
3918
  if( typeof userdraw_text != 'undefined' ){\
3918
  if( typeof userdraw_text != 'undefined' ){\
3919
   return reply_coord+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3919
   return reply_coord+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3920
  }\
3920
  }\
3921
  else\
3921
  else\
3922
  {\
3922
  {\
3923
   return reply_coord+\"\\n\"+input_reply;\
3923
   return reply_coord+\"\\n\"+input_reply;\
3924
  }\
3924
  }\
3925
 }\
3925
 }\
3926
 else\
3926
 else\
3927
 {\
3927
 {\
3928
  if( typeof userdraw_text != 'undefined' ){\
3928
  if( typeof userdraw_text != 'undefined' ){\
3929
   return reply_coord+\"\\n\"+userdraw_text;\
3929
   return reply_coord+\"\\n\"+userdraw_text;\
3930
  }\
3930
  }\
3931
  else\
3931
  else\
3932
  {\
3932
  {\
Line 3972... Line 3972...
3972
 }\
3972
 }\
3973
 else\
3973
 else\
3974
 {\
3974
 {\
3975
  if( typeof userdraw_text != 'undefined' ){\
3975
  if( typeof userdraw_text != 'undefined' ){\
3976
   return reply +\"\\n\"+userdraw_text;\
3976
   return reply +\"\\n\"+userdraw_text;\
3977
  }\
3977
  }\
3978
  else\
3978
  else\
3979
  {\
3979
  {\
3980
   return reply;\
3980
   return reply;\
3981
  }\
3981
  }\
3982
 };\
3982
 };\
3983
};\
3983
};\
3984
this.read_canvas = read_canvas;\n\
3984
this.read_canvas = read_canvas;\n\
3985
<!-- end function 22 read_canvas() -->");
3985
<!-- end function 22 read_canvas() -->");
3986
    break;
3986
    break;
3987
    case 23: fprintf(js_include_file,"\
3987
    case 23: fprintf(js_include_file,"\
3988
\n<!-- begin function 23 read_canvas() default 5 px marge -->\n\
3988
\n<!-- begin function 23 read_canvas() default 5 px marge -->\n\
Line 4029... Line 4029...
4029
  }\
4029
  }\
4030
  else\
4030
  else\
4031
  {\
4031
  {\
4032
   return reply_x+\"\\n\"+reply_y;\
4032
   return reply_x+\"\\n\"+reply_y;\
4033
  };\
4033
  };\
4034
 };\
4034
 };\
4035
};\
4035
};\
4036
this.read_canvas = read_canvas;\n\
4036
this.read_canvas = read_canvas;\n\
4037
<!-- end function 23 read_canvas() -->");
4037
<!-- end function 23 read_canvas() -->");
4038
    break;
4038
    break;
4039
 
4039
 
4040
    default: canvas_error("hmmm unknown replyformat...");break;
4040
    default: canvas_error("hmmm unknown replyformat...");break;
4041
}
4041
}
4042
 return;
4042
 return;
4043
}
4043
}
4044
 
4044
 
4045
 
4045
 
4046
/*
4046
/*
4047
 add drawfunction :
4047
 add drawfunction :
4048
 - functions used by userdraw_primitives (circle,rect,path,triangle...)
4048
 - functions used by userdraw_primitives (circle,rect,path,triangle...)
4049
 - things not covered by the drag&drop library (static objects like parallel, lattice ,gridfill , imagefill)
4049
 - things not covered by the drag&drop library (static objects like parallel, lattice ,gridfill , imagefill)
4050
 - grid / mathml
4050
 - grid / mathml
4051
 - will not scale or zoom in
4051
 - will not scale or zoom in
4052
 - will not be filled via pixel operations like fill / floodfill / filltoborder / clickfill
4052
 - will not be filled via pixel operations like fill / floodfill / filltoborder / clickfill
4053
 - is printed directly into 'js_include_file'
4053
 - is printed directly into 'js_include_file'
4054
*/
4054
*/
4055
 
4055
 
4056
void add_javascript_functions(int js_functions[],int canvas_root_id){
4056
void add_javascript_functions(int js_functions[],int canvas_root_id){
4057
int i;
4057
int i;
4058
for(i = 0 ; i < MAX_JS_FUNCTIONS; i++){
4058
for(i = 0 ; i < MAX_JS_FUNCTIONS; i++){
Line 4084... Line 4084...
4084
  external_ctx.drawImage(img[1],img[2],img[3],img[4],img[5],img[6],img[7],img[8],img[9]);\
4084
  external_ctx.drawImage(img[1],img[2],img[3],img[4],img[5],img[6],img[7],img[8],img[9]);\
4085
 };\
4085
 };\
4086
};\
4086
};\
4087
function dragstop(evt){\
4087
function dragstop(evt){\
4088
 selected_image = null;return;\
4088
 selected_image = null;return;\
4089
};\
4089
};\
4090
function dragxy(evt){\
4090
function dragxy(evt){\
4091
 if( selected_image != null ){\
4091
 if( selected_image != null ){\
4092
  var xoff = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);\
4092
  var xoff = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);\
4093
  var yoff = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);\
4093
  var yoff = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);\
4094
  var s_img = ext_drag_images[selected_image];\
4094
  var s_img = ext_drag_images[selected_image];\
Line 4153... Line 4153...
4153
  canvas_bg_div.style.backgroundSize = width+\"px \"+height+\"px\";\
4153
  canvas_bg_div.style.backgroundSize = width+\"px \"+height+\"px\";\
4154
  canvas_bg_div.style.backgroundRepeat = \"no-repeat\";\
4154
  canvas_bg_div.style.backgroundRepeat = \"no-repeat\";\
4155
  canvas_bg_div.style.backgroundPosition= sx+\"px \"+sy+\"px\";\
4155
  canvas_bg_div.style.backgroundPosition= sx+\"px \"+sy+\"px\";\
4156
  canvas_bg_div.style.backgroundImage = \"url(\" + URL + \")\";\
4156
  canvas_bg_div.style.backgroundImage = \"url(\" + URL + \")\";\
4157
 };\
4157
 };\
4158
};",canvas_root_id);    
4158
};",canvas_root_id);
4159
    break;
4159
    break;
4160
   
4160
 
4161
    case DRAW_ZOOM_BUTTONS: /* 6 rectangles 15x15 px  forbidden zone for drawing : y < ysize - 15*/
4161
    case DRAW_ZOOM_BUTTONS: /* 6 rectangles 15x15 px  forbidden zone for drawing : y < ysize - 15*/
4162
fprintf(js_include_file,"\n<!-- draw zoom buttons -->\n\
4162
fprintf(js_include_file,"\n<!-- draw zoom buttons -->\n\
4163
draw_zoom_buttons = function(canvas_type,color,opacity){\
4163
draw_zoom_buttons = function(canvas_type,color,opacity){\
4164
 var obj;\
4164
 var obj;\
4165
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4165
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4166
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4166
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4167
 }\
4167
 }\
4168
 else\
4168
 else\
4169
 {\
4169
 {\
Line 4180... Line 4180...
4180
 ctx.fillText(\"\\u2191\",xsize - 60,ysize-2);\
4180
 ctx.fillText(\"\\u2191\",xsize - 60,ysize-2);\
4181
 ctx.fillText(\"\\u2193\",xsize - 75,ysize-2);\
4181
 ctx.fillText(\"\\u2193\",xsize - 75,ysize-2);\
4182
 ctx.fillText(\"\\u00D7\",xsize - 90,ysize-2);\
4182
 ctx.fillText(\"\\u00D7\",xsize - 90,ysize-2);\
4183
 ctx.stroke();\
4183
 ctx.stroke();\
4184
};",canvas_root_id,canvas_root_id,canvas_root_id);
4184
};",canvas_root_id,canvas_root_id,canvas_root_id);
4185
   
4185
 
4186
    break;
4186
    break;
4187
    case DRAW_GRIDFILL:/* not used for userdraw */
4187
    case DRAW_GRIDFILL:/* not used for userdraw */
4188
fprintf(js_include_file,"\n<!-- draw gridfill -->\n\
4188
fprintf(js_include_file,"\n<!-- draw gridfill -->\n\
4189
draw_gridfill = function(canvas_type,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize){\
4189
draw_gridfill = function(canvas_type,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize){\
4190
 var obj;\
4190
 var obj;\
4191
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4191
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4192
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4192
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4193
 }\
4193
 }\
4194
 else\
4194
 else\
4195
 {\
4195
 {\
4196
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4196
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4197
 };\
4197
 };\
4198
 var ctx = obj.getContext(\"2d\");\
4198
 var ctx = obj.getContext(\"2d\");\
4199
 var x,y;\
4199
 var x,y;\
4200
 ctx.save();\
4200
 ctx.save();\
4201
 ctx.strokeStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4201
 ctx.strokeStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4202
 snap_x = dx;snap_y = dy;\
4202
 snap_x = dx;snap_y = dy;\
4203
 for( x = x0 ; x < xsize+dx ; x = x + dx ){\
4203
 for( x = x0 ; x < xsize+dx ; x = x + dx ){\
4204
    ctx.moveTo(x,y0);\
4204
    ctx.moveTo(x,y0);\
4205
    ctx.lineTo(x,ysize);\
4205
    ctx.lineTo(x,ysize);\
4206
 };\
4206
 };\
4207
 for( y = y0 ; y < ysize+dy; y = y + dy ){\
4207
 for( y = y0 ; y < ysize+dy; y = y + dy ){\
4208
    ctx.moveTo(x0,y);\
4208
    ctx.moveTo(x0,y);\
4209
    ctx.lineTo(xsize,y);\
4209
    ctx.lineTo(xsize,y);\
4210
 };\
4210
 };\
4211
 ctx.stroke();\
4211
 ctx.stroke();\
4212
 ctx.restore();\
4212
 ctx.restore();\
4213
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4213
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4214
    break;
4214
    break;
4215
   
4215
 
4216
    case DRAW_IMAGEFILL:/* not  used for userdraw */
4216
    case DRAW_IMAGEFILL:/* not  used for userdraw */
4217
fprintf(js_include_file,"\n<!-- draw imagefill -->\n\
4217
fprintf(js_include_file,"\n<!-- draw imagefill -->\n\
4218
draw_imagefill = function(canvas_type,x0,y0,URL,xsize,ysize){\
4218
draw_imagefill = function(canvas_type,x0,y0,URL,xsize,ysize){\
4219
 var obj;\
4219
 var obj;\
4220
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4220
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4221
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4221
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4222
 }\
4222
 }\
4223
 else\
4223
 else\
4224
 {\
4224
 {\
4225
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4225
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4226
 };\
4226
 };\
4227
 var ctx = obj.getContext(\"2d\");\
4227
 var ctx = obj.getContext(\"2d\");\
4228
 ctx.save();\
4228
 ctx.save();\
4229
 var img = new Image();\
4229
 var img = new Image();\
4230
 img.src = URL;\
4230
 img.src = URL;\
4231
 img.onload = function(){\
4231
 img.onload = function(){\
4232
  if( (img.width > xsize-x0) && (img.height > ysize-y0) ){\
4232
  if( (img.width > xsize-x0) && (img.height > ysize-y0) ){\
Line 4252... Line 4252...
4252
 };\
4252
 };\
4253
 ctx.restore();\
4253
 ctx.restore();\
4254
 return;\
4254
 return;\
4255
};",canvas_root_id,canvas_root_id,canvas_root_id);
4255
};",canvas_root_id,canvas_root_id,canvas_root_id);
4256
    break;
4256
    break;
4257
   
4257
 
4258
    case DRAW_DOTFILL:/* not  used for userdraw */
4258
    case DRAW_DOTFILL:/* not  used for userdraw */
4259
fprintf(js_include_file,"\n<!-- draw dotfill -->\n\
4259
fprintf(js_include_file,"\n<!-- draw dotfill -->\n\
4260
draw_dotfill = function(canvas_type,x0,y0,dx,dy,radius,color,opacity,xsize,ysize){\
4260
draw_dotfill = function(canvas_type,x0,y0,dx,dy,radius,color,opacity,xsize,ysize){\
4261
 var obj;\
4261
 var obj;\
4262
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4262
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4263
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4263
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4264
 }\
4264
 }\
4265
 else\
4265
 else\
4266
 {\
4266
 {\
4267
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4267
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4268
 };\
4268
 };\
4269
 var ctx = obj.getContext(\"2d\");\
4269
 var ctx = obj.getContext(\"2d\");\
Line 4284... Line 4284...
4284
    break;
4284
    break;
4285
 
4285
 
4286
    case DRAW_DIAMONDFILL:/* not used for userdraw */
4286
    case DRAW_DIAMONDFILL:/* not used for userdraw */
4287
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4287
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4288
draw_diamondfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4288
draw_diamondfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4289
  var obj;\
4289
  var obj;\
4290
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4290
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4291
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4291
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4292
 }\
4292
 }\
4293
 else\
4293
 else\
4294
 {\
4294
 {\
4295
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4295
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4296
 };\
4296
 };\
4297
 var ctx = obj.getContext(\"2d\");\
4297
 var ctx = obj.getContext(\"2d\");\
4298
 var x;\
4298
 var x;\
4299
 var y;\
4299
 var y;\
4300
 ctx.save();\
4300
 ctx.save();\
4301
 ctx.lineWidth = linewidth;\
4301
 ctx.lineWidth = linewidth;\
4302
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4302
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4303
 y = ysize;\
4303
 y = ysize;\
4304
 for( x = x0 ; x < xsize ; x = x + dx ){\
4304
 for( x = x0 ; x < xsize ; x = x + dx ){\
4305
  ctx.moveTo(x,y0);\
4305
  ctx.moveTo(x,y0);\
4306
  ctx.lineTo(xsize,y);\
4306
  ctx.lineTo(xsize,y);\
4307
  y = y - dy;\
4307
  y = y - dy;\
4308
 };\
4308
 };\
4309
 y = y0;\
4309
 y = y0;\
4310
 for( x = xsize ; x > 0 ; x = x - dx){\
4310
 for( x = xsize ; x > 0 ; x = x - dx){\
4311
  ctx.moveTo(x,ysize);\
4311
  ctx.moveTo(x,ysize);\
Line 4315... Line 4315...
4315
 x = x0;\
4315
 x = x0;\
4316
 for( y = y0 ; y < ysize ; y = y + dy ){\
4316
 for( y = y0 ; y < ysize ; y = y + dy ){\
4317
  ctx.moveTo(xsize,y);\
4317
  ctx.moveTo(xsize,y);\
4318
  ctx.lineTo(x,ysize);\
4318
  ctx.lineTo(x,ysize);\
4319
  x = x + dx;\
4319
  x = x + dx;\
4320
 };\
4320
 };\
4321
 x = xsize;\
4321
 x = xsize;\
4322
 for( y = ysize ; y > y0 ; y = y - dy ){\
4322
 for( y = ysize ; y > y0 ; y = y - dy ){\
4323
  ctx.moveTo(x,y0);\
4323
  ctx.moveTo(x,y0);\
4324
  ctx.lineTo(x0,y);\
4324
  ctx.lineTo(x0,y);\
4325
  x = x - dx;\
4325
  x = x - dx;\
Line 4327... Line 4327...
4327
 ctx.stroke();\
4327
 ctx.stroke();\
4328
 ctx.restore();\
4328
 ctx.restore();\
4329
 return;\
4329
 return;\
4330
 }",canvas_root_id,canvas_root_id,canvas_root_id);
4330
 }",canvas_root_id,canvas_root_id,canvas_root_id);
4331
    break;
4331
    break;
4332
   
4332
 
4333
    case DRAW_HATCHFILL:/* not used for userdraw */
4333
    case DRAW_HATCHFILL:/* not used for userdraw */
4334
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4334
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4335
draw_hatchfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4335
draw_hatchfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4336
  var obj;\
4336
  var obj;\
4337
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4337
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
Line 4350... Line 4350...
4350
 y = ysize;\
4350
 y = ysize;\
4351
 for( x = x0 ; x < xsize ; x = x + dx ){\
4351
 for( x = x0 ; x < xsize ; x = x + dx ){\
4352
  ctx.moveTo(x,y0);\
4352
  ctx.moveTo(x,y0);\
4353
  ctx.lineTo(xsize,y);\
4353
  ctx.lineTo(xsize,y);\
4354
  y = y - dy;\
4354
  y = y - dy;\
4355
 };\
4355
 };\
4356
 y = y0;\
4356
 y = y0;\
4357
 for( x = xsize ; x >= dx ; x = x - dx){\
4357
 for( x = xsize ; x >= dx ; x = x - dx){\
4358
  ctx.moveTo(x,ysize);\
4358
  ctx.moveTo(x,ysize);\
4359
  ctx.lineTo(x0,y);\
4359
  ctx.lineTo(x0,y);\
4360
  y = y + dy;\
4360
  y = y + dy;\
4361
 };\
4361
 };\
4362
 ctx.stroke();\
4362
 ctx.stroke();\
4363
 ctx.restore();\
4363
 ctx.restore();\
4364
 return;\
4364
 return;\
4365
 };",canvas_root_id,canvas_root_id,canvas_root_id);
4365
 };",canvas_root_id,canvas_root_id,canvas_root_id);
4366
    break;
4366
    break;
4367
    case DRAW_CIRCLES:/*  used for userdraw */
4367
    case DRAW_CIRCLES:/*  used for userdraw */
4368
fprintf(js_include_file,"\n<!-- draw circles -->\n\
4368
fprintf(js_include_file,"\n<!-- draw circles -->\n\
4369
draw_circles = function(ctx,x_points,y_points,radius,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4369
draw_circles = function(ctx,x_points,y_points,radius,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4370
 ctx.save();\
4370
 ctx.save();\
4371
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4371
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4372
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4372
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4373
 ctx.lineWidth = line_width;\
4373
 ctx.lineWidth = line_width;\
4374
 for(var p = 0 ; p < x_points.length ; p++ ){\
4374
 for(var p = 0 ; p < x_points.length ; p++ ){\
4375
  ctx.beginPath();\
4375
  ctx.beginPath();\
4376
  ctx.arc(x_points[p],y_points[p],radius[p],0,2*Math.PI,false);\
4376
  ctx.arc(x_points[p],y_points[p],radius[p],0,2*Math.PI,false);\
4377
  ctx.closePath();\
4377
  ctx.closePath();\
4378
  if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4378
  if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4379
  if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4379
  if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4380
  ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4380
  ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
Line 4404... Line 4404...
4404
 ctx.fillStyle =\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4404
 ctx.fillStyle =\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4405
 for(var p = 0 ; p < x_points.length ; p++ ){\
4405
 for(var p = 0 ; p < x_points.length ; p++ ){\
4406
  ctx.beginPath();\
4406
  ctx.beginPath();\
4407
  ctx.arc(x_points[p],y_points[p],line_width,0,2*Math.PI,false);\
4407
  ctx.arc(x_points[p],y_points[p],line_width,0,2*Math.PI,false);\
4408
  ctx.closePath();ctx.fill();ctx.stroke();\
4408
  ctx.closePath();ctx.fill();ctx.stroke();\
4409
 };\
4409
 };\
4410
 ctx.restore();\
4410
 ctx.restore();\
4411
 return;\
4411
 return;\
4412
};");
4412
};");
4413
    break;
4413
    break;
4414
   
4414
 
4415
    case DRAW_SEGMENTS:/*  used for userdraw */
4415
    case DRAW_SEGMENTS:/*  used for userdraw */
4416
fprintf(js_include_file,"\n<!-- draw segments -->\n\
4416
fprintf(js_include_file,"\n<!-- draw segments -->\n\
4417
draw_segments = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4417
draw_segments = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4418
 ctx.save();\
4418
 ctx.save();\
4419
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4419
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4420
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4420
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4421
 ctx.lineWidth = line_width;\
4421
 ctx.lineWidth = line_width;\
4422
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4422
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4423
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4423
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4424
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4424
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4425
  ctx.beginPath();\
4425
  ctx.beginPath();\
4426
  ctx.moveTo(x_points[p],y_points[p]);\
4426
  ctx.moveTo(x_points[p],y_points[p]);\
4427
  ctx.lineTo(x_points[p+1],y_points[p+1]);\
4427
  ctx.lineTo(x_points[p+1],y_points[p+1]);\
4428
  ctx.closePath();\
4428
  ctx.closePath();\
4429
  ctx.stroke();\
4429
  ctx.stroke();\
4430
  }\
4430
  }\
4431
  ctx.restore();\
4431
  ctx.restore();\
4432
  return;\
4432
  return;\
4433
 };");
4433
 };");
4434
    break;
4434
    break;
4435
   
4435
 
4436
    case DRAW_LINES:/*  used for userdraw */
4436
    case DRAW_LINES:/*  used for userdraw */
4437
fprintf(js_include_file,"\n<!-- draw lines -->\n\
4437
fprintf(js_include_file,"\n<!-- draw lines -->\n\
4438
function calc_line(x1,x2,y1,y2){\
4438
function calc_line(x1,x2,y1,y2){\
4439
 var marge = 2;\
4439
 var marge = 2;\
4440
 if(x1 < x2+marge && x1>x2-marge){\
4440
 if(x1 < x2+marge && x1>x2-marge){\
4441
  return [x1,0,x1,ysize];\
4441
  return [x1,0,x1,ysize];\
4442
 };\
4442
 };\
4443
 if(y1 < y2+marge && y1>y2-marge){\
4443
 if(y1 < y2+marge && y1>y2-marge){\
4444
  return [0,y1,xsize,y1];\
4444
  return [0,y1,xsize,y1];\
4445
 };\
4445
 };\
4446
 var Y1 = y1 - (x1)*(y2 - y1)/(x2 - x1);\
4446
 var Y1 = y1 - (x1)*(y2 - y1)/(x2 - x1);\
4447
 var Y2 = y1 + (xsize - x1)*(y2 - y1)/(x2 - x1);\
4447
 var Y2 = y1 + (xsize - x1)*(y2 - y1)/(x2 - x1);\
Line 4458... Line 4458...
4458
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4458
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4459
  line = calc_line(x_points[p],x_points[p+1],y_points[p],y_points[p+1]);\
4459
  line = calc_line(x_points[p],x_points[p+1],y_points[p],y_points[p+1]);\
4460
  ctx.beginPath();\
4460
  ctx.beginPath();\
4461
  ctx.moveTo(line[0],line[1]);\
4461
  ctx.moveTo(line[0],line[1]);\
4462
  ctx.lineTo(line[2],line[3]);\
4462
  ctx.lineTo(line[2],line[3]);\
4463
  ctx.closePath();\
4463
  ctx.closePath();\
4464
  ctx.stroke();\
4464
  ctx.stroke();\
4465
  }\
4465
  }\
4466
  ctx.restore();\
4466
  ctx.restore();\
4467
  return;\
4467
  return;\
4468
 };");
4468
 };");
4469
    break;
4469
    break;
4470
 
4470
 
4471
    case DRAW_CROSSHAIRS:/*  used for userdraw */
4471
    case DRAW_CROSSHAIRS:/*  used for userdraw */
4472
fprintf(js_include_file,"\n<!-- draw crosshairs  -->\n\
4472
fprintf(js_include_file,"\n<!-- draw crosshairs  -->\n\
Line 4542... Line 4542...
4542
  if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();};\
4542
  if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();};\
4543
  ctx.stroke();\
4543
  ctx.stroke();\
4544
 }\
4544
 }\
4545
 ctx.restore();\
4545
 ctx.restore();\
4546
};");
4546
};");
4547
    break;
4547
    break;
4548
 
4548
 
4549
    case DRAW_ELLIPSES:/* not  used for userdraw */
4549
    case DRAW_ELLIPSES:/* not  used for userdraw */
4550
fprintf(js_include_file,"\n<!-- draw ellipses -->\n\
4550
fprintf(js_include_file,"\n<!-- draw ellipses -->\n\
4551
draw_ellipses = function(canvas_type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
4551
draw_ellipses = function(canvas_type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
4552
 var obj;\
4552
 var obj;\
Line 4572... Line 4572...
4572
  ctx.translate(cx - rx, cy - ry);\
4572
  ctx.translate(cx - rx, cy - ry);\
4573
  ctx.scale(rx, ry);\
4573
  ctx.scale(rx, ry);\
4574
  ctx.arc(1, 1, 1, 0, 2 * Math.PI, false);\
4574
  ctx.arc(1, 1, 1, 0, 2 * Math.PI, false);\
4575
  if( use_filled == 1 ){ctx.fill();}\
4575
  if( use_filled == 1 ){ctx.fill();}\
4576
  ctx.stroke();\
4576
  ctx.stroke();\
4577
 };\
4577
 };\
4578
 ctx.restore();\
4578
 ctx.restore();\
4579
};",canvas_root_id,canvas_root_id,canvas_root_id);
4579
};",canvas_root_id,canvas_root_id,canvas_root_id);
4580
    break;
4580
    break;
4581
 
4581
 
4582
    case DRAW_PATHS: /*  used for userdraw */
4582
    case DRAW_PATHS: /*  used for userdraw */
Line 4596... Line 4596...
4596
 if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4596
 if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4597
 ctx.stroke();\
4597
 ctx.stroke();\
4598
 ctx.restore();\
4598
 ctx.restore();\
4599
 return;\
4599
 return;\
4600
};");
4600
};");
4601
   
4601
 
4602
    break;
4602
    break;
4603
    case DRAW_ARROWS:/*  used for userdraw */
4603
    case DRAW_ARROWS:/*  used for userdraw */
4604
fprintf(js_include_file,"\n<!-- draw arrows -->\n\
4604
fprintf(js_include_file,"\n<!-- draw arrows -->\n\
4605
draw_arrows = function(ctx,x_points,y_points,arrow_head,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,type,use_rotate,angle,use_translate,vector){\
4605
draw_arrows = function(ctx,x_points,y_points,arrow_head,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,type,use_rotate,angle,use_translate,vector){\
4606
 ctx.save();\
4606
 ctx.save();\
Line 4671... Line 4671...
4671
 src.type = \"video/mp4\";\
4671
 src.type = \"video/mp4\";\
4672
 src.src = URL;\
4672
 src.src = URL;\
4673
 video.appendChild(src);\
4673
 video.appendChild(src);\
4674
 video.load();\
4674
 video.load();\
4675
 return;\
4675
 return;\
4676
};");    
4676
};");
4677
    break;
4677
    break;
4678
   
4678
 
4679
    case DRAW_AUDIO:/* not used for userdraw */
4679
    case DRAW_AUDIO:/* not used for userdraw */
4680
fprintf(js_include_file,"\n<!-- draw audio -->\n\
4680
fprintf(js_include_file,"\n<!-- draw audio -->\n\
4681
draw_audio = function(canvas_root_id,x,y,w,h,loop,visible,URL1,URL2){\
4681
draw_audio = function(canvas_root_id,x,y,w,h,loop,visible,URL1,URL2){\
4682
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4682
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4683
 var audio_div = document.createElement(\"div\");\
4683
 var audio_div = document.createElement(\"div\");\
Line 4703... Line 4703...
4703
 audio.appendChild(src2);\
4703
 audio.appendChild(src2);\
4704
 audio.load();\
4704
 audio.load();\
4705
 return;\
4705
 return;\
4706
};");
4706
};");
4707
    break;
4707
    break;
4708
   
4708
 
4709
    case DRAW_HTTP:/* not  used for userdraw */
4709
    case DRAW_HTTP:/* not  used for userdraw */
4710
fprintf(js_include_file,"\n<!-- draw http -->\n\
4710
fprintf(js_include_file,"\n<!-- draw http -->\n\
4711
draw_http = function(canvas_root_id,x,y,w,h,URL){\
4711
draw_http = function(canvas_root_id,x,y,w,h,URL){\
4712
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4712
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4713
 var http_div = document.createElement(\"div\");\
4713
 var http_div = document.createElement(\"div\");\
Line 4717... Line 4717...
4717
 iframe.src = URL;\
4717
 iframe.src = URL;\
4718
 iframe.setAttribute(\"width\",w);\
4718
 iframe.setAttribute(\"width\",w);\
4719
 iframe.setAttribute(\"height\",h);\
4719
 iframe.setAttribute(\"height\",h);\
4720
 return;\
4720
 return;\
4721
};");
4721
};");
4722
    break;
4722
    break;
4723
   
4723
 
4724
    case DRAW_XML:
4724
    case DRAW_XML:
4725
fprintf(js_include_file,"\n<!-- draw xml -->\n\
4725
fprintf(js_include_file,"\n<!-- draw xml -->\n\
4726
draw_xml = function(canvas_root_id,x,y,w,h,mathml,onclick){\
4726
draw_xml = function(canvas_root_id,x,y,w,h,mathml,onclick){\
4727
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4727
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4728
 var xml_div = document.createElement(\"div\");\
4728
 var xml_div = document.createElement(\"div\");\
Line 4742... Line 4742...
4742
 return;\
4742
 return;\
4743
};"
4743
};"
4744
);
4744
);
4745
    break;
4745
    break;
4746
    case DRAW_SGRAPH:
4746
    case DRAW_SGRAPH:
4747
/*
4747
/*
4748
 xstart = given
4748
 xstart = given
4749
 ystart = given
4749
 ystart = given
4750
 sgraph(canvas_type,precision,xmajor,ymajor,xminor,yminor,majorcolor,minorcolor,fontfamily)
4750
 sgraph(canvas_type,precision,xmajor,ymajor,xminor,yminor,majorcolor,minorcolor,fontfamily)
4751
*/
4751
*/
4752
fprintf(js_include_file,"\n<!-- draw sgraph -->\n\
4752
fprintf(js_include_file,"\n<!-- draw sgraph -->\n\
Line 5272... Line 5272...
5272
};\
5272
};\
5273
ctx.restore();\
5273
ctx.restore();\
5274
return;\
5274
return;\
5275
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5275
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5276
    break;
5276
    break;
5277
   
5277
 
5278
    case DRAW_PIECHART:
5278
    case DRAW_PIECHART:
5279
fprintf(js_include_file,"\n<!-- draw piechars -->\n\
5279
fprintf(js_include_file,"\n<!-- draw piechars -->\n\
5280
function draw_piechart(canvas_type,x_center,y_center,radius, data_color_list,fill_opacity,font_size,font_family){\
5280
function draw_piechart(canvas_type,x_center,y_center,radius, data_color_list,fill_opacity,font_size,font_family){\
5281
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5281
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5282
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
5282
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
Line 5328... Line 5328...
5328
   y_offset = parseInt(y_offset + 1.5*font_size);\
5328
   y_offset = parseInt(y_offset + 1.5*font_size);\
5329
  };\
5329
  };\
5330
 };\
5330
 };\
5331
 ctx.restore();\
5331
 ctx.restore();\
5332
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5332
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5333
   
5333
 
5334
    break;
5334
    break;
5335
    case DRAW_ARCS:
5335
    case DRAW_ARCS:
5336
fprintf(js_include_file,"\n<!-- draw arcs -->\n\
5336
fprintf(js_include_file,"\n<!-- draw arcs -->\n\
5337
draw_arc = function(canvas_type,xc,yc,r,start,end,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5337
draw_arc = function(canvas_type,xc,yc,r,start,end,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5338
 var obj;\
5338
 var obj;\
Line 5377... Line 5377...
5377
    ctx.stroke();\
5377
    ctx.stroke();\
5378
    ctx.closePath();\
5378
    ctx.closePath();\
5379
 }\
5379
 }\
5380
 ctx.restore();\
5380
 ctx.restore();\
5381
};",canvas_root_id,canvas_root_id,canvas_root_id);
5381
};",canvas_root_id,canvas_root_id,canvas_root_id);
5382
   
5382
 
5383
    break;
5383
    break;
5384
    case DRAW_TEXTS:
5384
    case DRAW_TEXTS:
5385
fprintf(js_include_file,"\n<!-- draw text -->\n\
5385
fprintf(js_include_file,"\n<!-- draw text -->\n\
5386
draw_text = function(canvas_type,x,y,font_size,font_family,stroke_color,stroke_opacity,angle2,text,use_rotate,angle,use_translate,vector){\
5386
draw_text = function(canvas_type,x,y,font_size,font_family,stroke_color,stroke_opacity,angle2,text,use_rotate,angle,use_translate,vector){\
5387
  var obj;\
5387
  var obj;\
Line 5398... Line 5398...
5398
   if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
5398
   if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
5399
   if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
5399
   if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
5400
  };\
5400
  };\
5401
  if( font_family.indexOf('px') != null ){\
5401
  if( font_family.indexOf('px') != null ){\
5402
   ctx.font = font_family;\
5402
   ctx.font = font_family;\
5403
  }\
5403
  }\
5404
  else\
5404
  else\
5405
  {\
5405
  {\
5406
   ctx.font = \"+font_size+'px '+font_family \";\
5406
   ctx.font = \"+font_size+'px '+font_family \";\
5407
  };\
5407
  };\
5408
  ctx.fillStyle = \"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
5408
  ctx.fillStyle = \"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
5409
  if(angle2 != 0){\
5409
  if(angle2 != 0){\
Line 5414... Line 5414...
5414
   ctx.restore();\
5414
   ctx.restore();\
5415
  }else{ctx.fillText(text,x,y);};\
5415
  }else{ctx.fillText(text,x,y);};\
5416
 ctx.restore();\
5416
 ctx.restore();\
5417
 return;\
5417
 return;\
5418
 };",canvas_root_id,canvas_root_id,canvas_root_id);
5418
 };",canvas_root_id,canvas_root_id,canvas_root_id);
5419
   
5419
 
5420
    break;
5420
    break;
5421
    case DRAW_CURVE:
5421
    case DRAW_CURVE:
5422
fprintf(js_include_file,"\n<!-- draw curve -->\n\
5422
fprintf(js_include_file,"\n<!-- draw curve -->\n\
5423
draw_curve = function(canvas_type,type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5423
draw_curve = function(canvas_type,type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5424
 var obj;\
5424
 var obj;\
Line 5450... Line 5450...
5450
  };\
5450
  };\
5451
 };\
5451
 };\
5452
 ctx.stroke();\
5452
 ctx.stroke();\
5453
 ctx.restore();\
5453
 ctx.restore();\
5454
};",canvas_root_id,canvas_root_id,canvas_root_id);
5454
};",canvas_root_id,canvas_root_id,canvas_root_id);
5455
    break;
5455
    break;
5456
   
5456
 
5457
    case DRAW_INPUTS:
5457
    case DRAW_INPUTS:
5458
fprintf(js_include_file,"\n<!-- draw input fields -->\n\
5458
fprintf(js_include_file,"\n<!-- draw input fields -->\n\
5459
draw_inputs = function(root_id,input_cnt,x,y,size,readonly,style,value){\
5459
draw_inputs = function(root_id,input_cnt,x,y,size,readonly,style,value){\
5460
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5460
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5461
var input = document.createElement(\"input\");\
5461
var input = document.createElement(\"input\");\
Line 5463... Line 5463...
5463
input.setAttribute(\"style\",\"position:absolute;left:\"+x+\"px;top:\"+y+\"px;\"+style);\
5463
input.setAttribute(\"style\",\"position:absolute;left:\"+x+\"px;top:\"+y+\"px;\"+style);\
5464
input.setAttribute(\"size\",size);\
5464
input.setAttribute(\"size\",size);\
5465
input.setAttribute(\"value\",value);\
5465
input.setAttribute(\"value\",value);\
5466
if( readonly == 0 ){ input.setAttribute(\"readonly\",\"readonly\");};\
5466
if( readonly == 0 ){ input.setAttribute(\"readonly\",\"readonly\");};\
5467
canvas_div.appendChild(input);};");
5467
canvas_div.appendChild(input);};");
5468
    break;
5468
    break;
5469
   
5469
 
5470
    case DRAW_TEXTAREAS:
5470
    case DRAW_TEXTAREAS:
5471
fprintf(js_include_file,"\n<!-- draw text area inputfields -->\n\
5471
fprintf(js_include_file,"\n<!-- draw text area inputfields -->\n\
5472
draw_textareas = function(root_id,input_cnt,x,y,cols,rows,readonly,style,value){\
5472
draw_textareas = function(root_id,input_cnt,x,y,cols,rows,readonly,style,value){\
5473
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5473
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5474
var textarea = document.createElement(\"textarea\");\
5474
var textarea = document.createElement(\"textarea\");\
Line 5477... Line 5477...
5477
textarea.setAttribute(\"cols\",cols);\
5477
textarea.setAttribute(\"cols\",cols);\
5478
textarea.setAttribute(\"rows\",rows);\
5478
textarea.setAttribute(\"rows\",rows);\
5479
textarea.innerHTML = value;\
5479
textarea.innerHTML = value;\
5480
canvas_div.appendChild(textarea);};");
5480
canvas_div.appendChild(textarea);};");
5481
    break;
5481
    break;
5482
   
5482
 
5483
case DRAW_PIXELS:
5483
case DRAW_PIXELS:
5484
fprintf(js_include_file,"\n<!-- draw pixel -->\n\
5484
fprintf(js_include_file,"\n<!-- draw pixel -->\n\
5485
draw_setpixel = function(x,y,color,opacity,pixelsize){\
5485
draw_setpixel = function(x,y,color,opacity,pixelsize){\
5486
 var canvas = create_canvas%d(10,xsize,ysize);\
5486
 var canvas = create_canvas%d(10,xsize,ysize);\
5487
 var d = 0.5*pixelsize;\
5487
 var d = 0.5*pixelsize;\
Line 6541... Line 6541...
6541
        }
6541
        }
6542
        if( strcmp(input_type, fellipse) == 0){
6542
        if( strcmp(input_type, fellipse) == 0){
6543
        free(input_type);
6543
        free(input_type);
6544
        use_filled = TRUE;
6544
        use_filled = TRUE;
6545
        return ELLIPSE;
6545
        return ELLIPSE;
6546
        }      
6546
        }
6547
        if( strcmp(input_type, blink) == 0 ){
6547
        if( strcmp(input_type, blink) == 0 ){
6548
        free(input_type);
6548
        free(input_type);
6549
        return BLINK;
6549
        return BLINK;
6550
        }
6550
        }
6551
        if( strcmp(input_type, button) == 0){
6551
        if( strcmp(input_type, button) == 0){
6552
        free(input_type);
6552
        free(input_type);
6553
        return BUTTON;
6553
        return BUTTON;
6554
        }
6554
        }
6555
        if( strcmp(input_type, translation) == 0 ||  strcmp(input_type, translate) == 0  ){
6555
        if( strcmp(input_type, translation) == 0 ||  strcmp(input_type, translate) == 0  ){
6556
        free(input_type);
6556
        free(input_type);
6557
        return TRANSLATION;
6557
        return TRANSLATION;
6558
        }
6558
        }
6559
        if( strcmp(input_type, killtranslation) == 0 ||  strcmp(input_type, killtranslate) == 0){
6559
        if( strcmp(input_type, killtranslation) == 0 ||  strcmp(input_type, killtranslate) == 0){
6560
        free(input_type);
6560
        free(input_type);
6561
        return KILLTRANSLATION;
6561
        return KILLTRANSLATION;
6562
        }
6562
        }
6563
        if( strcmp(input_type, rotate) == 0){
6563
        if( strcmp(input_type, rotate) == 0){
Line 6571... Line 6571...
6571
        if( strcmp(input_type, killaffine) == 0){
6571
        if( strcmp(input_type, killaffine) == 0){
6572
        free(input_type);
6572
        free(input_type);
6573
        return KILLAFFINE;
6573
        return KILLAFFINE;
6574
        }
6574
        }
6575
        if( strcmp(input_type, audio) == 0 ){
6575
        if( strcmp(input_type, audio) == 0 ){
6576
        free(input_type);
6576
        free(input_type);
6577
        return AUDIO;
6577
        return AUDIO;
6578
        }
6578
        }
6579
        if( strcmp(input_type, audioobject) == 0 ){
6579
        if( strcmp(input_type, audioobject) == 0 ){
6580
        free(input_type);
6580
        free(input_type);
6581
        return AUDIOOBJECT;
6581
        return AUDIOOBJECT;
Line 6657... Line 6657...
6657
        return VIDEO;
6657
        return VIDEO;
6658
        }
6658
        }
6659
        if( strcmp(input_type,floodfill) == 0 || strcmp(input_type,fill) == 0 ){
6659
        if( strcmp(input_type,floodfill) == 0 || strcmp(input_type,fill) == 0 ){
6660
        free(input_type);
6660
        free(input_type);
6661
        return FLOODFILL;
6661
        return FLOODFILL;
6662
        }      
6662
        }
6663
        if( strcmp(input_type,filltoborder) == 0 ){
6663
        if( strcmp(input_type,filltoborder) == 0 ){
6664
        free(input_type);
6664
        free(input_type);
6665
        return FILLTOBORDER;
6665
        return FILLTOBORDER;
6666
        }      
6666
        }
6667
        if( strcmp(input_type,clickfill) == 0 ){
6667
        if( strcmp(input_type,clickfill) == 0 ){
6668
        free(input_type);
6668
        free(input_type);
6669
        return CLICKFILL;
6669
        return CLICKFILL;
6670
        }      
6670
        }
6671
        if( strcmp(input_type, replyformat) == 0 ){
6671
        if( strcmp(input_type, replyformat) == 0 ){
6672
        free(input_type);
6672
        free(input_type);
6673
        return REPLYFORMAT;
6673
        return REPLYFORMAT;
6674
        }
6674
        }
6675
        if( strcmp(input_type, pixelsize) == 0 ){
6675
        if( strcmp(input_type, pixelsize) == 0 ){
Line 6721... Line 6721...
6721
        return LEGENDCOLORS;
6721
        return LEGENDCOLORS;
6722
        }
6722
        }
6723
        if( strcmp(input_type, xlabel) == 0  ){
6723
        if( strcmp(input_type, xlabel) == 0  ){
6724
        free(input_type);
6724
        free(input_type);
6725
        return XLABEL;
6725
        return XLABEL;
6726
        }
6726
        }
6727
        if( strcmp(input_type, ylabel) == 0  ){
6727
        if( strcmp(input_type, ylabel) == 0  ){
6728
        free(input_type);
6728
        free(input_type);
6729
        return YLABEL;
6729
        return YLABEL;
6730
        }
6730
        }
6731
        if( strcmp(input_type, animate) == 0  ){
6731
        if( strcmp(input_type, animate) == 0  ){
Line 6779... Line 6779...
6779
        }
6779
        }
6780
        free(input_type);
6780
        free(input_type);
6781
        ungetc(c,infile);
6781
        ungetc(c,infile);
6782
        return 0;
6782
        return 0;
6783
}
6783
}
6784
 
-
 
6785
 
-