Subversion Repositories wimsdev

Rev

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

Rev 8222 Rev 8224
Line 35... Line 35...
35
char    *get_string_argument(FILE *infile,int last); /* the same, but with "comma" as  separator */
35
char    *get_string_argument(FILE *infile,int last); /* the same, but with "comma" as  separator */
36
char    *convert_hex2rgb(char *hexcolor);
36
char    *convert_hex2rgb(char *hexcolor);
37
void    add_read_canvas(int reply_format,int reply_precision);
37
void    add_read_canvas(int reply_format,int reply_precision);
38
void    make_js_include(int canvas_root_id);
38
void    make_js_include(int canvas_root_id);
39
void    check_string_length(int length);/* checks if the length of string argument of command is correct */
39
void    check_string_length(int length);/* checks if the length of string argument of command is correct */
40
FILE    *js_include_file;
40
FILE    *js_include_file;
41
FILE    *get_file(int *line_number, char **filename);
41
FILE    *get_file(int *line_number, char **filename);
42
FILE    *infile;    /* will be stdin */
42
FILE    *infile;    /* will be stdin */
43
/******************************************************************************
43
/******************************************************************************
44
** global
44
** global
45
******************************************************************************/
45
******************************************************************************/
Line 53... Line 53...
53
double ymin = 0.0;
53
double ymin = 0.0;
54
double ymax = 320.0;
54
double ymax = 320.0;
55
double tmax = 2;
55
double tmax = 2;
56
double tmin = -2;
56
double tmin = -2;
57
/* flag to indicate parsing of line status */
57
/* flag to indicate parsing of line status */
58
int done = FALSE;
58
int done = FALSE;
59
int type; /* eg command number */
59
int type; /* eg command number */
60
int onclick = 0;/* 0 = noninteractive ; 1 = onclick ; 2 = draggable*/
60
int onclick = 0;/* 0 = noninteractive ; 1 = onclick ; 2 = draggable*/
61
int slider = 0;/* slider=1 : x-values ; slider=2 : y-values;slider=3 angle values */
61
int slider = 0;/* slider=1 : x-values ; slider=2 : y-values;slider=3 angle values */
62
int use_affine = FALSE;
62
int use_affine = FALSE;
63
int use_rotate = FALSE;
63
int use_rotate = FALSE;
Line 111... Line 111...
111
    int dashtype[2] = { 4 , 4 };
111
    int dashtype[2] = { 4 , 4 };
112
    int js_function[MAX_JS_FUNCTIONS]; /* javascript functions include objects on demand basis : only once per object type */
112
    int js_function[MAX_JS_FUNCTIONS]; /* javascript functions include objects on demand basis : only once per object type */
113
    for(i=0;i<MAX_JS_FUNCTIONS;i++){js_function[i]=0;}
113
    for(i=0;i<MAX_JS_FUNCTIONS;i++){js_function[i]=0;}
114
    int arrow_head = 8; /* size in px*/
114
    int arrow_head = 8; /* size in px*/
115
    int crosshair_size = 5; /* size in px*/
115
    int crosshair_size = 5; /* size in px*/
116
    int plot_steps = 250;
116
    int plot_steps = 250;
117
    int found_size_command = 0; /* 1 = found size ; 2 = found xrange; 3 = found yrange*/
117
    int found_size_command = 0; /* 1 = found size ; 2 = found xrange; 3 = found yrange*/
118
    int click_cnt = 1;
118
    int click_cnt = 1;
119
    int clock_cnt = 0; /* counts the amount of clocks used -> unique object clock%d */
119
    int clock_cnt = 0; /* counts the amount of clocks used -> unique object clock%d */
120
    int linegraph_cnt = 0; /* identifier for command 'linegraph' ; multiple line graphs may be plotted in a single plot*/
120
    int linegraph_cnt = 0; /* identifier for command 'linegraph' ; multiple line graphs may be plotted in a single plot*/
121
    int barchart_cnt = 0; /* identifier for command 'barchart' ; multiple charts may be plotted in a single plot*/
121
    int barchart_cnt = 0; /* identifier for command 'barchart' ; multiple charts may be plotted in a single plot*/
Line 130... Line 130...
130
    double stroke_opacity = 0.8;
130
    double stroke_opacity = 0.8;
131
    double fill_opacity = 0.8;
131
    double fill_opacity = 0.8;
132
    char *URL = "http://localhost/images";
132
    char *URL = "http://localhost/images";
133
    memset(buffer,'\0',MAX_BUFFER);
133
    memset(buffer,'\0',MAX_BUFFER);
134
    void *tmp_buffer = "";
134
    void *tmp_buffer = "";
135
   
135
 
136
    /* default writing a unzipped js-include file into wims getfile directory */
136
    /* default writing a unzipped js-include file into wims getfile directory */
137
    char *w_wims_session = getenv("w_wims_session");
137
    char *w_wims_session = getenv("w_wims_session");
138
    if(  w_wims_session == NULL || *w_wims_session == 0 ){
138
    if(  w_wims_session == NULL || *w_wims_session == 0 ){
139
        canvas_error("Hmmm, your wims environment does not exist...\nCanvasdraw should be used within wims.");
139
        canvas_error("Hmmm, your wims environment does not exist...\nCanvasdraw should be used within wims.");
140
    }
140
    }
141
    int L0=strlen(w_wims_session) + 21;
141
    int L0=strlen(w_wims_session) + 21;
142
    char *getfile_dir = my_newmem(L0); /* create memory to fit string precisely */
142
    char *getfile_dir = my_newmem(L0); /* create memory to fit string precisely */
143
    snprintf(getfile_dir,L0, "../sessions/%s/getfile",w_wims_session);/* string will fit precisely  */
143
    snprintf(getfile_dir,L0, "../sessions/%s/getfile",w_wims_session);/* string will fit precisely  */
144
    mode_t process_mask = umask(0); /* check if file exists */
144
    mode_t process_mask = umask(0); /* check if file exists */
145
    int result = mkdir(getfile_dir, S_IRWXU | S_IRWXG | S_IRWXO);
145
    int result = mkdir(getfile_dir, S_IRWXU | S_IRWXG | S_IRWXO);
146
    if( result == 0 || errno == EEXIST ){
146
    if( result == 0 || errno == EEXIST ){
147
     umask(process_mask); /* be sure to set correct permission */
147
     umask(process_mask); /* be sure to set correct permission */
148
     char *w_session = getenv("w_session");
148
     char *w_session = getenv("w_session");
149
     int L1 = (int) (strlen(w_session)) + find_number_of_digits(canvas_root_id) + 48;
149
     int L1 = (int) (strlen(w_session)) + find_number_of_digits(canvas_root_id) + 48;
150
    char *getfile_cmd = my_newmem(L1); /* create memory to fit string precisely */
150
    char *getfile_cmd = my_newmem(L1); /* create memory to fit string precisely */
151
     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 */   
151
     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 */
152
    /* write the include tag to html page:<script type="text/javascript" src="wims.cgi?session=%s&cmd=getfile&special_parm=11223344_js"></script> */
152
    /* write the include tag to html page:<script type="text/javascript" src="wims.cgi?session=%s&cmd=getfile&special_parm=11223344_js"></script> */
153
    /* now write file into getfile dir*/
153
    /* now write file into getfile dir*/
154
    char *w_wims_home = getenv("w_wims_home"); /* "/home/users/wims" : we need absolute path for location */
154
    char *w_wims_home = getenv("w_wims_home"); /* "/home/users/wims" : we need absolute path for location */
155
    int L2 = (int) (strlen(w_wims_home)) + (int) (strlen(w_wims_session)) + find_number_of_digits(canvas_root_id) + 23;
155
    int L2 = (int) (strlen(w_wims_home)) + (int) (strlen(w_wims_session)) + find_number_of_digits(canvas_root_id) + 23;
156
    char *location = my_newmem(L2); /* create memory to fit string precisely */
156
    char *location = my_newmem(L2); /* create memory to fit string precisely */
Line 166... Line 166...
166
        if(line_number>1 && found_size_command == 0){canvas_error("command \"size xsize,ysize\" needs to come first ! ");}
166
        if(line_number>1 && found_size_command == 0){canvas_error("command \"size xsize,ysize\" needs to come first ! ");}
167
        type = get_token(infile);
167
        type = get_token(infile);
168
        done = FALSE;
168
        done = FALSE;
169
        /*
169
        /*
170
        @canvasdraw
170
        @canvasdraw
171
        @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...)
171
        @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...)
172
        @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><li> all draggable objects may have a slider for translation / rotation; several objects may be translated / rotated by a single slider</li> <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();The replyformat is : object_number : x-orig : y-orig : x-drag : y-drag<br />The x-orig/y-orig will be returned in maximum precision (javascript float)...<br />the x-drag/y-drag will be returned in defined 'precision' number of decimals<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.</li></ul>
172
        @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><li> all draggable objects may have a slider for translation / rotation; several objects may be translated / rotated by a single slider</li> <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();The replyformat is : object_number : x-orig : y-orig : x-drag : y-drag<br />The x-orig/y-orig will be returned in maximum precision (javascript float)...<br />the x-drag/y-drag will be returned in defined 'precision' number of decimals<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.</li></ul>
173
        */
173
        */
174
        switch(type){
174
        switch(type){
175
        case END:
175
        case END:
176
        finished = 1;
176
        finished = 1;
Line 197... Line 197...
197
            ysize = (int)(abs(round(get_real(infile,1))));
197
            ysize = (int)(abs(round(get_real(infile,1))));
198
            /* sometimes we want xrange / yrange to be in pixels...without telling x/y-range */
198
            /* sometimes we want xrange / yrange to be in pixels...without telling x/y-range */
199
            xmin = 0;xmax = xsize;
199
            xmin = 0;xmax = xsize;
200
            ymin = 0;ymax = ysize;
200
            ymin = 0;ymax = ysize;
201
 
201
 
202
/*
202
/*
203
 The sequence in which stuff is finally printed is important !!
203
 The sequence in which stuff is finally printed is important !!
204
 for example, when writing a 'include.js" the may not be a "script tag <script>" etc etc
204
 for example, when writing a 'include.js" the may not be a "script tag <script>" etc etc
205
*/
205
*/
206
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;margin-left:auto;margin-right:auto;\" ></div><div id=\"tooltip_placeholder_div%d\" style=\"display:block;margin-bottom:4px;\"><span id=\"tooltip_placeholder%d\" style=\"display:none;\"></span></div>\n",canvas_root_id,xsize,ysize,canvas_root_id,canvas_root_id);
206
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;margin-left:auto;margin-right:auto;\" ></div><div id=\"tooltip_placeholder_div%d\" style=\"display:block;margin-bottom:4px;\"><span id=\"tooltip_placeholder%d\" style=\"display:none;\"></span></div>\n",canvas_root_id,xsize,ysize,canvas_root_id,canvas_root_id);
207
fprintf(stdout,"<!-- include actual object code via include file -->\n<script type=\"text/javascript\" src=\"%s\"></script>\n",getfile_cmd);
207
fprintf(stdout,"<!-- include actual object code via include file -->\n<script type=\"text/javascript\" src=\"%s\"></script>\n",getfile_cmd);
Line 249... Line 249...
249
add_drag_code(js_include_file,DRAG_CANVAS,canvas_root_id);
249
add_drag_code(js_include_file,DRAG_CANVAS,canvas_root_id);
250
            break;
250
            break;
251
        case XRANGE:
251
        case XRANGE:
252
        /*
252
        /*
253
        @ xrange xmin,xmax
253
        @ xrange xmin,xmax
254
        @ if not given: 0,xsize (eg in pixels)
254
        @ if not given: 0,xsize (eg in pixels)
255
        */
255
        */
256
            for(i = 0 ; i<2; i++){
256
            for(i = 0 ; i<2; i++){
257
                switch(i){
257
                switch(i){
258
                    case 0: xmin = get_real(infile,0);break;
258
                    case 0: xmin = get_real(infile,0);break;
259
                    case 1: xmax = get_real(infile,1);break;
259
                    case 1: xmax = get_real(infile,1);break;
Line 339... Line 339...
339
        case CROSSHAIRS:
339
        case CROSSHAIRS:
340
        /*
340
        /*
341
        @ crosshairs color,x1,y1,x2,y2,...,x_n,y_n
341
        @ crosshairs color,x1,y1,x2,y2,...,x_n,y_n
342
        @ draw multiple crosshair points at given coordinates in color 'color'
342
        @ draw multiple crosshair points at given coordinates in color 'color'
343
        @ use command 'crosshairsize int' and / or 'linewidth int'  to adust
343
        @ use command 'crosshairsize int' and / or 'linewidth int'  to adust
344
        @ may be set draggable / onclick individually (!)
344
        @ may be set draggable / onclick individually (!)
345
        */
345
        */
346
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
346
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
347
            fill_color = stroke_color;
347
            fill_color = stroke_color;
348
            i=0;
348
            i=0;
349
            while( ! done ){     /* get next item until EOL*/
349
            while( ! done ){     /* get next item until EOL*/
350
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
350
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
351
                if(i%2 == 0 ){
351
                if(i%2 == 0 ){
352
                    double_data[i] = get_real(infile,0); /* x */
352
                    double_data[i] = get_real(infile,0); /* x */
353
                }
353
                }
354
                else
354
                else
355
                {
355
                {
356
                    double_data[i] = get_real(infile,1); /* y */
356
                    double_data[i] = get_real(infile,1); /* y */
357
                }
357
                }
358
                i++;
358
                i++;
359
            }
359
            }
360
            decimals = find_number_of_digits(precision);
360
            decimals = find_number_of_digits(precision);
361
            for(c=0 ; c < i-1 ; c = c+2){
361
            for(c=0 ; c < i-1 ; c = c+2){
362
                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,%d,%d));\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,slider,slider_cnt);
362
                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,%d,%d));\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,slider,slider_cnt);
363
                click_cnt++;
363
                click_cnt++;
364
            }
364
            }
365
            reset();
365
            reset();
366
            break;
366
            break;
367
        case POINT:
367
        case POINT:
368
        /*
368
        /*
369
        @ point x,y,color
369
        @ point x,y,color
370
        @ draw a single point at (x;y) in color 'color'
370
        @ draw a single point at (x;y) in color 'color'
371
        @ use command 'linewidth int'  to adust size
371
        @ use command 'linewidth int'  to adust size
372
        @ may be set draggable / onclick
372
        @ may be set draggable / onclick
373
        @ will not resize on zooming <br />(command 'circle x,y,r,color' will resize on zooming)
373
        @ will not resize on zooming <br />(command 'circle x,y,r,color' will resize on zooming)
374
        */
374
        */
375
            for(i=0;i<3;i++){
375
            for(i=0;i<3;i++){
376
                switch(i){
376
                switch(i){
377
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
377
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
378
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
378
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
379
                    case 2: stroke_color = get_color(infile,1);/* name or hex color */
379
                    case 2: stroke_color = get_color(infile,1);/* name or hex color */
380
                    decimals = find_number_of_digits(precision);
380
                    decimals = find_number_of_digits(precision);
381
                    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,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[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,slider,slider_cnt);
381
                    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,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[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,slider,slider_cnt);
382
                    click_cnt++;break;
382
                    click_cnt++;break;
383
                    default: break;
383
                    default: break;
384
                }
384
                }
385
            }
385
            }
386
            reset();
386
            reset();
387
            break;
387
            break;
388
        case POINTS:
388
        case POINTS:
389
        /*
389
        /*
Line 397... Line 397...
397
            i=0;
397
            i=0;
398
            while( ! done ){     /* get next item until EOL*/
398
            while( ! done ){     /* get next item until EOL*/
399
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
399
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
400
                if(i%2 == 0 ){
400
                if(i%2 == 0 ){
401
                    double_data[i] = get_real(infile,0); /* x */
401
                    double_data[i] = get_real(infile,0); /* x */
402
                }
402
                }
403
                else
403
                else
404
                {
404
                {
405
                    double_data[i] = get_real(infile,1); /* y */
405
                    double_data[i] = get_real(infile,1); /* y */
406
                }
406
                }
407
                i++;
407
                i++;
408
            }
408
            }
409
            decimals = find_number_of_digits(precision);           
409
            decimals = find_number_of_digits(precision);
410
            for(c = 0 ; c < i-1 ; c = c+2){
410
            for(c = 0 ; c < i-1 ; c = c+2){
411
                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,%d,%d));\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,slider,slider_cnt);
411
                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,%d,%d));\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,slider,slider_cnt);
412
                click_cnt++;
412
                click_cnt++;
413
            }
413
            }
414
            reset();
414
            reset();
Line 466... Line 466...
466
                        {
466
                        {
467
                        /* m */
467
                        /* m */
468
                        double_data[5] = (double_data[13] - double_data[11]) /(double_data[12] - double_data[10]);
468
                        double_data[5] = (double_data[13] - double_data[11]) /(double_data[12] - double_data[10]);
469
                        /* q */
469
                        /* q */
470
                        double_data[6] = double_data[11] - ((double_data[13] - double_data[11]) /(double_data[12] - double_data[10]))*double_data[10];
470
                        double_data[6] = double_data[11] - ((double_data[13] - double_data[11]) /(double_data[12] - double_data[10]))*double_data[10];
471
                       
471
 
472
                        /*xmin,m*xmin+q,xmax,m*xmax+q*/
472
                        /*xmin,m*xmin+q,xmax,m*xmax+q*/
473
                       
473
 
474
                            double_data[1] = (double_data[5])*(xmin)+(double_data[6]);
474
                            double_data[1] = (double_data[5])*(xmin)+(double_data[6]);
475
                            double_data[3] = (double_data[5])*(xmax)+(double_data[6]);
475
                            double_data[3] = (double_data[5])*(xmax)+(double_data[6]);
476
                            double_data[0] = xmin;
476
                            double_data[0] = xmin;
477
                            double_data[2] = xmax;
477
                            double_data[2] = xmax;
478
                        }
478
                        }
Line 482... Line 482...
482
                    click_cnt++;reset();
482
                    click_cnt++;reset();
483
                    break;
483
                    break;
484
                }
484
                }
485
            }
485
            }
486
            break;
486
            break;
487
        case HLINE:
487
        case HLINE:
488
        /*
488
        /*
489
        @ hline x,y,color
489
        @ hline x,y,color
490
        @ draw a horizontal line through point (x:y) in color 'color'
490
        @ draw a horizontal line through point (x:y) in color 'color'
491
        @ or use command 'curve color,formula' to draw the line <br />(uses more points to draw the line; is however better draggable)
491
        @ or use command 'curve color,formula' to draw the line <br />(uses more points to draw the line; is however better draggable)
492
        @ may be set draggable / onclick
492
        @ may be set draggable / onclick
Line 564... Line 564...
564
                    case 3:double_data[3] = get_real(infile,0);break; /* y-values */
564
                    case 3:double_data[3] = get_real(infile,0);break; /* y-values */
565
                    case 4:int_data[0] = (int) (get_real(infile,0));break; /* radius value in pixels */
565
                    case 4:int_data[0] = (int) (get_real(infile,0));break; /* radius value in pixels */
566
                    case 5:stroke_color = get_color(infile,1);/* name or hex color */
566
                    case 5:stroke_color = get_color(infile,1);/* name or hex color */
567
                        /* ensure no inverted roundrect is produced... */
567
                        /* ensure no inverted roundrect is produced... */
568
                        if( double_data[0] > double_data[2] ){double_data[4] = double_data[0];double_data[0] = double_data[2];double_data[2] = double_data[4];}
568
                        if( double_data[0] > double_data[2] ){double_data[4] = double_data[0];double_data[0] = double_data[2];double_data[2] = double_data[4];}
569
                        if( double_data[3] > double_data[1] ){double_data[4] = double_data[1];double_data[1] = double_data[3];double_data[3] = double_data[4];}
569
                        if( double_data[3] > double_data[1] ){double_data[4] = double_data[1];double_data[1] = double_data[3];double_data[3] = double_data[4];}
570
                        decimals = find_number_of_digits(precision);
570
                        decimals = find_number_of_digits(precision);
571
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,6,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%d,%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],int_data[0],int_data[0],int_data[0],int_data[0],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,slider,slider_cnt);
571
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,6,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%d,%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],int_data[0],int_data[0],int_data[0],int_data[0],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,slider,slider_cnt);
572
                        click_cnt++;reset();
572
                        click_cnt++;reset();
573
                    break;
573
                    break;
574
                }
574
                }
Line 650... Line 650...
650
            /* draw path :  closed & optional filled */
650
            /* draw path :  closed & optional filled */
651
                decimals = find_number_of_digits(precision);
651
                decimals = find_number_of_digits(precision);
652
                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,%d,%d));\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,slider,slider_cnt);
652
                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,%d,%d));\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,slider,slider_cnt);
653
                click_cnt++;reset();
653
                click_cnt++;reset();
654
            break;
654
            break;
655
        case ARC:
655
        case ARC:
656
        /*
656
        /*
657
         @ arc xc,yc,width,height,start_angle,end_angle,color
657
         @ arc xc,yc,width,height,start_angle,end_angle,color
658
         @ can not be set "onclick" or "drag xy"
658
         @ can not be set "onclick" or "drag xy"
659
         @ attention: width == height == radius in pixels
659
         @ attention: width == height == radius in pixels
660
         @ will not zoom in or zoom out (because radius is given in pixels an not in x/y-system !). Panning will work
660
         @ will not zoom in or zoom out (because radius is given in pixels an not in x/y-system !). Panning will work
Line 670... Line 670...
670
                    case 5:double_data[3] = get_real(infile,0);break; /* end angle in degrees */
670
                    case 5:double_data[3] = get_real(infile,0);break; /* end angle in degrees */
671
                    case 6:stroke_color = get_color(infile,1);/* name or hex color */
671
                    case 6:stroke_color = get_color(infile,1);/* name or hex color */
672
                    /* in Shape library:
672
                    /* in Shape library:
673
                        x[0] = x[1] = xc
673
                        x[0] = x[1] = xc
674
                        y[0] = y[1] = yc
674
                        y[0] = y[1] = yc
675
                        w[0] = w[1] = radius = width = height  
675
                        w[0] = w[1] = radius = width = height
676
                        h[0] = start_angle ; h[1] = end_engle
676
                        h[0] = start_angle ; h[1] = end_engle
677
                    */
677
                    */
678
                        decimals = find_number_of_digits(precision);
678
                        decimals = find_number_of_digits(precision);
679
                        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,%d,%d));\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,slider,slider_cnt);
679
                        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,%d,%d));\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,slider,slider_cnt);
680
                        reset();
680
                        reset();
681
                    break;
681
                    break;
682
                }
682
                }
683
            }
683
            }
684
            break;
684
            break;
685
        case ANGLE:
685
        case ANGLE:
686
        /*
686
        /*
687
         @ angle xc,yc,width,start_angle,end_angle,color
687
         @ angle xc,yc,width,start_angle,end_angle,color
688
         @ width is in x-range
688
         @ width is in x-range
689
         @ will zoom in/out
689
         @ will zoom in/out
690
         @ if size is controlled by command 'slider' use radians to set limits of slider.
690
         @ if size is controlled by command 'slider' use radians to set limits of slider.
691
        */
691
        */
692
            for(i=0;i<7;i++){
692
            for(i=0;i<7;i++){
693
                switch(i){
693
                switch(i){
694
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
694
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
695
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
695
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
696
                    case 2:double_data[2] = get_real(infile,0);break; /* width in pixels ! */
696
                    case 2:double_data[2] = get_real(infile,0);break; /* width in pixels ! */
697
                    case 3:double_data[3] = get_real(infile,0);break; /* start angle in degrees */
697
                    case 3:double_data[3] = get_real(infile,0);break; /* start angle in degrees */
698
                    case 4:double_data[4] = get_real(infile,0);break; /* end angle in degrees */
698
                    case 4:double_data[4] = get_real(infile,0);break; /* end angle in degrees */
699
                    case 5:stroke_color = get_color(infile,1);/* name or hex color */
699
                    case 5:stroke_color = get_color(infile,1);/* name or hex color */
700
                        decimals = find_number_of_digits(precision);
700
                        decimals = find_number_of_digits(precision);
701
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,17,[%.*f,%.*f],[%.*f,%.*f],[%.*f,%.*f],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[0],decimals,double_data[1],decimals,double_data[1],decimals,double_data[2],decimals,double_data[2],decimals,double_data[3],decimals,double_data[4],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,slider,slider_cnt);
701
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,17,[%.*f,%.*f],[%.*f,%.*f],[%.*f,%.*f],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[0],decimals,double_data[1],decimals,double_data[1],decimals,double_data[2],decimals,double_data[2],decimals,double_data[3],decimals,double_data[4],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,slider,slider_cnt);
702
                        reset();
702
                        reset();
703
                    break;
703
                    break;
704
                }
704
                }
705
            }
705
            }
706
            break;
706
            break;
707
 
707
 
708
        case ELLIPSE:
708
        case ELLIPSE:
709
        /*
709
        /*
710
        @ ellipse xc,yc,radius_x,radius_y,color
710
        @ ellipse xc,yc,radius_x,radius_y,color
711
        @ a ellipse with center xc/yc in x/y-range
711
        @ a ellipse with center xc/yc in x/y-range
712
        @ radius_x and radius_y are in pixels
712
        @ radius_x and radius_y are in pixels
713
        @ may be set draggable / onclick
713
        @ may be set draggable / onclick
714
        @ will shrink / expand on zoom out / zoom in
714
        @ will shrink / expand on zoom out / zoom in
715
        */
715
        */
716
            for(i=0;i<5;i++){
716
            for(i=0;i<5;i++){
717
                switch(i){
717
                switch(i){
718
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
718
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
719
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
719
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
720
                    case 2:double_data[2] = get_real(infile,0);break; /* rx -> px  */
720
                    case 2:double_data[2] = get_real(infile,0);break; /* rx -> px  */
721
                    case 3:double_data[3] = get_real(infile,0);break; /* ry -> px  */
721
                    case 3:double_data[3] = get_real(infile,0);break; /* ry -> px  */
722
                    case 4:stroke_color = get_color(infile,1);/* name or hex color */
722
                    case 4:stroke_color = get_color(infile,1);/* name or hex color */
723
                        decimals = find_number_of_digits(precision);
723
                        decimals = find_number_of_digits(precision);
724
                        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,%d,%d));\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,slider,slider_cnt);
724
                        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,%d,%d));\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,slider,slider_cnt);
725
                        click_cnt++;reset();
725
                        click_cnt++;reset();
726
                    break;
726
                    break;
Line 744... Line 744...
744
        /*
744
        /*
745
        @ circle xc,yc,width (2*r in pixels),color
745
        @ circle xc,yc,width (2*r in pixels),color
746
        @ use command 'fcircle xc,yc,d,color' or command 'filled' for a filled disk
746
        @ use command 'fcircle xc,yc,d,color' or command 'filled' for a filled disk
747
        @ use command 'fillcolor color' to set the fillcolor
747
        @ use command 'fillcolor color' to set the fillcolor
748
        @ may be set draggable / onclick
748
        @ may be set draggable / onclick
749
        @ will shrink / expand on zoom out / zoom in
749
        @ will shrink / expand on zoom out / zoom in
750
        */
750
        */
751
            for(i=0;i<4;i++){
751
            for(i=0;i<4;i++){
752
                switch(i){
752
                switch(i){
753
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
753
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
754
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
754
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
Line 781... Line 781...
781
                {
781
                {
782
                    double_data[i] = get_real(infile,1); /* y */
782
                    double_data[i] = get_real(infile,1); /* y */
783
                }
783
                }
784
            fprintf(js_include_file,"/* double_data[%d] = %f */\n",i,double_data[i]);
784
            fprintf(js_include_file,"/* double_data[%d] = %f */\n",i,double_data[i]);
785
                i++;
785
                i++;
786
            }
786
            }
787
           
787
 
788
            if( i%2 != 0 ){canvas_error("in command rays: unpaired x or y value");}
788
            if( i%2 != 0 ){canvas_error("in command rays: unpaired x or y value");}
789
            decimals = find_number_of_digits(precision);           
789
            decimals = find_number_of_digits(precision);
790
            for(c=2; c<i;c = c+2){
790
            for(c=2; c<i;c = c+2){
791
                click_cnt++;
791
                click_cnt++;
792
                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,%d,%d));\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,slider,slider_cnt);
792
                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,%d,%d));\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,slider,slider_cnt);
793
            }
793
            }
794
            reset();
794
            reset();
795
            break;
795
            break;
796
        case ARROW:
796
        case ARROW:
797
        /*
797
        /*
798
        @ arrow x1,y1,x2,y2,h,color
798
        @ arrow x1,y1,x2,y2,h,color
799
        @ draw a single headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and in color 'color'
799
        @ draw a single headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and in color 'color'
800
        @ use command 'linewidth int' to adjust thickness of the arrow
800
        @ use command 'linewidth int' to adjust thickness of the arrow
801
        @ may be set draggable / onclick
801
        @ may be set draggable / onclick
802
        */
802
        */
803
            for(i=0;i<6;i++){
803
            for(i=0;i<6;i++){
804
                switch(i){
804
                switch(i){
805
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
805
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
806
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
806
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
807
                    case 2: double_data[2] = get_real(infile,0);break; /* x */
807
                    case 2: double_data[2] = get_real(infile,0);break; /* x */
808
                    case 3: double_data[3] = get_real(infile,0);break; /* y */
808
                    case 3: double_data[3] = get_real(infile,0);break; /* y */
809
                    case 4: arrow_head = (int) get_real(infile,0);break;/* h */
809
                    case 4: arrow_head = (int) get_real(infile,0);break;/* h */
810
                    case 5: stroke_color = get_color(infile,1);/* name or hex color */
810
                    case 5: stroke_color = get_color(infile,1);/* name or hex color */
811
                        decimals = find_number_of_digits(precision);
811
                        decimals = find_number_of_digits(precision);
812
                        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,%d,%d));\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,slider,slider_cnt);
812
                        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,%d,%d));\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,slider,slider_cnt);
813
                        click_cnt++;
813
                        click_cnt++;
814
                        reset();
814
                        reset();
815
                        break;
815
                        break;
816
                }
816
                }
817
            }
817
            }
818
            break;
818
            break;
819
        case ARROW2:
819
        case ARROW2:
820
        /*
820
        /*
821
        @ arrow2 x1,y1,x2,y2,h,color
821
        @ arrow2 x1,y1,x2,y2,h,color
822
        @ draw a double headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and  in color 'color'
822
        @ draw a double headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and  in color 'color'
823
        @ use command 'arrowhead int' to adjust the arrow head size
823
        @ use command 'arrowhead int' to adjust the arrow head size
Line 837... Line 837...
837
                        click_cnt++;reset();
837
                        click_cnt++;reset();
838
                        break;
838
                        break;
839
                }
839
                }
840
            }
840
            }
841
            break;
841
            break;
842
        case PARALLEL:
842
        case PARALLEL:
843
        /*
843
        /*
844
         @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor]
844
         @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor]
845
         @ can not be set "onclick" or "drag xy"
845
         @ can not be set "onclick" or "drag xy"
846
        */
846
        */
847
            for( i = 0;i < 8; i++ ){
847
            for( i = 0;i < 8; i++ ){
848
                switch(i){
848
                switch(i){
849
                    case 0: double_data[0] = get_real(infile,0);break; /* x1-values  -> x-pixels*/
849
                    case 0: double_data[0] = get_real(infile,0);break; /* x1-values  -> x-pixels*/
850
                    case 1: double_data[1] = get_real(infile,0);break; /* y1-values  -> y-pixels*/
850
                    case 1: double_data[1] = get_real(infile,0);break; /* y1-values  -> y-pixels*/
Line 885... Line 885...
885
            }
885
            }
886
            break;
886
            break;
887
        case LATTICE:
887
        case LATTICE:
888
        /*
888
        /*
889
         @lattice x0,y0,xv1,yv1,xv2,yv2,n1,n2,color
889
         @lattice x0,y0,xv1,yv1,xv2,yv2,n1,n2,color
890
         @can not be set "onclick" or "drag xy"
890
         @can not be set "onclick" or "drag xy"
891
        */
891
        */
892
            if( js_function[DRAW_LATTICE] != 1 ){ js_function[DRAW_LATTICE] = 1;}
892
            if( js_function[DRAW_LATTICE] != 1 ){ js_function[DRAW_LATTICE] = 1;}
893
            for( i = 0; i<9; i++){
893
            for( i = 0; i<9; i++){
894
                switch(i){
894
                switch(i){
895
                    case 0: int_data[0] = x2px(get_real(infile,0));break; /* x0-values  -> x-pixels*/
895
                    case 0: int_data[0] = x2px(get_real(infile,0));break; /* x0-values  -> x-pixels*/
Line 946... Line 946...
946
         @ textarea and inputfield are only usable in combination with some 'userdraw draw_ type'
946
         @ textarea and inputfield are only usable in combination with some 'userdraw draw_ type'
947
         @ function may be used any time (e.g. without userdraw)
947
         @ function may be used any time (e.g. without userdraw)
948
        */
948
        */
949
            temp = get_string_argument(infile,1);
949
            temp = get_string_argument(infile,1);
950
            if(strstr(temp,"function") != 0  || strstr(temp,"curve") != 0  || strstr(temp,"plot") != 0 ){
950
            if(strstr(temp,"function") != 0  || strstr(temp,"curve") != 0  || strstr(temp,"plot") != 0 ){
951
             if( js_function[DRAW_JSFUNCTION] != 1 ){
951
             if( js_function[DRAW_JSFUNCTION] != 1 ){
952
              js_function[DRAW_JSFUNCTION] = 1;
952
              js_function[DRAW_JSFUNCTION] = 1;
953
              if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
953
              if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
954
              add_input_jsfunction(js_include_file,canvas_root_id,1,input_style,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
954
              add_input_jsfunction(js_include_file,canvas_root_id,1,input_style,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
955
              input_cnt++;
955
              input_cnt++;
956
             }
956
             }
Line 985... Line 985...
985
            }
985
            }
986
            break;
986
            break;
987
        case USERTEXTAREA_XY:
987
        case USERTEXTAREA_XY:
988
        /*
988
        /*
989
        @ usertextarea_xy
989
        @ usertextarea_xy
990
        @ keyword
990
        @ keyword
991
        @ to be used in combination with command "userdraw object_type,color" wherein object_type is only segment / polyline for the time being...
991
        @ to be used in combination with command "userdraw object_type,color" wherein object_type is only segment / polyline for the time being...
992
        @ if set two textareas are added to the document<br />(one for x-values , one for y-values)
992
        @ if set two textareas are added to the document<br />(one for x-values , one for y-values)
993
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
993
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
994
        @ user drawings will not zoom on zooming (or pan on panning)
994
        @ user drawings will not zoom on zooming (or pan on panning)
995
        */
995
        */
996
            if( use_input_xy != 0 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
996
            if( use_input_xy != 0 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
997
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
997
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
998
            use_input_xy = 2;
998
            use_input_xy = 2;
999
            break;
999
            break;
1000
        case USERINPUT_XY:
1000
        case USERINPUT_XY:
1001
        /*
1001
        /*
1002
        @ userinput_xy
1002
        @ userinput_xy
1003
        @ keyword
1003
        @ keyword
1004
        @ to be used in combination with command "userdraw object_type,color"
1004
        @ to be used in combination with command "userdraw object_type,color"
1005
        @ 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)
1005
        @ 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)
1006
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
1006
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
1007
        @ 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.
1007
        @ 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.
1008
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
1008
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
1009
        @ user drawings will not zoom on zooming (or pan on panning)
1009
        @ user drawings will not zoom on zooming (or pan on panning)
1010
        */
1010
        */
1011
            /* add simple eval check to avoid code injection with unprotected eval(string) */
1011
            /* add simple eval check to avoid code injection with unprotected eval(string) */
1012
            if( use_input_xy != 0 ){canvas_error("userinput_xy can not be combined with usertextarea_xy command");}
1012
            if( use_input_xy != 0 ){canvas_error("userinput_xy can not be combined with usertextarea_xy command");}
1013
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
1013
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
1014
            use_input_xy = 1;
1014
            use_input_xy = 1;
1015
            break;
1015
            break;
Line 1021... Line 1021...
1021
        @ the userinput value will be plotted in the canvas
1021
        @ the userinput value will be plotted in the canvas
1022
        @ this value may be read with 'read_canvas()'. <br />for do it yourself js-scripters : If this is the first inputfield in the script, it's id is canvas_input0
1022
        @ this value may be read with 'read_canvas()'. <br />for do it yourself js-scripters : If this is the first inputfield in the script, it's id is canvas_input0
1023
        @ use before this command 'userinput_function',<br />commands like 'inputstyle some_css' , 'xlabel some_description' , 'opacity int,int' , 'linewidth int' , 'dashed' and 'dashtype int,int' to modify
1023
        @ use before this command 'userinput_function',<br />commands like 'inputstyle some_css' , 'xlabel some_description' , 'opacity int,int' , 'linewidth int' , 'dashed' and 'dashtype int,int' to modify
1024
        @ incompatible with command 'intooltip link_text_or_image' : it uses the tooltip div for adding the inputfield
1024
        @ incompatible with command 'intooltip link_text_or_image' : it uses the tooltip div for adding the inputfield
1025
        */
1025
        */
1026
            if( js_function[DRAW_JSFUNCTION] != 1 ){
1026
            if( js_function[DRAW_JSFUNCTION] != 1 ){
1027
             js_function[DRAW_JSFUNCTION] = 1;
1027
             js_function[DRAW_JSFUNCTION] = 1;
1028
             if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
1028
             if(reply_format == 0){reply_format = 24;}/* read canvas_input values */
1029
             add_input_jsfunction(js_include_file,canvas_root_id,1,input_style,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
1029
             add_input_jsfunction(js_include_file,canvas_root_id,1,input_style,input_cnt,stroke_color,stroke_opacity,line_width,use_dashed,dashtype[0],dashtype[1]);
1030
             input_cnt++;
1030
             input_cnt++;
1031
            }
1031
            }
1032
            if( use_js_math == FALSE){/* add this stuff only once...*/
1032
            if( use_js_math == FALSE){/* add this stuff only once...*/
1033
             add_to_js_math(js_include_file);
1033
             add_to_js_math(js_include_file);
1034
             use_js_math = TRUE;
1034
             use_js_math = TRUE;
1035
            }
1035
            }
1036
            if( use_js_plot == FALSE){
1036
            if( use_js_plot == FALSE){
1037
             use_js_plot = TRUE;
1037
             use_js_plot = TRUE;
1038
             add_jsplot(js_include_file,canvas_root_id); /* this plots the function on JSPLOT_CANVAS */
1038
             add_jsplot(js_include_file,canvas_root_id); /* this plots the function on JSPLOT_CANVAS */
1039
            }
1039
            }
1040
            break;
1040
            break;
1041
        case USERDRAW:
1041
        case USERDRAW:
1042
        /*
1042
        /*
1043
        @ userdraw object_type,color
1043
        @ userdraw object_type,color
1044
        @ implemented object_type: <ul><li>point</li><li>points</li><li>crosshair</li><li>crosshairs</li><li>line</li><li>lines</li><li>vline</li><li>vlines</li><li>hline</li><li>hlines</li><li>segment</li><li>segments</li><li>polyline</li><li>circle</li><li>circles</li><li>arrow</li><li>arrow2 (double arrow)</li><li>arrows</li><li>arrows2 (double 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><li>arc</li><li>arcs</li><li>input<br/>place a single inputfield on 'canvas'<br />use commands 'inputstyle' for css styling: use command 'linewidth' for adjusting the input field size (default 1)</li><li>inputs<br/>place multiple inputfield : placing inputfields on top of each other is not possible</li></ul>
1044
        @ implemented object_type: <ul><li>point</li><li>points</li><li>crosshair</li><li>crosshairs</li><li>line</li><li>lines</li><li>vline</li><li>vlines</li><li>hline</li><li>hlines</li><li>segment</li><li>segments</li><li>polyline</li><li>circle</li><li>circles</li><li>arrow</li><li>arrow2 (double arrow)</li><li>arrows</li><li>arrows2 (double 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><li>arc</li><li>arcs</li><li>input<br/>place a single inputfield on 'canvas'<br />use commands 'inputstyle' for css styling: use command 'linewidth' for adjusting the input field size (default 1)</li><li>inputs<br/>place multiple inputfield : placing inputfields on top of each other is not possible</li></ul>
1045
        @ 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)
1045
        @ 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)
1046
        @ 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
1046
        @ 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
1047
        @ note: object_type polygone: Will be finished (the object is closed) when clicked on the first point of the polygone again.
1047
        @ note: object_type polygone: Will be finished (the object is closed) when clicked on the first point of the polygone again.
1048
        @ 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)
1048
        @ 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)
1049
        @ use command "filled", "opacity int,int"  and "fillcolor color" to trigger coloured filling of fillable objects
1049
        @ use command "filled", "opacity int,int"  and "fillcolor color" to trigger coloured filling of fillable objects
1050
        @ use command "dashed" and/or "dashtype int,int" to trigger dashing
1050
        @ use command "dashed" and/or "dashtype int,int" to trigger dashing
1051
        @ use command "replyformat int" to control / adjust output formatting of javascript function read_canvas();
1051
        @ use command "replyformat int" to control / adjust output formatting of javascript function read_canvas();
1052
        @ may be combined with onclick or drag xy  of other components of flyscript objects (although not very usefull...)
1052
        @ may be combined with onclick or drag xy  of other components of flyscript objects (although not very usefull...)
1053
        @ may be combined with keyword 'userinput_xy' or
1053
        @ may be combined with keyword 'userinput_xy' or
1054
        @ 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.!
1054
        @ 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.!
1055
        */
1055
        */
1056
            if( use_userdraw == TRUE ){ /* only one object type may be drawn*/
1056
            if( use_userdraw == TRUE ){ /* only one object type may be drawn*/
1057
                canvas_error("Only one userdraw primitive may be used: read documentation !!");
1057
                canvas_error("Only one userdraw primitive may be used: read documentation !!");
1058
            }
1058
            }
Line 1062... Line 1062...
1062
            draw_type = get_string_argument(infile,0);
1062
            draw_type = get_string_argument(infile,0);
1063
            stroke_color = get_color(infile,1);
1063
            stroke_color = get_color(infile,1);
1064
            if( strcmp(draw_type,"point") == 0 ){
1064
            if( strcmp(draw_type,"point") == 0 ){
1065
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1065
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1066
                if(reply_format == 0 ){reply_format = 8;}
1066
                if(reply_format == 0 ){reply_format = 8;}
1067
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1067
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1068
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1068
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1069
                if(use_input_xy == 1){
1069
                if(use_input_xy == 1){
1070
                    add_input_circle(js_include_file,1,1);
1070
                    add_input_circle(js_include_file,1,1);
1071
                    add_input_xy(js_include_file,canvas_root_id);
1071
                    add_input_xy(js_include_file,canvas_root_id);
1072
                }
1072
                }
1073
                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);
1073
                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);
1074
            }
1074
            }
Line 1076... Line 1076...
1076
            if( strcmp(draw_type,"points") == 0 ){
1076
            if( strcmp(draw_type,"points") == 0 ){
1077
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1077
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1078
                if(reply_format == 0 ){reply_format = 8;}
1078
                if(reply_format == 0 ){reply_format = 8;}
1079
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1079
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1080
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1080
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1081
                if(use_input_xy == 1){
1081
                if(use_input_xy == 1){
1082
                    add_input_circle(js_include_file,1,2);
1082
                    add_input_circle(js_include_file,1,2);
1083
                    add_input_xy(js_include_file,canvas_root_id);
1083
                    add_input_xy(js_include_file,canvas_root_id);
1084
                }
1084
                }
1085
                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);
1085
                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);
1086
            }
1086
            }
Line 1088... Line 1088...
1088
            if( strcmp(draw_type,"segment") == 0 ){
1088
            if( strcmp(draw_type,"segment") == 0 ){
1089
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1089
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1090
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
1090
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
1091
                if(reply_format == 0){reply_format = 11;}
1091
                if(reply_format == 0){reply_format = 11;}
1092
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1092
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1093
                if(use_input_xy == 1){
1093
                if(use_input_xy == 1){
1094
                    add_input_segment(js_include_file,1);
1094
                    add_input_segment(js_include_file,1);
1095
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1095
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1096
                }
1096
                }
1097
                add_js_segments(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1097
                add_js_segments(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1098
            }
1098
            }
Line 1111... Line 1111...
1111
            if( strcmp(draw_type,"segments") == 0 ){
1111
            if( strcmp(draw_type,"segments") == 0 ){
1112
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1112
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1113
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
1113
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
1114
                if(reply_format == 0){reply_format = 11;}
1114
                if(reply_format == 0){reply_format = 11;}
1115
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1115
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1116
                if(use_input_xy == 1){
1116
                if(use_input_xy == 1){
1117
                    add_input_segment(js_include_file,2);
1117
                    add_input_segment(js_include_file,2);
1118
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1118
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1119
                }
1119
                }
1120
                add_js_segments(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1120
                add_js_segments(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1121
            }
1121
            }
1122
            else
1122
            else
1123
            if( strcmp(draw_type,"circle") == 0 ){
1123
            if( strcmp(draw_type,"circle") == 0 ){
1124
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1124
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1125
                if(reply_format == 0){reply_format = 10;}
1125
                if(reply_format == 0){reply_format = 10;}
1126
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1126
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1127
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1127
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1128
                if(use_input_xy == 1){
1128
                if(use_input_xy == 1){
1129
                    add_input_circle(js_include_file,2,1);
1129
                    add_input_circle(js_include_file,2,1);
1130
                    add_input_xyr(js_include_file,canvas_root_id);
1130
                    add_input_xyr(js_include_file,canvas_root_id);
1131
                }
1131
                }
1132
                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]);
1132
                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]);
1133
            }
1133
            }
Line 1135... Line 1135...
1135
            if( strcmp(draw_type,"circles") == 0 ){
1135
            if( strcmp(draw_type,"circles") == 0 ){
1136
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1136
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1137
                if(reply_format == 0){reply_format = 10;}
1137
                if(reply_format == 0){reply_format = 10;}
1138
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1138
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1139
                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]);
1139
                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]);
1140
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1140
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1141
                if(use_input_xy == 1){
1141
                if(use_input_xy == 1){
1142
                    add_input_circle(js_include_file,2,2);
1142
                    add_input_circle(js_include_file,2,2);
1143
                    add_input_xyr(js_include_file,canvas_root_id);
1143
                    add_input_xyr(js_include_file,canvas_root_id);
1144
                }
1144
                }
1145
            }
1145
            }
1146
            else
1146
            else
Line 1148... Line 1148...
1148
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1148
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1149
                if(reply_format == 0){reply_format = 8;}
1149
                if(reply_format == 0){reply_format = 8;}
1150
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1150
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1151
                add_js_crosshairs(js_include_file,1,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1151
                add_js_crosshairs(js_include_file,1,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1152
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1152
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1153
                if(use_input_xy == 1){
1153
                if(use_input_xy == 1){
1154
                    add_input_crosshair(js_include_file,1);
1154
                    add_input_crosshair(js_include_file,1);
1155
                    add_input_xy(js_include_file,canvas_root_id);
1155
                    add_input_xy(js_include_file,canvas_root_id);
1156
                }
1156
                }
1157
            }
1157
            }
1158
            else
1158
            else
1159
            if(strcmp(draw_type,"crosshairs") == 0 ){
1159
            if(strcmp(draw_type,"crosshairs") == 0 ){
1160
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1160
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1161
                if(reply_format == 0){reply_format = 8;}
1161
                if(reply_format == 0){reply_format = 8;}
1162
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1162
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1163
                add_js_crosshairs(js_include_file,2,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1163
                add_js_crosshairs(js_include_file,2,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1164
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1164
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1165
                if(use_input_xy == 1){
1165
                if(use_input_xy == 1){
1166
                    add_input_crosshair(js_include_file,2);
1166
                    add_input_crosshair(js_include_file,2);
1167
                    add_input_xy(js_include_file,canvas_root_id);
1167
                    add_input_xy(js_include_file,canvas_root_id);
1168
                }
1168
                }
1169
            }
1169
            }
1170
            else
1170
            else
1171
            if(strcmp(draw_type,"freehandline") == 0 ){
1171
            if(strcmp(draw_type,"freehandline") == 0 ){
1172
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1172
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1173
                if(reply_format == 0){reply_format = 6;}
1173
                if(reply_format == 0){reply_format = 6;}
1174
                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]);  
1174
                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]);
1175
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1175
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1176
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1176
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1177
            }
1177
            }
1178
            else
1178
            else
1179
            if(strcmp(draw_type,"freehandlines") == 0 ){
1179
            if(strcmp(draw_type,"freehandlines") == 0 ){
1180
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1180
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1181
                if(reply_format == 0){reply_format = 6;}
1181
                if(reply_format == 0){reply_format = 6;}
1182
                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]);  
1182
                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]);
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
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1184
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1185
            }
1185
            }
1186
            else
1186
            else
1187
            if(strcmp(draw_type,"path") == 0 ){
1187
            if(strcmp(draw_type,"path") == 0 ){
1188
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1188
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1189
                if(reply_format == 0){reply_format = 6;}
1189
                if(reply_format == 0){reply_format = 6;}
1190
                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]);  
1190
                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]);
1191
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1191
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1192
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1192
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1193
            }
1193
            }
1194
            else
1194
            else
1195
            if(strcmp(draw_type,"paths") == 0 ){
1195
            if(strcmp(draw_type,"paths") == 0 ){
1196
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1196
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1197
                if(reply_format == 0){reply_format = 6;}
1197
                if(reply_format == 0){reply_format = 6;}
1198
                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]);  
1198
                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]);
1199
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1199
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1200
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1200
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1201
            }
1201
            }
1202
            else
1202
            else
1203
            if(strcmp(draw_type,"arrows") == 0 ){
1203
            if(strcmp(draw_type,"arrows") == 0 ){
1204
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1204
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1205
                if(reply_format == 0){reply_format = 11;}
1205
                if(reply_format == 0){reply_format = 11;}
1206
                add_js_arrows(js_include_file,2,draw_type,line_width,1,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1206
                add_js_arrows(js_include_file,2,draw_type,line_width,1,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1207
                if(use_input_xy == 1){
1207
                if(use_input_xy == 1){
1208
                    add_input_arrow(js_include_file,2);
1208
                    add_input_arrow(js_include_file,2);
1209
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1209
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1210
                }
1210
                }
1211
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1211
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1212
            }
1212
            }
1213
            else
1213
            else
1214
            if(strcmp(draw_type,"arrows2") == 0 ){
1214
            if(strcmp(draw_type,"arrows2") == 0 ){
1215
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1215
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1216
                if(reply_format == 0){reply_format = 11;}
1216
                if(reply_format == 0){reply_format = 11;}
1217
                add_js_arrows(js_include_file,2,draw_type,line_width,2,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1217
                add_js_arrows(js_include_file,2,draw_type,line_width,2,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1218
                if(use_input_xy == 1){
1218
                if(use_input_xy == 1){
1219
                    add_input_arrow(js_include_file,1);
1219
                    add_input_arrow(js_include_file,1);
1220
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1220
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1221
                }
1221
                }
1222
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1222
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1223
            }
1223
            }
1224
            else
1224
            else
1225
            if(strcmp(draw_type,"arrow2") == 0 ){
1225
            if(strcmp(draw_type,"arrow2") == 0 ){
1226
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1226
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1227
                if(reply_format == 0){reply_format = 11;}
1227
                if(reply_format == 0){reply_format = 11;}
1228
                add_js_arrows(js_include_file,1,draw_type,line_width,2,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1228
                add_js_arrows(js_include_file,1,draw_type,line_width,2,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1229
                if(use_input_xy == 1){
1229
                if(use_input_xy == 1){
1230
                    add_input_arrow(js_include_file,1);
1230
                    add_input_arrow(js_include_file,1);
1231
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1231
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1232
                }
1232
                }
1233
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1233
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1234
            }
1234
            }
1235
            else
1235
            else
1236
            if(strcmp(draw_type,"arrow") == 0 ){
1236
            if(strcmp(draw_type,"arrow") == 0 ){
1237
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1237
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1238
                if(reply_format == 0){reply_format = 11;}
1238
                if(reply_format == 0){reply_format = 11;}
1239
                add_js_arrows(js_include_file,1,draw_type,line_width,1,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1239
                add_js_arrows(js_include_file,1,draw_type,line_width,1,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1240
                if(use_input_xy == 1){
1240
                if(use_input_xy == 1){
1241
                    add_input_arrow(js_include_file,1);
1241
                    add_input_arrow(js_include_file,1);
1242
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1242
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1243
                }
1243
                }
1244
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1244
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1245
            }
1245
            }
1246
            else
1246
            else
1247
            if(strcmp(draw_type,"polygon") == 0){
1247
            if(strcmp(draw_type,"polygon") == 0){
1248
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1248
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1249
                if(reply_format == 0){reply_format = 2;}
1249
                if(reply_format == 0){reply_format = 2;}
1250
                add_js_poly(js_include_file,-1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
1250
                add_js_poly(js_include_file,-1,draw_type,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype[0],dashtype[1]);
Line 1252... Line 1252...
1252
                if(use_input_xy == 2){
1252
                if(use_input_xy == 2){
1253
                  add_textarea_polygon(js_include_file);
1253
                  add_textarea_polygon(js_include_file);
1254
                  add_textarea_xy(js_include_file,canvas_root_id);
1254
                  add_textarea_xy(js_include_file,canvas_root_id);
1255
                }
1255
                }
1256
            }
1256
            }
1257
            else
1257
            else
1258
            if(strncmp(draw_type,"poly",4) == 0){
1258
            if(strncmp(draw_type,"poly",4) == 0){
1259
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1259
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1260
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1260
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1261
                if(reply_format == 0){reply_format = 2;}
1261
                if(reply_format == 0){reply_format = 2;}
1262
                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]);
1262
                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]);
1263
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1263
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1264
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1264
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1265
            }
1265
            }
1266
            else
1266
            else
1267
            if(strcmp(draw_type,"triangle") == 0){
1267
            if(strcmp(draw_type,"triangle") == 0){
1268
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1268
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1269
                if(reply_format == 0){reply_format = 2;}
1269
                if(reply_format == 0){reply_format = 2;}
1270
                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]);
1270
                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]);
1271
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1271
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1272
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1272
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1273
            }
1273
            }
1274
            else
1274
            else
1275
            if( strcmp(draw_type,"hline") == 0 ){
1275
            if( strcmp(draw_type,"hline") == 0 ){
1276
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1276
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1277
                if(reply_format == 0){reply_format = 11;}
1277
                if(reply_format == 0){reply_format = 11;}
1278
                add_js_hlines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1278
                add_js_hlines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1279
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1279
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
Line 1333... Line 1333...
1333
                if(reply_format == 0){reply_format = 2;}
1333
                if(reply_format == 0){reply_format = 2;}
1334
                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]);
1334
                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]);
1335
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1335
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1336
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1336
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1337
            }
1337
            }
1338
            else
1338
            else
1339
            if( strcmp(draw_type,"roundrects") == 0){
1339
            if( strcmp(draw_type,"roundrects") == 0){
1340
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1340
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1341
                if(reply_format == 0){reply_format = 2;}
1341
                if(reply_format == 0){reply_format = 2;}
1342
                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]);
1342
                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]);
1343
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1343
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1344
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1344
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1345
            }
1345
            }
1346
            else
1346
            else
1347
            if( strcmp(draw_type,"rect") == 0){
1347
            if( strcmp(draw_type,"rect") == 0){
1348
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1348
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1349
                if(reply_format == 0){reply_format = 2;}
1349
                if(reply_format == 0){reply_format = 2;}
1350
                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]);
1350
                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]);
1351
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1351
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1352
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1352
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1353
            }
1353
            }
1354
            else
1354
            else
1355
            if( strcmp(draw_type,"roundrect") == 0){
1355
            if( strcmp(draw_type,"roundrect") == 0){
1356
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1356
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1357
                if(reply_format == 0){reply_format = 2;}
1357
                if(reply_format == 0){reply_format = 2;}
1358
                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]);
1358
                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]);
1359
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1359
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
Line 1375... Line 1375...
1375
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1375
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1376
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1376
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1377
            }
1377
            }
1378
            else
1378
            else
1379
            if( strcmp(draw_type,"text") == 0){
1379
            if( strcmp(draw_type,"text") == 0){
1380
                if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}      
1380
                if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}
1381
                if(reply_format == 0){reply_format = 17;}
1381
                if(reply_format == 0){reply_format = 17;}
1382
                add_js_text(js_include_file,canvas_root_id,font_size,font_family,font_color,stroke_opacity);
1382
                add_js_text(js_include_file,canvas_root_id,font_size,font_family,font_color,stroke_opacity);
1383
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1383
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1384
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1384
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1385
            }
1385
            }
1386
            else
1386
            else
1387
            if( strcmp(draw_type,"inputs") == 0){
1387
            if( strcmp(draw_type,"inputs") == 0){
1388
                if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}    
1388
                if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}
1389
                if(reply_format == 0){reply_format = 27;}
1389
                if(reply_format == 0){reply_format = 27;}
1390
                add_js_inputs(js_include_file,canvas_root_id,2,input_cnt,input_style,line_width);
1390
                add_js_inputs(js_include_file,canvas_root_id,2,input_cnt,input_style,line_width);
1391
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1391
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1392
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1392
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1393
            }
1393
            }
1394
            else
1394
            else
1395
            if( strcmp(draw_type,"input") == 0){
1395
            if( strcmp(draw_type,"input") == 0){
1396
                if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}    
1396
                if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}
1397
                if(reply_format == 0){reply_format = 27;}
1397
                if(reply_format == 0){reply_format = 27;}
1398
                add_js_inputs(js_include_file,canvas_root_id,1,input_cnt,input_style,line_width);
1398
                add_js_inputs(js_include_file,canvas_root_id,1,input_cnt,input_style,line_width);
1399
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1399
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1400
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1400
                if(use_input_xy == 2){ canvas_error("usertextarea_xy not yet implemented for this userdraw type !");}
1401
            }
1401
            }
Line 1468... Line 1468...
1468
        case TRACE_JSCURVE:
1468
        case TRACE_JSCURVE:
1469
        /*
1469
        /*
1470
         @trace_jscurve some_math_function
1470
         @trace_jscurve some_math_function
1471
         @will use a crosshair to trace the jsmath curve
1471
         @will use a crosshair to trace the jsmath curve
1472
         @two inputfields will display the current x/y-values (numerical evaluation by javascript)
1472
         @two inputfields will display the current x/y-values (numerical evaluation by javascript)
1473
         @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  
1473
         @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
1474
         @use linewidth,strokecolor,crosshairsize to adjust the corsshair.
1474
         @use linewidth,strokecolor,crosshairsize to adjust the corsshair.
1475
         @the client browser will convert your math function to javascript math.<br />use parenthesis and rawmath : use 2*x in stead of 2x etc etc<br />no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1475
         @the client browser will convert your math function to javascript math.<br />use parenthesis and rawmath : use 2*x in stead of 2x etc etc<br />no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1476
        */
1476
        */
1477
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1477
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1478
            if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1478
            if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
Line 1484... Line 1484...
1484
            break;
1484
            break;
1485
        case JSMATH:
1485
        case JSMATH:
1486
        /*
1486
        /*
1487
            @jsmath some_math_function
1487
            @jsmath some_math_function
1488
            @will calculate an y-value from a userinput x-value and draws a crosshair on these coordinates.
1488
            @will calculate an y-value from a userinput x-value and draws a crosshair on these coordinates.
1489
            @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  
1489
            @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
1490
            @example: jsmath sin(x^2)
1490
            @example: jsmath sin(x^2)
1491
            @the client browser will convert your math function to javascript math.<br />use parenthesis and rawmath : use 2*x in stead of 2x etc etc<br />no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1491
            @the client browser will convert your math function to javascript math.<br />use parenthesis and rawmath : use 2*x in stead of 2x etc etc<br />no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1492
        */
1492
        */
1493
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1493
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1494
            if( use_js_math == FALSE){
1494
            if( use_js_math == FALSE){
1495
                add_to_js_math(js_include_file);
1495
                add_to_js_math(js_include_file);
1496
                use_js_math = TRUE;
1496
                use_js_math = TRUE;
1497
            }
1497
            }
1498
            add_calc_y(js_include_file,canvas_root_id,get_string(infile,1));
1498
            add_calc_y(js_include_file,canvas_root_id,get_string(infile,1));
1499
            break;
1499
            break;
1500
        case JSCURVE:
1500
        case JSCURVE:
1501
        /*
1501
        /*
1502
         @jscurve color,formula(x)
1502
         @jscurve color,formula(x)
1503
         @your function will be plotted by the javascript engine of the client browser.
1503
         @your function will be plotted by the javascript engine of the client browser.
1504
         @use only basic math in your curve:<br /> sqrt,^,asin,acos,atan,log,pi,abs,sin,cos,tan,e
1504
         @use only basic math in your curve:<br /> sqrt,^,asin,acos,atan,log,pi,abs,sin,cos,tan,e
Line 1507... Line 1507...
1507
         @no validity check is done by wims.
1507
         @no validity check is done by wims.
1508
         @zooming & panning are implemented :<br />use command 'zoom color' for mouse driven zooming<br />or use keyword 'setlimits' for inputfields setting xmin/xmax, ymin/ymax
1508
         @zooming & panning are implemented :<br />use command 'zoom color' for mouse driven zooming<br />or use keyword 'setlimits' for inputfields setting xmin/xmax, ymin/ymax
1509
         @use command 'trace_jscurve formula(x)` for tracing
1509
         @use command 'trace_jscurve formula(x)` for tracing
1510
         @use commmand 'jsmath  formula(x)` for calculating and displaying indiviual points on the curve
1510
         @use commmand 'jsmath  formula(x)` for calculating and displaying indiviual points on the curve
1511
         @can not be set draggable / onclick (yet)
1511
         @can not be set draggable / onclick (yet)
1512
         @commands plotjump / plotstep are not active for 'jscurve'
1512
         @commands plotjump / plotstep are not active for 'jscurve'
1513
        */
1513
        */
1514
            stroke_color = get_color(infile,0);
1514
            stroke_color = get_color(infile,0);
1515
            if( use_js_math == FALSE){/* add this stuff only once...*/
1515
            if( use_js_math == FALSE){/* add this stuff only once...*/
1516
                add_to_js_math(js_include_file);
1516
                add_to_js_math(js_include_file);
1517
                use_js_math = TRUE;
1517
                use_js_math = TRUE;
Line 1548... Line 1548...
1548
            }
1548
            }
1549
            else
1549
            else
1550
            {
1550
            {
1551
                stroke_color = get_color(infile,0);
1551
                stroke_color = get_color(infile,0);
1552
                char *fun1 = get_string_argument(infile,1);
1552
                char *fun1 = get_string_argument(infile,1);
1553
                if( strlen(fun1) == 0 ){canvas_error("function is NOT OK !");} 
1553
                if( strlen(fun1) == 0 ){canvas_error("function is NOT OK !");}
1554
                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,%d,%d));\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,slider,slider_cnt);
1554
                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,%d,%d));\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,slider,slider_cnt);
1555
                click_cnt++;
1555
                click_cnt++;
1556
            }
1556
            }
1557
            animation_type = 9;/* reset to curve plotting without animation */
1557
            animation_type = 9;/* reset to curve plotting without animation */
1558
            reset();
1558
            reset();
1559
            break;
1559
            break;
1560
        case FLY_TEXT:
1560
        case FLY_TEXT:
1561
        /*
1561
        /*
1562
        @ text fontcolor,x,y,font,text_string
1562
        @ text fontcolor,x,y,font,text_string
1563
        @ font may be described by keywords : giant,huge,normal,small,tiny
1563
        @ font may be described by keywords : giant,huge,normal,small,tiny
1564
        @ use command 'fontsize' to increase base fontsize for these keywords
1564
        @ use command 'fontsize' to increase base fontsize for these keywords
1565
        @ may be set "onclick" or "drag xy"
1565
        @ may be set "onclick" or "drag xy"
1566
        @ backwards compatible with flydraw
1566
        @ backwards compatible with flydraw
1567
        @ unicode supported: text red,0,0,huge,\\u2232
1567
        @ unicode supported: text red,0,0,huge,\\u2232
1568
        @ use command 'string' combined with 'fontfamily' for a more fine grained control over html5 canvas text element
1568
        @ use command 'string' combined with 'fontfamily' for a more fine grained control over html5 canvas text element
1569
        @ 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 reset 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1569
        @ 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 reset 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
Line 1579... Line 1579...
1579
                            }
1579
                            }
1580
                            else
1580
                            else
1581
                            {
1581
                            {
1582
                                if(strcmp(fly_font,"huge") == 0){
1582
                                if(strcmp(fly_font,"huge") == 0){
1583
                                    font_size = (int)(font_size + 14);
1583
                                    font_size = (int)(font_size + 14);
1584
                                }
1584
                                }
1585
                                else
1585
                                else
1586
                                {
1586
                                {
1587
                                    if(strcmp(fly_font,"large") == 0){
1587
                                    if(strcmp(fly_font,"large") == 0){
1588
                                        font_size = (int)(font_size + 6);
1588
                                        font_size = (int)(font_size + 6);
1589
                                        }
1589
                                        }
Line 1595... Line 1595...
1595
                                        }
1595
                                        }
1596
                                    }
1596
                                    }
1597
                                }
1597
                                }
1598
                            }
1598
                            }
1599
                            break; /* font_size ! */
1599
                            break; /* font_size ! */
1600
                    case 4:
1600
                    case 4:
1601
                        temp = get_string_argument(infile,1);
1601
                        temp = get_string_argument(infile,1);
1602
                        decimals = find_number_of_digits(precision);
1602
                        decimals = find_number_of_digits(precision);
1603
                        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,%f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\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,use_rotate,angle,temp,font_size,font_family,use_affine,affine_matrix,slider,slider_cnt);
1603
                        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,%f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\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,use_rotate,angle,temp,font_size,font_family,use_affine,affine_matrix,slider,slider_cnt);
1604
                        click_cnt++;reset();break;
1604
                        click_cnt++;reset();break;
1605
                    default:break;
1605
                    default:break;
Line 1607... Line 1607...
1607
            }
1607
            }
1608
            break;
1608
            break;
1609
        case FLY_TEXTUP:
1609
        case FLY_TEXTUP:
1610
        /*
1610
        /*
1611
         @ textup fontcolor,x,y,font,text_string
1611
         @ textup fontcolor,x,y,font,text_string
1612
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1612
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1613
         @ font may be described by keywords : giant,huge,normal,small,tiny
1613
         @ font may be described by keywords : giant,huge,normal,small,tiny
1614
         @ use command 'fontsize' to increase base fontsize for the keywords
1614
         @ use command 'fontsize' to increase base fontsize for the keywords
1615
         @ backwards compatible with flydraw
1615
         @ backwards compatible with flydraw
1616
         @ unicode supported: textup red,0,0,huge,\\u2232
1616
         @ unicode supported: textup red,0,0,huge,\\u2232
1617
         @ use command 'stringup' and 'fontfamily' for a more fine grained control over html5 canvas text element
1617
         @ use command 'stringup' and 'fontfamily' for a more fine grained control over html5 canvas text element
1618
         @ 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 reset 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1618
         @ 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 reset 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1619
        */
1619
        */
1620
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}  
1620
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}
1621
            for(i = 0; i<5 ;i++){
1621
            for(i = 0; i<5 ;i++){
1622
                switch(i){
1622
                switch(i){
1623
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1623
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1624
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1624
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1625
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
1625
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
Line 1645... Line 1645...
1645
                                        }
1645
                                        }
1646
                                    }
1646
                                    }
1647
                                }
1647
                                }
1648
                            }
1648
                            }
1649
                            break; /* font_size ! */
1649
                            break; /* font_size ! */
1650
                    case 4:
1650
                    case 4:
1651
                    decimals = find_number_of_digits(precision);
1651
                    decimals = find_number_of_digits(precision);
1652
                    temp = get_string_argument(infile,1);
1652
                    temp = get_string_argument(infile,1);
1653
                    string_length = snprintf(NULL,0,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,%s);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_affine,affine_matrix);
1653
                    string_length = snprintf(NULL,0,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,%s);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_affine,affine_matrix);
1654
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1654
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1655
                    snprintf(tmp_buffer,string_length,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,%s);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_affine,affine_matrix);
1655
                    snprintf(tmp_buffer,string_length,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,%s);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_affine,affine_matrix);
Line 1669... Line 1669...
1669
         @ use correct syntax : 'font style' 'font size'px 'fontfamily'
1669
         @ use correct syntax : 'font style' 'font size'px 'fontfamily'
1670
        */
1670
        */
1671
            font_family = get_string(infile,1);
1671
            font_family = get_string(infile,1);
1672
            break;
1672
            break;
1673
        case STRINGUP:
1673
        case STRINGUP:
1674
        /*
1674
        /*
1675
         @ stringup color,x,y,rotation_degrees,the text string
1675
         @ stringup color,x,y,rotation_degrees,the text string
1676
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1676
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1677
         @ unicode supported: stringup red,0,0,45,\\u2232
1677
         @ unicode supported: stringup red,0,0,45,\\u2232
1678
         @ use a command like 'fontfamily bold 34px Courier' <br />to set fonts on browser that support font change
1678
         @ use a command like 'fontfamily bold 34px Courier' <br />to set fonts on browser that support font change
1679
 
1679
 
1680
        */
1680
        */
Line 1696... Line 1696...
1696
                }
1696
                }
1697
            }
1697
            }
1698
            reset();
1698
            reset();
1699
            break;
1699
            break;
1700
        case STRING:
1700
        case STRING:
1701
        /*
1701
        /*
1702
         @ string color,x,y,the text string
1702
         @ string color,x,y,the text string
1703
         @ may be set "onclick" or "drag xy"
1703
         @ may be set "onclick" or "drag xy"
1704
         @ unicode supported: string red,0,0,\\u2232
1704
         @ unicode supported: string red,0,0,\\u2232
1705
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1705
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1706
        */
1706
        */
1707
            for(i=0;i<5;i++){
1707
            for(i=0;i<5;i++){
1708
                switch(i){
1708
                switch(i){
1709
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1709
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1710
                    case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/
1710
                    case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/
Line 1717... Line 1717...
1717
                    default:break;
1717
                    default:break;
1718
                }
1718
                }
1719
            }
1719
            }
1720
            break;
1720
            break;
1721
        case CENTERSTRING:
1721
        case CENTERSTRING:
1722
        /*
1722
        /*
1723
         @ centerstring color,y-value,the text string
1723
         @ centerstring color,y-value,the text string
1724
         @ title color,y-value,the text string
1724
         @ title color,y-value,the text string
1725
         @ draw a string centered on the canvas at y = y-value
1725
         @ draw a string centered on the canvas at y = y-value
1726
         @ can not set "onclick" or "drag xy" (...)
1726
         @ can not set "onclick" or "drag xy" (...)
1727
         @ unicode supported: centerstring red,5,\\u2232
1727
         @ unicode supported: centerstring red,5,\\u2232
1728
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1728
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1729
        */
1729
        */
1730
            if( js_function[DRAW_CENTERSTRING] != 1 ){ js_function[DRAW_CENTERSTRING] = 1;}
1730
            if( js_function[DRAW_CENTERSTRING] != 1 ){ js_function[DRAW_CENTERSTRING] = 1;}
1731
            for(i=0;i<3;i++){
1731
            for(i=0;i<3;i++){
1732
                switch(i){
1732
                switch(i){
1733
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1733
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1734
                    case 1: double_data[0] = get_real(infile,0);break; /* y in xrange*/
1734
                    case 1: double_data[0] = get_real(infile,0);break; /* y in xrange*/
Line 1744... Line 1744...
1744
                    default:break;
1744
                    default:break;
1745
                }
1745
                }
1746
            }
1746
            }
1747
            break;
1747
            break;
1748
        case MATHML:
1748
        case MATHML:
1749
        /*
1749
        /*
1750
        @ mathml x1,y1,x2,y2,mathml_string
1750
        @ mathml x1,y1,x2,y2,mathml_string
1751
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1751
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1752
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1752
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1753
        @ 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();"
1753
        @ 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();"
1754
        @ 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....
1754
        @ 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....
1755
       
1755
 
1756
        */
1756
        */
1757
            if( js_function[DRAW_XML] != 1 ){ js_function[DRAW_XML] = 1;}
1757
            if( js_function[DRAW_XML] != 1 ){ js_function[DRAW_XML] = 1;}
1758
            for(i=0;i<5;i++){
1758
            for(i=0;i<5;i++){
1759
                switch(i){
1759
                switch(i){
1760
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1760
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1761
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1761
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1762
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1762
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1763
                    case 3: int_data[3]=y2px(get_real(infile,0)) - int_data[1];break; /* height in x/y-range coord system  -> pixel height */
1763
                    case 3: int_data[3]=y2px(get_real(infile,0)) - int_data[1];break; /* height in x/y-range coord system  -> pixel height */
1764
                    case 4: decimals = find_number_of_digits(precision);
1764
                    case 4: decimals = find_number_of_digits(precision);
1765
                            if(onclick == 1 ){ onclick = click_cnt;click_cnt++;}
1765
                            if(onclick == 1 ){ onclick = click_cnt;click_cnt++;}
1766
                            temp = get_string(infile,1);
1766
                            temp = get_string(infile,1);
1767
                            if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","'"); }
1767
                            if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","'"); }
1768
                            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);
1768
                            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);
1769
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1769
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1770
                            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);
1770
                            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);
1771
                            add_to_buffer(tmp_buffer);
1771
                            add_to_buffer(tmp_buffer);
1772
                            /*
1772
                            /*
1773
                             in case inputs are present , trigger adding the read_mathml()
1773
                             in case inputs are present , trigger adding the read_mathml()
1774
                             if no other reply_format is defined
1774
                             if no other reply_format is defined
1775
                             note: all other reply types will include a reading of elements with id='mathml'+p)
1775
                             note: all other reply types will include a reading of elements with id='mathml'+p)
1776
                             */
1776
                             */
1777
                            if(strstr(temp,"mathml0") != NULL){
1777
                            if(strstr(temp,"mathml0") != NULL){
1778
                             if(reply_format == 0 ){reply_format = 16;} /* no other reply type is defined */
1778
                             if(reply_format == 0 ){reply_format = 16;} /* no other reply type is defined */
1779
                            }
1779
                            }
1780
                            break;
1780
                            break;
1781
                    default:break;
1781
                    default:break;
1782
                }
1782
                }
1783
            }
1783
            }
1784
            reset();
1784
            reset();
1785
            break;
1785
            break;
1786
        case HTTP:
1786
        case HTTP:
1787
        /*
1787
        /*
1788
         @http x1,y1,x2,y2,http://some_adress.com
1788
         @http x1,y1,x2,y2,http://some_adress.com
1789
         @an active html-page will be displayed in an "iframe" rectangle left top (x1:y1) , right bottom (x2:y2)
1789
         @an active html-page will be displayed in an "iframe" rectangle left top (x1:y1) , right bottom (x2:y2)
1790
         @do not use interactivity (or mouse) if the mouse needs to be active in the iframe
1790
         @do not use interactivity (or mouse) if the mouse needs to be active in the iframe
1791
         @can not be 'set onclick' or 'drag xy'
1791
         @can not be 'set onclick' or 'drag xy'
1792
        */
1792
        */
1793
            if( js_function[DRAW_HTTP] != 1 ){ js_function[DRAW_HTTP] = 1;}    
1793
            if( js_function[DRAW_HTTP] != 1 ){ js_function[DRAW_HTTP] = 1;}
1794
            for(i=0;i<5;i++){
1794
            for(i=0;i<5;i++){
1795
                switch(i){
1795
                switch(i){
1796
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1796
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1797
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1797
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1798
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1798
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
Line 1813... Line 1813...
1813
        /*
1813
        /*
1814
         @ html x1,y1,x2,y2,html_string
1814
         @ html x1,y1,x2,y2,html_string
1815
         @ all tags are allowed
1815
         @ all tags are allowed
1816
         @ can be set onclick <br />(dragging not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1816
         @ can be set onclick <br />(dragging not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1817
         @ 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.
1817
         @ 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.
1818
         
1818
 
1819
         note: uses the same code as 'mathml'
1819
         note: uses the same code as 'mathml'
1820
        */
1820
        */
1821
            break;
1821
            break;
1822
        case X_AXIS_STRINGS:
1822
        case X_AXIS_STRINGS:
1823
        /*
1823
        /*
Line 1847... Line 1847...
1847
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1847
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1848
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1848
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1849
            fprintf(js_include_file,"y_strings = [\"%s\"];\n ",temp);
1849
            fprintf(js_include_file,"y_strings = [\"%s\"];\n ",temp);
1850
            use_axis_numbering = 1;
1850
            use_axis_numbering = 1;
1851
            break;
1851
            break;
1852
         
1852
 
1853
        case AXIS_NUMBERING:
1853
        case AXIS_NUMBERING:
1854
        /*
1854
        /*
1855
            @ axisnumbering
1855
            @ axisnumbering
1856
            @ keyword, no arguments required
1856
            @ keyword, no arguments required
1857
        */
1857
        */
1858
            use_axis_numbering = 1;
1858
            use_axis_numbering = 1;
1859
            break;
1859
            break;
1860
        case AXIS:
1860
        case AXIS:
1861
        /*
1861
        /*
1862
            @ axis
1862
            @ axis
1863
            @ keyword, no arguments required
1863
            @ keyword, no arguments required
1864
 
1864
 
1865
        */
1865
        */
1866
            use_axis = TRUE;
1866
            use_axis = TRUE;
1867
            break;
1867
            break;
1868
        case KILLSLIDER:
1868
        case KILLSLIDER:
1869
        /*
1869
        /*
1870
         @ killslider
1870
         @ killslider
Line 1910... Line 1910...
1910
                     }
1910
                     }
1911
                     else
1911
                     else
1912
                     {
1912
                     {
1913
                      if(strstr(temp,"y") != 0){
1913
                      if(strstr(temp,"y") != 0){
1914
                       slider = 2;
1914
                       slider = 2;
1915
                      }
1915
                      }
1916
                      else
1916
                      else
1917
                      {
1917
                      {
1918
                       if(strstr(temp,"angle") != 0){ /* angle diplay radian */
1918
                       if(strstr(temp,"angle") != 0){ /* angle diplay radian */
1919
                        slider = 3;
1919
                        slider = 3;
1920
                       }
1920
                       }
1921
                       else
1921
                       else
1922
                       {
1922
                       {
1923
                        canvas_error("slider types may be : x , y , xy , angle");
1923
                        canvas_error("slider types may be : x , y , xy , angle");
1924
                       }
1924
                       }
1925
                      }
1925
                      }
1926
                     }
1926
                     }
1927
                    }
1927
                    }
1928
                    if(strstr(temp,"display")!=0){
1928
                    if(strstr(temp,"display")!=0){
1929
                     use_slider_display = 1; /* show x xy values in canvas window */
1929
                     use_slider_display = 1; /* show x xy values in canvas window */
1930
                    }
1930
                    }
1931
                    else
1931
                    else
1932
                    {
1932
                    {
Line 1948... Line 1948...
1948
                    slider_cnt++;
1948
                    slider_cnt++;
1949
                    if(slider == 4){
1949
                    if(slider == 4){
1950
                     add_xyslider(js_include_file,canvas_root_id,double_data[0],double_data[1],int_data[0],int_data[1],slider,get_string_argument(infile,1),slider_cnt,stroke_color,fill_color,line_width,fill_opacity,font_family,font_color,use_slider_display );
1950
                     add_xyslider(js_include_file,canvas_root_id,double_data[0],double_data[1],int_data[0],int_data[1],slider,get_string_argument(infile,1),slider_cnt,stroke_color,fill_color,line_width,fill_opacity,font_family,font_color,use_slider_display );
1951
                    }else{
1951
                    }else{
1952
                     add_slider(js_include_file,canvas_root_id,double_data[0],double_data[1],int_data[0],int_data[1],slider,get_string_argument(infile,1),slider_cnt,stroke_color,fill_color,line_width,fill_opacity,font_family,font_color,use_slider_display);
1952
                     add_slider(js_include_file,canvas_root_id,double_data[0],double_data[1],int_data[0],int_data[1],slider,get_string_argument(infile,1),slider_cnt,stroke_color,fill_color,line_width,fill_opacity,font_family,font_color,use_slider_display);
1953
                    }
1953
                    }
1954
                    break;
1954
                    break;
1955
                }
1955
                }
1956
             }
1956
             }
1957
            break;
1957
            break;
1958
        case SGRAPH:
1958
        case SGRAPH:
1959
        /*
1959
        /*
1960
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
1960
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
1961
         @ primitive implementation of a 'broken scale' graph...
1961
         @ primitive implementation of a 'broken scale' graph...
1962
         @ not very versatile: only usable in combination with userdraw <br />eg no other objects will obey this "coordinate system"<br />if you want to place an object into this coordinate system, be aware that 10% or 20% of xsize and/or ysize is 'lost'.<br />Use these "formulas" to recalculate the virtual coordinates:<br />factor=0.8 in case xstart != xmin (or ystart != ymin)<br />factor=0.9 in case xstart = xmin (or ystart = ymin)<br />px_x_point = ((factor*xsize)/(xmax - xstart))*(x_point - xmax)+xsize<br />x_recalculated = px*(xmax - xmin)/xsize + $xmin<br />px_y_point = -1*factor*y_point*ysize/(ymax - ystart) + ymax*factor*ysize/(ymax - ystart)<br />y_recalculated = ymax - py*(ymax - ymin)/ysize<br />
1962
         @ not very versatile: only usable in combination with userdraw <br />eg no other objects will obey this "coordinate system"<br />if you want to place an object into this coordinate system, be aware that 10% or 20% of xsize and/or ysize is 'lost'.<br />Use these "formulas" to recalculate the virtual coordinates:<br />factor=0.8 in case xstart != xmin (or ystart != ymin)<br />factor=0.9 in case xstart = xmin (or ystart = ymin)<br />px_x_point = ((factor*xsize)/(xmax - xstart))*(x_point - xmax)+xsize<br />x_recalculated = px*(xmax - xmin)/xsize + $xmin<br />px_y_point = -1*factor*y_point*ysize/(ymax - ystart) + ymax*factor*ysize/(ymax - ystart)<br />y_recalculated = ymax - py*(ymax - ymin)/ysize<br />
1963
         @ 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
1963
         @ 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
1964
        */
1964
        */
1965
            if( js_function[DRAW_SGRAPH] != 1 ){ js_function[DRAW_SGRAPH] = 1;}
1965
            if( js_function[DRAW_SGRAPH] != 1 ){ js_function[DRAW_SGRAPH] = 1;}
1966
            for(i = 0 ; i < 8 ;i++){
1966
            for(i = 0 ; i < 8 ;i++){
1967
                switch(i){
1967
                switch(i){
1968
                    case 0:double_data[0] = get_real(infile,0);break;
1968
                    case 0:double_data[0] = get_real(infile,0);break;
1969
                    case 1:double_data[1] = get_real(infile,0);break;
1969
                    case 1:double_data[1] = get_real(infile,0);break;
1970
                    case 2:double_data[2] = get_real(infile,0);break;
1970
                    case 2:double_data[2] = get_real(infile,0);break;
Line 2056... Line 2056...
2056
        /*
2056
        /*
2057
        @ killaffine
2057
        @ killaffine
2058
        @ keyword : resets the transformation matrix to 1,0,0,1,0,0
2058
        @ keyword : resets the transformation matrix to 1,0,0,1,0,0
2059
        */
2059
        */
2060
            use_affine = FALSE;
2060
            use_affine = FALSE;
2061
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");    
2061
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");
2062
            break;
2062
            break;
2063
        case AFFINE:
2063
        case AFFINE:
2064
        /*
2064
        /*
2065
         @affine a,b,c,d,tx,ty
2065
         @affine a,b,c,d,tx,ty
2066
         @ defines a transformation matrix for subsequent objects
2066
         @ defines a transformation matrix for subsequent objects
2067
         @ use keyword 'killaffine' to end the transformation
2067
         @ use keyword 'killaffine' to end the transformation
2068
         @ note 1: only 'draggable' / 'noclick' objects can be transformed.
2068
         @ note 1: only 'draggable' / 'noclick' objects can be transformed.
2069
         @ note 2: do not use 'onclick' or 'drag xy' with tranformation objects : the mouse coordinates do not get transformed (yet)
2069
         @ note 2: do not use 'onclick' or 'drag xy' with tranformation objects : the mouse coordinates do not get transformed (yet)
2070
         @ note 3: no matrix operations on the transformation matrix implemented (yet)
2070
         @ note 3: no matrix operations on the transformation matrix implemented (yet)
2071
         @ a : Scales the drawings horizontally
2071
         @ a : Scales the drawings horizontally
2072
         @ b : Skews the drawings horizontally
2072
         @ b : Skews the drawings horizontally
2073
         @ c : Skews the drawings vertically
2073
         @ c : Skews the drawings vertically
2074
         @ d : Scales the drawings vertically
2074
         @ d : Scales the drawings vertically
2075
         @ tx: Moves the drawings horizontally in xrange coordinate system
2075
         @ tx: Moves the drawings horizontally in xrange coordinate system
2076
         @ ty: Moves the drawings vertically in yrange coordinate system
2076
         @ ty: Moves the drawings vertically in yrange coordinate system
2077
         @ the data precision is 2 decimals (printf : %2.f)
2077
         @ the data precision is 2 decimals (printf : %2.f)
2078
        */
2078
        */
2079
            for(i = 0 ; i<6;i++){
2079
            for(i = 0 ; i<6;i++){
2080
                switch(i){
2080
                switch(i){
2081
                    case 0: double_data[0] = get_real(infile,0);break;
2081
                    case 0: double_data[0] = get_real(infile,0);break;
Line 2085... Line 2085...
2085
                    case 4: double_data[4] = get_real(infile,0);break;
2085
                    case 4: double_data[4] = get_real(infile,0);break;
2086
                    case 5: double_data[5] = get_real(infile,1);
2086
                    case 5: double_data[5] = get_real(infile,1);
2087
                        use_affine = TRUE;
2087
                        use_affine = TRUE;
2088
                        string_length = snprintf(NULL,0,     "[%.2f,%.2f,%.2f,%.2f,%.2f,%.2f] ",double_data[0],double_data[1],double_data[2],double_data[3],double_data[4]*xsize/(xmax - xmin),-1*double_data[5]*ysize/(ymax - ymin));
2088
                        string_length = snprintf(NULL,0,     "[%.2f,%.2f,%.2f,%.2f,%.2f,%.2f] ",double_data[0],double_data[1],double_data[2],double_data[3],double_data[4]*xsize/(xmax - xmin),-1*double_data[5]*ysize/(ymax - ymin));
2089
                        check_string_length(string_length);affine_matrix = my_newmem(string_length+1);
2089
                        check_string_length(string_length);affine_matrix = my_newmem(string_length+1);
2090
                        snprintf(affine_matrix,string_length,"[%.2f,%.2f,%.2f,%.2f,%.2f,%.2f] ",double_data[0],double_data[1],double_data[2],double_data[3],double_data[4]*xsize/(xmax - xmin),-1*double_data[5]*ysize/(ymax - ymin));    
2090
                        snprintf(affine_matrix,string_length,"[%.2f,%.2f,%.2f,%.2f,%.2f,%.2f] ",double_data[0],double_data[1],double_data[2],double_data[3],double_data[4]*xsize/(xmax - xmin),-1*double_data[5]*ysize/(ymax - ymin));
2091
                        break;
2091
                        break;
2092
                    default: break;
2092
                    default: break;
2093
                }
2093
                }
2094
            }
2094
            }
2095
        break;
2095
        break;
2096
        case KILLTRANSLATION:
2096
        case KILLTRANSLATION:
2097
        /*
2097
        /*
2098
         killtranslation
2098
         killtranslation
2099
        */
2099
        */
2100
            use_affine = FALSE;
2100
            use_affine = FALSE;
2101
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");    
2101
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");
2102
            break;
2102
            break;
2103
        case TRANSLATION:
2103
        case TRANSLATION:
2104
        /*
2104
        /*
2105
         @translation tx,ty
2105
         @translation tx,ty
2106
         @will translate the next object tx in xrange and ty in yrange
2106
         @will translate the next object tx in xrange and ty in yrange
Line 2128... Line 2128...
2128
        */
2128
        */
2129
            use_dashed = TRUE;
2129
            use_dashed = TRUE;
2130
            break;
2130
            break;
2131
        case FILLED:
2131
        case FILLED:
2132
        /*
2132
        /*
2133
        @ keyword "filled"
2133
        @ keyword "filled"
2134
        @ the next 'fillable' object (only) will be filled
2134
        @ the next 'fillable' object (only) will be filled
2135
        @ use command "fillcolor color" to set fillcolor
2135
        @ use command "fillcolor color" to set fillcolor
2136
        @ use command "opacity 0-255,0-255" to set stroke and fill-opacity
2136
        @ use command "opacity 0-255,0-255" to set stroke and fill-opacity
2137
        @ 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 !
2137
        @ 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 !
2138
        */
2138
        */
2139
            use_filled = TRUE;
2139
            use_filled = TRUE;
Line 2158... Line 2158...
2158
        @ strokecolor colorname or #hex
2158
        @ strokecolor colorname or #hex
2159
        @ to be used for commands that do not supply a color argument (like command 'linegraph')
2159
        @ to be used for commands that do not supply a color argument (like command 'linegraph')
2160
        */
2160
        */
2161
            stroke_color = get_color(infile,1);
2161
            stroke_color = get_color(infile,1);
2162
            break;
2162
            break;
2163
        case BGIMAGE:
2163
        case BGIMAGE:
2164
        /*
2164
        /*
2165
         @bgimage image_location
2165
         @bgimage image_location
2166
         @use an image as background .<br />(we use the background of 'canvas_div' )
2166
         @use an image as background .<br />(we use the background of 'canvas_div' )
2167
         @the background image will be resized to match "width = xsize" and "height = ysize"
2167
         @the background image will be resized to match "width = xsize" and "height = ysize"
2168
        */
2168
        */
2169
        URL = get_string(infile,1);
2169
        URL = get_string(infile,1);
2170
        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);
2170
        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);
2171
            break;
2171
            break;
2172
        case BGCOLOR:
2172
        case BGCOLOR:
2173
        /*
2173
        /*
2174
         @bgcolor colorname or #hex
2174
         @bgcolor colorname or #hex
2175
         @use this color as background of the "div" containing the canvas(es)
2175
         @use this color as background of the "div" containing the canvas(es)
2176
        */
2176
        */
2177
        /* [255,255,255]*/
2177
        /* [255,255,255]*/
Line 2192... Line 2192...
2192
        case COPY:
2192
        case COPY:
2193
        /*
2193
        /*
2194
        @ copy x,y,x1,y1,x2,y2,[filename URL]
2194
        @ copy x,y,x1,y1,x2,y2,[filename URL]
2195
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y) in x/y-range
2195
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y) in x/y-range
2196
        @ If x1=y1=x2=y2=-1, the whole [filename URL] is copied.
2196
        @ If x1=y1=x2=y2=-1, the whole [filename URL] is copied.
2197
        @ [filename] is the URL of the image   
2197
        @ [filename] is the URL of the image
2198
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
2198
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
2199
        @ 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
2199
        @ 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
2200
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
2200
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
2201
 
2201
 
2202
        context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
2202
        context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
2203
        draw_external_image(canvas_type,URL,sx,sy,swidth,sheight,x,y,width,height,drag_drop){
2203
        draw_external_image(canvas_type,URL,sx,sy,swidth,sheight,x,y,width,height,drag_drop){
2204
        */
2204
        */
2205
            for(i = 0 ; i<7;i++){
2205
            for(i = 0 ; i<7;i++){
Line 2216... Line 2216...
2216
                            if( drag_type > -1 ){
2216
                            if( drag_type > -1 ){
2217
                                if( js_function[DRAG_EXTERNAL_IMAGE] != 1 ){ js_function[DRAG_EXTERNAL_IMAGE] = 1;}
2217
                                if( js_function[DRAG_EXTERNAL_IMAGE] != 1 ){ js_function[DRAG_EXTERNAL_IMAGE] = 1;}
2218
                                if(reply_format == 0 ){reply_format = 20;}
2218
                                if(reply_format == 0 ){reply_format = 20;}
2219
                                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);
2219
                                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);
2220
                                check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2220
                                check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2221
                                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);                       
2221
                                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);
2222
                                drag_type = -1;
2222
                                drag_type = -1;
2223
                                ext_img_cnt++;
2223
                                ext_img_cnt++;
2224
                            }
2224
                            }
2225
                            else
2225
                            else
2226
                            {
2226
                            {
Line 2242... Line 2242...
2242
/*
2242
/*
2243
context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
2243
context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
2244
img     Specifies the image, canvas, or video element to use
2244
img     Specifies the image, canvas, or video element to use
2245
sx      The x coordinate where to start clipping : x1 = int_data[0]
2245
sx      The x coordinate where to start clipping : x1 = int_data[0]
2246
sy      The y coordinate where to start clipping : x2 = int_data[1]
2246
sy      The y coordinate where to start clipping : x2 = int_data[1]
2247
swidth  The width of the clipped image : int_data[2] - int_data[0]
2247
swidth  The width of the clipped image : int_data[2] - int_data[0]
2248
sheight The height of the clipped image : int_data[3] - int_data[1]
2248
sheight The height of the clipped image : int_data[3] - int_data[1]
2249
x       The x coordinate where to place the image on the canvas : dx1 = int_data[4]
2249
x       The x coordinate where to place the image on the canvas : dx1 = int_data[4]
2250
y       The y coordinate where to place the image on the canvas : dy1 = int_data[5]
2250
y       The y coordinate where to place the image on the canvas : dy1 = int_data[5]
2251
width   The width of the image to use (stretch or reduce the image) : dx2 - dx1 = int_data[6]
2251
width   The width of the image to use (stretch or reduce the image) : dx2 - dx1 = int_data[6]
2252
height  The height of the image to use (stretch or reduce the image) : dy2 - dy1 = int_data[7]
2252
height  The height of the image to use (stretch or reduce the image) : dy2 - dy1 = int_data[7]
2253
*/
2253
*/
2254
        case COPYRESIZED:
2254
        case COPYRESIZED:
2255
        /*
2255
        /*
2256
        @ copyresized x1,y2,x2,y2,dx1,dy1,dx2,dy2,image_file_url
2256
        @ copyresized x1,y2,x2,y2,dx1,dy1,dx2,dy2,image_file_url
2257
        @ 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
2257
        @ 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
2258
        @ If x1=y1=x2=y2=-1, the whole [filename / URL ] is copied and resized.
2258
        @ If x1=y1=x2=y2=-1, the whole [filename / URL ] is copied and resized.
2259
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
2259
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
2260
        @ 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
2260
        @ 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
2261
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
2261
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
2262
        */
2262
        */
2263
            for(i = 0 ; i<9;i++){
2263
            for(i = 0 ; i<9;i++){
2264
                switch(i){
2264
                switch(i){
2265
                    case 0: int_data[0] = (int)(get_real(infile,0));break; /* x1 */
2265
                    case 0: int_data[0] = (int)(get_real(infile,0));break; /* x1 */
2266
                    case 1: int_data[1] = (int)(get_real(infile,0));break; /* y1 */
2266
                    case 1: int_data[1] = (int)(get_real(infile,0));break; /* y1 */
Line 2297... Line 2297...
2297
        /*
2297
        /*
2298
         @clearbutton value
2298
         @clearbutton value
2299
         @adds a button to clear the userdraw canvas with text 'value'
2299
         @adds a button to clear the userdraw canvas with text 'value'
2300
         @normally userdraw primitives have the option to use middle/right mouse button on<br /> a point of the object to remove this specific object...this clear button will remove all drawings
2300
         @normally userdraw primitives have the option to use middle/right mouse button on<br /> a point of the object to remove this specific object...this clear button will remove all drawings
2301
         @uses the tooltip placeholder div element: may not be used with command 'intooltip'
2301
         @uses the tooltip placeholder div element: may not be used with command 'intooltip'
2302
         @use command 'inputstyle' to style the button...  
2302
         @use command 'inputstyle' to style the button...
2303
        */
2303
        */
2304
            add_clear_button(js_include_file,canvas_root_id,input_style,get_string(infile,1));
2304
            add_clear_button(js_include_file,canvas_root_id,input_style,get_string(infile,1));
2305
        break;
2305
        break;
2306
        case INPUTSTYLE:
2306
        case INPUTSTYLE:
2307
        /*
2307
        /*
Line 2309... Line 2309...
2309
        @ example: inputstyle color:blue;font-weight:bold;font-style:italic;font-size:16pt
2309
        @ example: inputstyle color:blue;font-weight:bold;font-style:italic;font-size:16pt
2310
        */
2310
        */
2311
            input_style = get_string(infile,1);
2311
            input_style = get_string(infile,1);
2312
            break;
2312
            break;
2313
        case INPUT:
2313
        case INPUT:
2314
        /*
2314
        /*
2315
         @ input x,y,size,editable,value
2315
         @ input x,y,size,editable,value
2316
         @ to set inputfield "readonly", use editable = 0
2316
         @ to set inputfield "readonly", use editable = 0
2317
         @ only active inputfields (editable = 1) will be read with read_canvas();
2317
         @ only active inputfields (editable = 1) will be read with read_canvas();
2318
         @ if "$status=done"  (e.g. in answer.phtml) the inputfield will be clearedand set readonly<br />Override this by keyword 'status'
2318
         @ if "$status=done"  (e.g. in answer.phtml) the inputfield will be clearedand set readonly<br />Override this by keyword 'status'
2319
         @ may be further controlled by "inputstyle" (inputcss is not yet implemented...)
2319
         @ may be further controlled by "inputstyle" (inputcss is not yet implemented...)
2320
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
2320
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
2321
        */
2321
        */
2322
        if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}    
2322
        if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}
2323
            for(i = 0 ; i<5;i++){
2323
            for(i = 0 ; i<5;i++){
2324
                switch(i){
2324
                switch(i){
2325
                    case 0: int_data[0]=x2px(get_real(infile,0));break;/* x in px */
2325
                    case 0: int_data[0]=x2px(get_real(infile,0));break;/* x in px */
2326
                    case 1: int_data[1]=y2px(get_real(infile,0));break;/* y in px */
2326
                    case 1: int_data[1]=y2px(get_real(infile,0));break;/* y in px */
2327
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break; /* size */
2327
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break; /* size */
2328
                    case 3: if( get_real(infile,1) >0){int_data[3] = 1;}else{int_data[3] = 0;};break; /* readonly */
2328
                    case 3: if( get_real(infile,1) >0){int_data[3] = 1;}else{int_data[3] = 0;};break; /* readonly */
2329
                    case 4:
2329
                    case 4:
2330
                            temp = get_string_argument(infile,1);
2330
                            temp = get_string_argument(infile,1);
2331
                            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);
2331
                            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);
2332
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2332
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2333
                            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);
2333
                            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);
2334
                            add_to_buffer(tmp_buffer);
2334
                            add_to_buffer(tmp_buffer);
Line 2338... Line 2338...
2338
            }
2338
            }
2339
            if(reply_format == 0 ){reply_format = 15;}
2339
            if(reply_format == 0 ){reply_format = 15;}
2340
            reset();
2340
            reset();
2341
            break;
2341
            break;
2342
        case TEXTAREA:
2342
        case TEXTAREA:
2343
        /*
2343
        /*
2344
         @ textarea x,y,cols,rows,readonly,value
2344
         @ textarea x,y,cols,rows,readonly,value
2345
         @ may be further controlled by "inputstyle"
2345
         @ may be further controlled by "inputstyle"
2346
         @ if "$status=done"  (e.g. in answer.phtml) the inputfield will be clearedand set readonly<br />Override this by keyword 'status'
2346
         @ if "$status=done"  (e.g. in answer.phtml) the inputfield will be clearedand set readonly<br />Override this by keyword 'status'
2347
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
2347
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
2348
        */
2348
        */
2349
            if( js_function[DRAW_TEXTAREAS] != 1 ){ js_function[DRAW_TEXTAREAS] = 1;}  
2349
            if( js_function[DRAW_TEXTAREAS] != 1 ){ js_function[DRAW_TEXTAREAS] = 1;}
2350
            for(i = 0 ; i<6;i++){
2350
            for(i = 0 ; i<6;i++){
2351
                switch(i){
2351
                switch(i){
2352
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in px */
2352
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in px */
2353
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in px */
2353
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in px */
2354
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break;/* cols */
2354
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break;/* cols */
Line 2363... Line 2363...
2363
                    default: break;
2363
                    default: break;
2364
                }
2364
                }
2365
            }
2365
            }
2366
            if(reply_format == 0 ){reply_format = 15;}
2366
            if(reply_format == 0 ){reply_format = 15;}
2367
            reset();
2367
            reset();
2368
            break;
2368
            break;
2369
        case MOUSE_PRECISION:
2369
        case MOUSE_PRECISION:
2370
        /*
2370
        /*
2371
            @ precision int
2371
            @ precision int
2372
            @ 1 = no decimals ; 10 = 1 decimal ; 100 = 2 decimals etc
2372
            @ 1 = no decimals ; 10 = 1 decimal ; 100 = 2 decimals etc
2373
            @ may be used / changed before every object
2373
            @ may be used / changed before every object
Line 2375... Line 2375...
2375
        */
2375
        */
2376
            precision = (int) (get_real(infile,1));
2376
            precision = (int) (get_real(infile,1));
2377
            if(precision < 1 ){precision = 1;};
2377
            if(precision < 1 ){precision = 1;};
2378
            break;
2378
            break;
2379
        case SETLIMITS:
2379
        case SETLIMITS:
2380
        /*
2380
        /*
2381
            @setlimits
2381
            @setlimits
2382
            @keyword : if set, it will produce 4 inputfields for 'xmin,xmax,ymin,ymax' and an 'ok' button
2382
            @keyword : if set, it will produce 4 inputfields for 'xmin,xmax,ymin,ymax' and an 'ok' button
2383
            @may be used for inputfield based zooming / panning
2383
            @may be used for inputfield based zooming / panning
2384
            @use command xlabel / ylabel to change text from xmin to 'xlabel'min etc
2384
            @use command xlabel / ylabel to change text from xmin to 'xlabel'min etc
2385
            @note:the input value will not be checked on validity
2385
            @note:the input value will not be checked on validity
2386
        */
2386
        */
2387
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
2387
            if( use_safe_eval == FALSE){use_safe_eval = TRUE;add_safe_eval(js_include_file);} /* just once */
2388
            add_setlimits(js_include_file,canvas_root_id);
2388
            add_setlimits(js_include_file,canvas_root_id);
2389
            /* add_setlimits provides 'fprintf(js_include_file,"use_pan_and_zoom = 1;");' */
2389
            /* add_setlimits provides 'fprintf(js_include_file,"use_pan_and_zoom = 1;");' */
2390
            use_pan_and_zoom = TRUE;
2390
            use_pan_and_zoom = TRUE;
Line 2395... Line 2395...
2395
         @ zoom button_color
2395
         @ zoom button_color
2396
         @ introduce a controlpanel at the lower right corner
2396
         @ introduce a controlpanel at the lower right corner
2397
         @ 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
2397
         @ 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
2398
         @ the 'x' symbol will do a 'location.reload' of the page, and thus reset all canvas drawings.
2398
         @ the 'x' symbol will do a 'location.reload' of the page, and thus reset all canvas drawings.
2399
         @ choose an appropriate colour, so the small 'x,arrows,-,+' are clearly visible
2399
         @ choose an appropriate colour, so the small 'x,arrows,-,+' are clearly visible
2400
         @ command 'opacity' may be used to set stroke_opacity of 'buttons
2400
         @ command 'opacity' may be used to set stroke_opacity of 'buttons
2401
         @ NOTE: use command 'zoom' at the end of your script code (the same is true for commanmd 'mouse')
2401
         @ NOTE: use command 'zoom' at the end of your script code (the same is true for commanmd 'mouse')
2402
         @ NOTE: only objects that may be set draggable / clickable will be zoomed / panned
2402
         @ NOTE: only objects that may be set draggable / clickable will be zoomed / panned
2403
         @ 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 !!
2403
         @ 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 !!
2404
        */
2404
        */
2405
            fprintf(js_include_file,"use_pan_and_zoom = 1;");
2405
            fprintf(js_include_file,"use_pan_and_zoom = 1;");
2406
            use_pan_and_zoom = TRUE;
2406
            use_pan_and_zoom = TRUE;
Line 2412... Line 2412...
2412
        case ONCLICK:
2412
        case ONCLICK:
2413
        /*
2413
        /*
2414
         @ onclick
2414
         @ onclick
2415
         @ keyword, no arguments
2415
         @ keyword, no arguments
2416
         @ if the next object is clicked, it's 'object sequence number' in fly script is returned <br /> by javascript:read_canvas();
2416
         @ if the next object is clicked, it's 'object sequence number' in fly script is returned <br /> by javascript:read_canvas();
2417
         @ Line based object will show an increase in linewidth<br />Font based objects will show the text in 'bold' when clicked.
2417
         @ Line based object will show an increase in linewidth<br />Font based objects will show the text in 'bold' when clicked.
2418
         @ NOTE: not all objects may be set clickable
2418
         @ NOTE: not all objects may be set clickable
2419
        */
2419
        */
2420
           
2420
 
2421
            onclick = 1;
2421
            onclick = 1;
2422
            break;
2422
            break;
2423
        case DRAG:
2423
        case DRAG:
2424
        /*
2424
        /*
2425
         @ drag [x][y][xy]
2425
         @ drag [x][y][xy]
2426
         @ the next object will be draggable in x / y / xy direction
2426
         @ the next object will be draggable in x / y / xy direction
2427
         @ the displacement can be read by 'javascript:read_dragdrop();'
2427
         @ the displacement can be read by 'javascript:read_dragdrop();'
2428
         @ the precision (default 2 decimals) in the student reply may be set with command 'precision'.<br />Use this 'precision' command before this command 'drag x|y|xy' !
2428
         @ the precision (default 2 decimals) in the student reply may be set with command 'precision'.<br />Use this 'precision' command before this command 'drag x|y|xy' !
2429
         @ the answer is  : object_number : Xorg : Yorg : Xnew : Ynew<br />wherein object_number is the place of the draggable object in your script.<br />Only draggable object will have an object_number (e.g things like point,crosshair,line,segment,circle,rect,triangle...etc)
2429
         @ the answer is  : object_number : Xorg : Yorg : Xnew : Ynew<br />wherein object_number is the place of the draggable object in your script.<br />Only draggable object will have an object_number (e.g things like point,crosshair,line,segment,circle,rect,triangle...etc)
2430
         @ use keywordd 'snaptogrid' , 'xsnaptogrid' or 'ysnaptogrid' to switch from free to discrete movement
2430
         @ use keywordd 'snaptogrid' , 'xsnaptogrid' or 'ysnaptogrid' to switch from free to discrete movement
2431
         @ 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.
2431
         @ 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.
2432
         @ 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 !!
2432
         @ 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 !!
2433
        */
2433
        */
2434
            temp = get_string(infile,1);
2434
            temp = get_string(infile,1);
2435
            if(strstr(temp,"xy") != NULL ){
2435
            if(strstr(temp,"xy") != NULL ){
2436
                drag_type = 0;
2436
                drag_type = 0;
2437
            }
2437
            }
2438
            else
2438
            else
2439
            {
2439
            {
2440
                if(strstr(temp,"x") != NULL ){
2440
                if(strstr(temp,"x") != NULL ){
2441
                    drag_type = 1;
2441
                    drag_type = 1;
2442
                }
2442
                }
2443
                else
2443
                else
2444
                {
2444
                {
2445
                    drag_type = 2;
2445
                    drag_type = 2;
Line 2511... Line 2511...
2511
        case MOUSE_DEGREE:
2511
        case MOUSE_DEGREE:
2512
        /*
2512
        /*
2513
         @ mouse_degree color,fontsize
2513
         @ mouse_degree color,fontsize
2514
         @ will display the angle in degrees between x-axis, (0:0) and the cursor (x:y) in 'color' and 'font size'<br /> using default fontfamily Ariel
2514
         @ will display the angle in degrees between x-axis, (0:0) and the cursor (x:y) in 'color' and 'font size'<br /> using default fontfamily Ariel
2515
         @ The angle is positive in QI and QIII and the angle value is negative in QII and QIV
2515
         @ The angle is positive in QI and QIII and the angle value is negative in QII and QIV
2516
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
2516
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
2517
 
2517
 
2518
        */
2518
        */
2519
            stroke_color = get_color(infile,0);
2519
            stroke_color = get_color(infile,0);
2520
            font_size = (int) (get_real(infile,1));
2520
            font_size = (int) (get_real(infile,1));
2521
            tmp_buffer = my_newmem(26);
2521
            tmp_buffer = my_newmem(26);
Line 2524... Line 2524...
2524
            break;
2524
            break;
2525
        case MOUSEX:
2525
        case MOUSEX:
2526
        /*
2526
        /*
2527
         @ mousex color,fontsize
2527
         @ mousex color,fontsize
2528
         @ will display the cursor x-coordinate in 'color' and 'font size'<br /> using default fontfamily Ariel
2528
         @ will display the cursor x-coordinate in 'color' and 'font size'<br /> using default fontfamily Ariel
2529
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
2529
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
2530
 
2530
 
2531
        */
2531
        */
2532
            stroke_color = get_color(infile,0);
2532
            stroke_color = get_color(infile,0);
2533
            font_size = (int) (get_real(infile,1));
2533
            font_size = (int) (get_real(infile,1));
2534
            tmp_buffer = my_newmem(26);
2534
            tmp_buffer = my_newmem(26);
2535
            snprintf(tmp_buffer,25,"use_mouse_coordinates();\n");add_to_buffer(tmp_buffer);
2535
            snprintf(tmp_buffer,25,"use_mouse_coordinates();\n");add_to_buffer(tmp_buffer);
2536
            add_js_mouse(js_include_file,MOUSE_CANVAS,canvas_root_id,precision,stroke_color,font_size,stroke_opacity,0);
2536
            add_js_mouse(js_include_file,MOUSE_CANVAS,canvas_root_id,precision,stroke_color,font_size,stroke_opacity,0);
2537
            break;
2537
            break;
2538
        case MOUSEY:
2538
        case MOUSEY:
2539
        /*
2539
        /*
2540
         @ mousey color,fontsize
2540
         @ mousey color,fontsize
2541
         @ will display the cursor y-coordinate in 'color' and 'font size'<br /> using default fontfamily Ariel
2541
         @ will display the cursor y-coordinate in 'color' and 'font size'<br /> using default fontfamily Ariel
2542
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
2542
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
2543
 
2543
 
2544
        */
2544
        */
2545
            stroke_color = get_color(infile,0);
2545
            stroke_color = get_color(infile,0);
2546
            font_size = (int) (get_real(infile,1));
2546
            font_size = (int) (get_real(infile,1));
2547
            tmp_buffer = my_newmem(26);
2547
            tmp_buffer = my_newmem(26);
Line 2550... Line 2550...
2550
            break;
2550
            break;
2551
        case MOUSE:
2551
        case MOUSE:
2552
        /*
2552
        /*
2553
         @ mouse color,fontsize
2553
         @ mouse color,fontsize
2554
         @ will display the cursor (x:y) coordinates  in 'color' and 'font size'<br /> using default fontfamily Ariel
2554
         @ will display the cursor (x:y) coordinates  in 'color' and 'font size'<br /> using default fontfamily Ariel
2555
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for commanmd 'zoom')
2555
         @ NOTE: use command 'mouse' at the end of your script code (the same is true for commanmd 'zoom')
2556
 
2556
 
2557
        */
2557
        */
2558
            stroke_color = get_color(infile,0);
2558
            stroke_color = get_color(infile,0);
2559
            font_size = (int) (get_real(infile,1));
2559
            font_size = (int) (get_real(infile,1));
2560
            tmp_buffer = my_newmem(26);
2560
            tmp_buffer = my_newmem(26);
Line 2595... Line 2595...
2595
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y in x/y-range coord system  -> pixel */
2595
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y in x/y-range coord system  -> pixel */
2596
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* pixel width */
2596
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* pixel width */
2597
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* height pixel height */
2597
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* height pixel height */
2598
                    case 4: int_data[4] = (int) (get_real(infile,0)); if(int_data[4] != TRUE){int_data[4] = FALSE;} break; /* loop boolean */
2598
                    case 4: int_data[4] = (int) (get_real(infile,0)); if(int_data[4] != TRUE){int_data[4] = FALSE;} break; /* loop boolean */
2599
                    case 5: int_data[5] = (int) (get_real(infile,0)); if(int_data[5] != TRUE){int_data[5] = FALSE;} break; /* visible boolean */
2599
                    case 5: int_data[5] = (int) (get_real(infile,0)); if(int_data[5] != TRUE){int_data[5] = FALSE;} break; /* visible boolean */
2600
                    case 6:
2600
                    case 6:
2601
                    temp = get_string(infile,1);
2601
                    temp = get_string(infile,1);
2602
                    if( strstr(temp,".mp3") != 0 ){ temp = str_replace(temp,".mp3","");}
2602
                    if( strstr(temp,".mp3") != 0 ){ temp = str_replace(temp,".mp3","");}
2603
                    if( strstr(temp,".ogg") != 0 ){ temp = str_replace(temp,".ogg","");}
2603
                    if( strstr(temp,".ogg") != 0 ){ temp = str_replace(temp,".ogg","");}
2604
                    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);
2604
                    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);
2605
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2605
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
Line 2749... Line 2749...
2749
        @ normal url : imagefill 80,80,http://adres/a/b/c/my_image.jpg
2749
        @ normal url : imagefill 80,80,http://adres/a/b/c/my_image.jpg
2750
        @ if dx,dy is larger than the image, the whole image will be background to the next object.
2750
        @ if dx,dy is larger than the image, the whole image will be background to the next object.
2751
        */
2751
        */
2752
            if( js_function[DRAW_IMAGEFILL] != 1 ){ js_function[DRAW_IMAGEFILL] = 1;}
2752
            if( js_function[DRAW_IMAGEFILL] != 1 ){ js_function[DRAW_IMAGEFILL] = 1;}
2753
            for(i=0 ;i < 3 ; i++){
2753
            for(i=0 ;i < 3 ; i++){
2754
                switch(i){
2754
                switch(i){
2755
                    case 0:int_data[0] = (int) (get_real(infile,0));break;
2755
                    case 0:int_data[0] = (int) (get_real(infile,0));break;
2756
                    case 1:int_data[1] = (int) (get_real(infile,0));break;
2756
                    case 1:int_data[1] = (int) (get_real(infile,0));break;
2757
                    case 2: URL = get_string_argument(infile,1);
2757
                    case 2: URL = get_string_argument(infile,1);
2758
                            string_length = snprintf(NULL,0,  "draw_imagefill(%d,%d,%d,\"%s\",%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],URL,xsize,ysize);
2758
                            string_length = snprintf(NULL,0,  "draw_imagefill(%d,%d,%d,\"%s\",%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],URL,xsize,ysize);
2759
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2759
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
Line 2765... Line 2765...
2765
            reset();
2765
            reset();
2766
        break;
2766
        break;
2767
        case FILLTOBORDER:
2767
        case FILLTOBORDER:
2768
        /*
2768
        /*
2769
        @ filltoborder x,y,bordercolor,color
2769
        @ filltoborder x,y,bordercolor,color
2770
        @ fill the region  of point (x:y) bounded by 'bordercolor' with color 'color'
2770
        @ fill the region  of point (x:y) bounded by 'bordercolor' with color 'color'
2771
        @ any other color will not act as border to the bucket fill
2771
        @ any other color will not act as border to the bucket fill
2772
        @ use this command  after all boundary objects are declared.
2772
        @ use this command  after all boundary objects are declared.
2773
        @ 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..
2773
        @ 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..
2774
        */
2774
        */
2775
            for(i=0 ;i < 4 ; i++){
2775
            for(i=0 ;i < 4 ; i++){
Line 2785... Line 2785...
2785
                           decimals = find_number_of_digits(precision);
2785
                           decimals = find_number_of_digits(precision);
2786
                           /* we need to set a timeout: the canvas is not yet draw in memory? when floodfill is called directly... */
2786
                           /* we need to set a timeout: the canvas is not yet draw in memory? when floodfill is called directly... */
2787
                           string_length = snprintf(NULL,0,  "setTimeout(function(){filltoborder(%.*f,%.*f,[%s,%d],[%s,%d]);},1000);\n",decimals,double_data[0],decimals,double_data[1],bgcolor,(int) (fill_opacity/0.0039215),fill_color,(int) (fill_opacity/0.0039215));
2787
                           string_length = snprintf(NULL,0,  "setTimeout(function(){filltoborder(%.*f,%.*f,[%s,%d],[%s,%d]);},1000);\n",decimals,double_data[0],decimals,double_data[1],bgcolor,(int) (fill_opacity/0.0039215),fill_color,(int) (fill_opacity/0.0039215));
2788
                           check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2788
                           check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2789
                           snprintf(tmp_buffer,string_length,"setTimeout(function(){filltoborder(%.*f,%.*f,[%s,%d],[%s,%d]);},1000);\n",decimals,double_data[0],decimals,double_data[1],bgcolor,(int) (fill_opacity/0.0039215),fill_color,(int) (fill_opacity/0.0039215));
2789
                           snprintf(tmp_buffer,string_length,"setTimeout(function(){filltoborder(%.*f,%.*f,[%s,%d],[%s,%d]);},1000);\n",decimals,double_data[0],decimals,double_data[1],bgcolor,(int) (fill_opacity/0.0039215),fill_color,(int) (fill_opacity/0.0039215));
2790
                           add_to_buffer(tmp_buffer);
2790
                           add_to_buffer(tmp_buffer);
2791
                           break;
2791
                           break;
2792
                    default:break;
2792
                    default:break;
2793
                }
2793
                }
2794
            }
2794
            }
2795
            reset();
2795
            reset();
2796
        break;
2796
        break;
2797
        case FLOODFILL:
2797
        case FLOODFILL:
2798
        /*
2798
        /*
2799
        @ floodfill x,y,color
2799
        @ floodfill x,y,color
Line 2802... Line 2802...
2802
        @ any other color or size of picture (borders of picture) will act as border to the bucket fill
2802
        @ any other color or size of picture (borders of picture) will act as border to the bucket fill
2803
        @ use this command  after all boundary objects are declared.
2803
        @ use this command  after all boundary objects are declared.
2804
        @ Use command 'clickfill,color' for user click driven flood fill.
2804
        @ Use command 'clickfill,color' for user click driven flood fill.
2805
        @ NOTE: recognised colour boundaries are in the "drag canvas" e.g. only for objects that can be set draggable / clickable
2805
        @ NOTE: recognised colour boundaries are in the "drag canvas" e.g. only for objects that can be set draggable / clickable
2806
        @ NOTE: floodfill 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..
2806
        @ NOTE: floodfill 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..
2807
        */
2807
        */
2808
            for(i=0 ;i < 4 ; i++){
2808
            for(i=0 ;i < 4 ; i++){
2809
                switch(i){
2809
                switch(i){
2810
                    case 0:double_data[0] = get_real(infile,0);break;
2810
                    case 0:double_data[0] = get_real(infile,0);break;
2811
                    case 1:double_data[1] = get_real(infile,0);break;
2811
                    case 1:double_data[1] = get_real(infile,0);break;
2812
                    case 2:fill_color = get_color(infile,1);
2812
                    case 2:fill_color = get_color(infile,1);
Line 2842... Line 2842...
2842
        @ the coloured areas can be removed (changed to "bgcolor") by  middle / right mouse click <br />(if the click is in an 40x40 pixel area of the click coordinate that "painted" the area)
2842
        @ the coloured areas can be removed (changed to "bgcolor") by  middle / right mouse click <br />(if the click is in an 40x40 pixel area of the click coordinate that "painted" the area)
2843
        @ the answer will be read as the (x:y) click coordinates per coloured area
2843
        @ the answer will be read as the (x:y) click coordinates per coloured area
2844
        @ background color of main div may be set by using command "bgcolor color"
2844
        @ background color of main div may be set by using command "bgcolor color"
2845
        @ may not be combined with command "userdraw"
2845
        @ may not be combined with command "userdraw"
2846
        @ NOTE: recognised colour boundaries are in the "drag canvas" e.g. only for objects that can be set draggable / clickable
2846
        @ NOTE: recognised colour boundaries are in the "drag canvas" e.g. only for objects that can be set draggable / clickable
2847
        */
2847
        */
2848
         fill_color = get_color(infile,1);
2848
         fill_color = get_color(infile,1);
2849
         if(js_function[DRAW_FLOODFILL] != 1 ){/* use only once */
2849
         if(js_function[DRAW_FLOODFILL] != 1 ){/* use only once */
2850
            js_function[DRAW_FLOODFILL] = 1;
2850
            js_function[DRAW_FLOODFILL] = 1;
2851
            add_js_floodfill(js_include_file,canvas_root_id);
2851
            add_js_floodfill(js_include_file,canvas_root_id);
2852
         }
2852
         }
Line 2856... Line 2856...
2856
        break;
2856
        break;
2857
        case SETPIXEL:
2857
        case SETPIXEL:
2858
        /*
2858
        /*
2859
        @ setpixel x,y,color
2859
        @ setpixel x,y,color
2860
        @ A "point" with diameter 1 pixel centeres at (x:y) in xrange / yrange
2860
        @ A "point" with diameter 1 pixel centeres at (x:y) in xrange / yrange
2861
        @ pixels can not be dragged or clicked
2861
        @ pixels can not be dragged or clicked
2862
        @ "pixelsize = 1" may be changed by command "pixelsize int"
2862
        @ "pixelsize = 1" may be changed by command "pixelsize int"
2863
        */
2863
        */
2864
            if( js_function[DRAW_PIXELS] != 1 ){ js_function[DRAW_PIXELS] = 1;}
2864
            if( js_function[DRAW_PIXELS] != 1 ){ js_function[DRAW_PIXELS] = 1;}
2865
            for(i=0;i<3;i++){
2865
            for(i=0;i<3;i++){
2866
                switch(i){
2866
                switch(i){
2867
                    case 0: double_data[0] = get_real(infile,0); break; /* x */
2867
                    case 0: double_data[0] = get_real(infile,0); break; /* x */
2868
                    case 1: double_data[1] = get_real(infile,0); break; /* y  */
2868
                    case 1: double_data[1] = get_real(infile,0); break; /* y  */
Line 2879... Line 2879...
2879
        break;
2879
        break;
2880
        case PIXELSIZE:
2880
        case PIXELSIZE:
2881
        /*
2881
        /*
2882
        @ pixelsize int
2882
        @ pixelsize int
2883
        @ in case you want to deviate from default pixelsize = 1...
2883
        @ in case you want to deviate from default pixelsize = 1...
2884
        */
2884
        */
2885
            pixelsize = (int) get_real(infile,1);
2885
            pixelsize = (int) get_real(infile,1);
2886
        break;
2886
        break;
2887
        case PIXELS:
2887
        case PIXELS:
2888
        /*
2888
        /*
2889
        @ pixels color,x1,y1,x2,y2,x3,y3...
2889
        @ pixels color,x1,y1,x2,y2,x3,y3...
Line 2933... Line 2933...
2933
        case LEGENDCOLORS:
2933
        case LEGENDCOLORS:
2934
        /*
2934
        /*
2935
        @ legendcolors color1:color2:color3:...:color_n
2935
        @ legendcolors color1:color2:color3:...:color_n
2936
        @ will be used to colour a legend: use this command after the legend command ! e.g.<br />legend test1:test2:test3<br />legendcolors blue:red:orange<br />
2936
        @ will be used to colour a legend: use this command after the legend command ! e.g.<br />legend test1:test2:test3<br />legendcolors blue:red:orange<br />
2937
        @ make sure the number of colours match the number of legend items
2937
        @ make sure the number of colours match the number of legend items
2938
        @ command 'legend' in case of 'piechart' and 'barchart' will use these colours per default (no need to specify 'legendcolors'
2938
        @ command 'legend' in case of 'piechart' and 'barchart' will use these colours per default (no need to specify 'legendcolors'
2939
        */
2939
        */
2940
            if(legend_cnt == -1){canvas_error("use command \"legend\" before command \"legendcolors\" ! ");}
2940
            if(legend_cnt == -1){canvas_error("use command \"legend\" before command \"legendcolors\" ! ");}
2941
            temp = get_string(infile,1);
2941
            temp = get_string(infile,1);
2942
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2942
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2943
            fprintf(js_include_file,"var legendcolors%d = [\"%s\"];",legend_cnt,temp);
2943
            fprintf(js_include_file,"var legendcolors%d = [\"%s\"];",legend_cnt,temp);
2944
            break;
2944
            break;
2945
        case LEGEND:
2945
        case LEGEND:
2946
        /*
2946
        /*
2947
        @ legend string1:string2:string3....string_n
2947
        @ legend string1:string2:string3....string_n
2948
        @ will be used to create a legend for a graph
2948
        @ will be used to create a legend for a graph
2949
        @ also see command 'piechart'  
2949
        @ also see command 'piechart'
2950
        @ will use the same colors per default as used in the graphs : use command 'legendcolors' to override the default
2950
        @ will use the same colors per default as used in the graphs : use command 'legendcolors' to override the default
2951
        */
2951
        */
2952
            temp = get_string(infile,1);
2952
            temp = get_string(infile,1);
2953
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2953
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2954
            legend_cnt++; /* attention :starts with -1 : it will be used in piechart etc */
2954
            legend_cnt++; /* attention :starts with -1 : it will be used in piechart etc */
Line 2957... Line 2957...
2957
        case XLABEL:
2957
        case XLABEL:
2958
        /*
2958
        /*
2959
        @ xlabel some_string
2959
        @ xlabel some_string
2960
        @ will be used to create a label for the x-axis (label is in quadrant I)
2960
        @ will be used to create a label for the x-axis (label is in quadrant I)
2961
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2961
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2962
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2962
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2963
        */
2963
        */
2964
            temp = get_string(infile,1);
2964
            temp = get_string(infile,1);
2965
            fprintf(js_include_file,"var xaxislabel = \"%s\";",temp);
2965
            fprintf(js_include_file,"var xaxislabel = \"%s\";",temp);
2966
            break;
2966
            break;
2967
        case YLABEL:
2967
        case YLABEL:
2968
        /*
2968
        /*
2969
        @ ylabel some_string
2969
        @ ylabel some_string
2970
        @ will be used to create a (vertical) label for the y-axis (label is in quadrant I)
2970
        @ will be used to create a (vertical) label for the y-axis (label is in quadrant I)
2971
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2971
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2972
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2972
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2973
        */
2973
        */
2974
            temp = get_string(infile,1);
2974
            temp = get_string(infile,1);
2975
            fprintf(js_include_file,"var yaxislabel = \"%s\";",temp);
2975
            fprintf(js_include_file,"var yaxislabel = \"%s\";",temp);
2976
            break;
2976
            break;
2977
        case LINEGRAPH: /* scheme: var linegraph_0 = [ 'stroke_color','line_width','use_dashed' ,'dashtype0','dashtype1','x1','y1',...,'x_n','y_n'];*/
2977
        case LINEGRAPH: /* scheme: var linegraph_0 = [ 'stroke_color','line_width','use_dashed' ,'dashtype0','dashtype1','x1','y1',...,'x_n','y_n'];*/
Line 2983... Line 2983...
2983
        @ use command 'legend' to provide an optional legend in right-top-corner
2983
        @ use command 'legend' to provide an optional legend in right-top-corner
2984
        @ also see command 'piechart'
2984
        @ also see command 'piechart'
2985
        @ multiple linegraphs may be used in a single plot
2985
        @ multiple linegraphs may be used in a single plot
2986
        @ NOTE: your arguments are not checked by canvasdraw : use your javascript console in case of trouble...
2986
        @ NOTE: your arguments are not checked by canvasdraw : use your javascript console in case of trouble...
2987
        @ <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>
2987
        @ <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>
2988
        */    
2988
        */
2989
            temp = get_string(infile,1);
2989
            temp = get_string(infile,1);
2990
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2990
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2991
            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);
2991
            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);
2992
            linegraph_cnt++;
2992
            linegraph_cnt++;
2993
            reset();
2993
            reset();
Line 3064... Line 3064...
3064
                            }
3064
                            }
3065
                     break;
3065
                     break;
3066
                     default: canvas_error("interactive must be set 0,1 or 2");break;
3066
                     default: canvas_error("interactive must be set 0,1 or 2");break;
3067
                }
3067
                }
3068
                break;
3068
                break;
3069
                case 8:
3069
                case 8:
3070
                        if(clock_cnt == 0 ){ /* set opacity's just once .... it should be a argument to clock() , for now it's OK */
3070
                        if(clock_cnt == 0 ){ /* set opacity's just once .... it should be a argument to clock() , for now it's OK */
3071
                            fprintf(js_include_file,"var clock_bg_opacity = %.2f;var clock_fg_opacity = %.2f;",fill_opacity,stroke_opacity);
3071
                            fprintf(js_include_file,"var clock_bg_opacity = %.2f;var clock_fg_opacity = %.2f;",fill_opacity,stroke_opacity);
3072
                        }
3072
                        }
3073
                        temp = get_string(infile,1);
3073
                        temp = get_string(infile,1);
3074
                        if( strstr( temp,",") != 0 ){ temp = str_replace(temp,",","\",\""); }
3074
                        if( strstr( temp,",") != 0 ){ temp = str_replace(temp,",","\",\""); }
Line 3090... Line 3090...
3090
        @ radius in pixels
3090
        @ radius in pixels
3091
        @ data+color list: a colon separated list of raw data and corresponding colours<br />canvasdraw will not check validity of colornames...<br />in case of trouble look into javascript debugging of your browser
3091
        @ data+color list: a colon separated list of raw data and corresponding colours<br />canvasdraw will not check validity of colornames...<br />in case of trouble look into javascript debugging of your browser
3092
        @ example data+colorlist : 132:red:23565:green:323:black:234324:orange:23434:yellow:2543:white
3092
        @ example data+colorlist : 132:red:23565:green:323:black:234324:orange:23434:yellow:2543:white
3093
        @ the number of colors must match the number of data.
3093
        @ the number of colors must match the number of data.
3094
        @ use command "opacity 0-255,0-255" to adjust fill_opacity of colours
3094
        @ use command "opacity 0-255,0-255" to adjust fill_opacity of colours
3095
        @ 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...<br />use command 'fontfamily' to set the font of the legend.
3095
        @ 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...<br />use command 'fontfamily' to set the font of the legend.
3096
        */
3096
        */
3097
            if( js_function[DRAW_PIECHART] != 1 ){ js_function[DRAW_PIECHART] = 1;}    
3097
            if( js_function[DRAW_PIECHART] != 1 ){ js_function[DRAW_PIECHART] = 1;}
3098
            for(i=0;i<5;i++){
3098
            for(i=0;i<5;i++){
3099
                switch(i){
3099
                switch(i){
3100
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
3100
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
3101
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
3101
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
3102
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
3102
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
Line 3119... Line 3119...
3119
        @alernative keyword: nostatus
3119
        @alernative keyword: nostatus
3120
        @used to override the effects of "status=done" in wims (answer.phtml)
3120
        @used to override the effects of "status=done" in wims (answer.phtml)
3121
        @affects inputfields / textarea's in canvasimage and all userdraw based commands
3121
        @affects inputfields / textarea's in canvasimage and all userdraw based commands
3122
        @e.g.: if keyword 'status' is set, the pupil will be able to modify the canvas when the 'wims status variable' is set to 'done'
3122
        @e.g.: if keyword 'status' is set, the pupil will be able to modify the canvas when the 'wims status variable' is set to 'done'
3123
        */
3123
        */
3124
       
3124
 
3125
            fprintf(js_include_file,"\nwims_status=\"waiting\";\n");
3125
            fprintf(js_include_file,"\nwims_status=\"waiting\";\n");
3126
            break;
3126
            break;
3127
        case XLOGBASE:
3127
        case XLOGBASE:
3128
        /*
3128
        /*
3129
        @ xlogbase number
3129
        @ xlogbase number
Line 3148... Line 3148...
3148
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
3148
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
3149
         @ ymajor is the major step on the y-axis; yminor is the divisor for the y-step
3149
         @ ymajor is the major step on the y-axis; yminor is the divisor for the y-step
3150
         @ the linewidth is set using command 'linewidth int'
3150
         @ the linewidth is set using command 'linewidth int'
3151
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
3151
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
3152
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number'
3152
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number'
3153
         @ 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>
3153
         @ 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>
3154
         @ note: the complete canvas will be used for the 'log paper'
3154
         @ note: the complete canvas will be used for the 'log paper'
3155
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
3155
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
3156
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
3156
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
3157
         @ 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')  
3157
         @ 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')
3158
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
3158
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
3159
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
3159
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
3160
        */
3160
        */
3161
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
3161
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
3162
            if( js_function[DRAW_XLOGSCALE] != 1 ){ js_function[DRAW_XLOGSCALE] = 1;}
3162
            if( js_function[DRAW_XLOGSCALE] != 1 ){ js_function[DRAW_XLOGSCALE] = 1;}
3163
            for(i=0;i<4;i++){
3163
            for(i=0;i<4;i++){
3164
                switch(i){
3164
                switch(i){
3165
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
3165
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
3166
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
3166
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
3167
                    case 2: stroke_color = get_color(infile,0); break;
3167
                    case 2: stroke_color = get_color(infile,0); break;
3168
                    case 3: fill_color = get_color(infile,1);
3168
                    case 3: fill_color = get_color(infile,1);
3169
                        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);
3169
                        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);
3170
                        tmp_buffer = my_newmem(string_length+1);
3170
                        tmp_buffer = my_newmem(string_length+1);
3171
                        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);
3171
                        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);
3172
                        fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]);
3172
                        fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]);
3173
                        add_to_buffer(tmp_buffer);
3173
                        add_to_buffer(tmp_buffer);
Line 3182... Line 3182...
3182
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
3182
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
3183
         @ xmajor is the major step on the x-axis; xminor is the divisor for the x-step
3183
         @ xmajor is the major step on the x-axis; xminor is the divisor for the x-step
3184
         @ the linewidth is set using command 'linewidth int'
3184
         @ the linewidth is set using command 'linewidth int'
3185
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
3185
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
3186
         @ default logbase number = 10 ... when needed , set the logbase number with command 'ylogbase number'
3186
         @ default logbase number = 10 ... when needed , set the logbase number with command 'ylogbase number'
3187
         @ 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>
3187
         @ 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>
3188
         @ note: the complete canvas will be used for the 'log paper'
3188
         @ note: the complete canvas will be used for the 'log paper'
3189
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
3189
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
3190
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
3190
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
3191
         @ 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')  
3191
         @ 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')
3192
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
3192
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
3193
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
3193
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
3194
        */
3194
        */
3195
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
3195
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
3196
            if( js_function[DRAW_YLOGSCALE] != 1 ){ js_function[DRAW_YLOGSCALE] = 1;}
3196
            if( js_function[DRAW_YLOGSCALE] != 1 ){ js_function[DRAW_YLOGSCALE] = 1;}
3197
            for(i=0;i<4;i++){
3197
            for(i=0;i<4;i++){
3198
                switch(i){
3198
                switch(i){
3199
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
3199
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
3200
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
3200
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
3201
                    case 2: stroke_color = get_color(infile,0); break;
3201
                    case 2: stroke_color = get_color(infile,0); break;
3202
                    case 3: fill_color = get_color(infile,1);
3202
                    case 3: fill_color = get_color(infile,1);
3203
                        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);
3203
                        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);
3204
                        tmp_buffer = my_newmem(string_length+1);
3204
                        tmp_buffer = my_newmem(string_length+1);
3205
                        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);
3205
                        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);
3206
                        fprintf(js_include_file,"use_ylogscale=1;snap_x = %f;snap_y = ylogbase;",double_data[0]/int_data[0]);
3206
                        fprintf(js_include_file,"use_ylogscale=1;snap_x = %f;snap_y = ylogbase;",double_data[0]/int_data[0]);
3207
                        add_to_buffer(tmp_buffer);
3207
                        add_to_buffer(tmp_buffer);
3208
                        break;
3208
                        break;
3209
                    default:break;
3209
                    default:break;
3210
                }
3210
                }
3211
            }
3211
            }
3212
            break;
3212
            break;
3213
        case XYLOGSCALE:
3213
        case XYLOGSCALE:
Line 3215... Line 3215...
3215
         @ xylogscale majorcolor,minorcolor
3215
         @ xylogscale majorcolor,minorcolor
3216
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
3216
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
3217
         @ the linewidth is set using command 'linewidth int'
3217
         @ the linewidth is set using command 'linewidth int'
3218
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
3218
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
3219
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number' and/or 'ylogbase number'
3219
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number' and/or 'ylogbase number'
3220
         @ 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>
3220
         @ 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>
3221
         @ note: the complete canvas will be used for the 'log paper'
3221
         @ note: the complete canvas will be used for the 'log paper'
3222
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
3222
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
3223
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
3223
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
3224
         @ 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')  
3224
         @ 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')
3225
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
3225
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
3226
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
3226
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
3227
        */
3227
        */
3228
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
3228
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
3229
            if( js_function[DRAW_XYLOGSCALE] != 1 ){ js_function[DRAW_XYLOGSCALE] = 1;}
3229
            if( js_function[DRAW_XYLOGSCALE] != 1 ){ js_function[DRAW_XYLOGSCALE] = 1;}
3230
            for(i=0;i<2;i++){
3230
            for(i=0;i<2;i++){
3231
                switch(i){
3231
                switch(i){
3232
                    case 0: stroke_color = get_color(infile,0); break;
3232
                    case 0: stroke_color = get_color(infile,0); break;
3233
                    case 1: fill_color = get_color(infile,1);
3233
                    case 1: fill_color = get_color(infile,1);
3234
                        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);
3234
                        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);
3235
                        tmp_buffer = my_newmem(string_length+1);
3235
                        tmp_buffer = my_newmem(string_length+1);
3236
                        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);
3236
                        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);
3237
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
3237
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
3238
                        add_to_buffer(tmp_buffer);
3238
                        add_to_buffer(tmp_buffer);
Line 3242... Line 3242...
3242
            }
3242
            }
3243
        break;
3243
        break;
3244
        default:sync_input(infile);
3244
        default:sync_input(infile);
3245
        break;
3245
        break;
3246
    }
3246
    }
3247
  }
3247
  }
3248
  /* we are done parsing script file */
3248
  /* we are done parsing script file */
3249
  /* check if xrange / yrange was set explicit ... or use xmin=0 xmax=xsize ymin=0 ymax=ysize : Quadrant I */
3249
  /* check if xrange / yrange was set explicit ... or use xmin=0 xmax=xsize ymin=0 ymax=ysize : Quadrant I */
3250
  if( found_size_command == 1 ){
3250
  if( found_size_command == 1 ){
3251
    fprintf(js_include_file,"var xmin = 0;var xmax = %d;var ymin = 0;var ymax = %d",xsize,ysize);
3251
    fprintf(js_include_file,"var xmin = 0;var xmax = %d;var ymin = 0;var ymax = %d",xsize,ysize);
3252
  }
3252
  }
Line 3352... Line 3352...
3352
    if (oldlen != newlen){
3352
    if (oldlen != newlen){
3353
        for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){
3353
        for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){
3354
            count++;
3354
            count++;
3355
            retlen = p - str + strlen(p) + count * (newlen - oldlen);
3355
            retlen = p - str + strlen(p) + count * (newlen - oldlen);
3356
        }
3356
        }
3357
    }
3357
    }
3358
    else
3358
    else
3359
    {
3359
    {
3360
        retlen = strlen(str);
3360
        retlen = strlen(str);
3361
    }
3361
    }
3362
   
3362
 
3363
    if ((ret = malloc(retlen + 1)) == NULL){
3363
    if ((ret = malloc(retlen + 1)) == NULL){
3364
        ret = NULL;
3364
        ret = NULL;
3365
        canvas_error("string argument is NULL");
3365
        canvas_error("string argument is NULL");
3366
    }
3366
    }
3367
    else
3367
    else
Line 3391... Line 3391...
3391
        if( c != ' '){
3391
        if( c != ' '){
3392
            temp[i]=tolower(c);
3392
            temp[i]=tolower(c);
3393
            i++;
3393
            i++;
3394
        }
3394
        }
3395
    }
3395
    }
3396
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
3396
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
3397
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
3397
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
3398
    if( c == EOF ){finished = 1;}
3398
    if( c == EOF ){finished = 1;}
3399
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
3399
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
3400
    temp[i]='\0';
3400
    temp[i]='\0';
3401
    if( strlen(temp) == 0 ){ canvas_error("expected a colorname or hexnumber, but found nothing !!");}
3401
    if( strlen(temp) == 0 ){ canvas_error("expected a colorname or hexnumber, but found nothing !!");}
Line 3408... Line 3408...
3408
        int g = (int) strtol(green, NULL, 16);
3408
        int g = (int) strtol(green, NULL, 16);
3409
        int b = (int) strtol(blue,  NULL, 16);
3409
        int b = (int) strtol(blue,  NULL, 16);
3410
        string = (char *)my_newmem(12);
3410
        string = (char *)my_newmem(12);
3411
        snprintf(string,11,"%d,%d,%d",r,g,b);
3411
        snprintf(string,11,"%d,%d,%d",r,g,b);
3412
        return string;
3412
        return string;
3413
    }
3413
    }
3414
    else
3414
    else
3415
    {
3415
    {
3416
        string = (char *)my_newmem(sizeof(temp));
3416
        string = (char *)my_newmem(sizeof(temp));
3417
        snprintf(string,sizeof(temp),"%s",temp);
3417
        snprintf(string,sizeof(temp),"%s",temp);
3418
        for( i = 0; i <= NUMBER_OF_COLORNAMES ; i++ ){
3418
        for( i = 0; i <= NUMBER_OF_COLORNAMES ; i++ ){
Line 3433... Line 3433...
3433
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){
3433
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){
3434
        temp[i]=c;
3434
        temp[i]=c;
3435
        i++;
3435
        i++;
3436
        if(i > MAX_BUFFER){ canvas_error("string size too big...repeat command to fit string");break;}
3436
        if(i > MAX_BUFFER){ canvas_error("string size too big...repeat command to fit string");break;}
3437
    }
3437
    }
3438
    if( ( c == '\n' || c == EOF ) && last == 0){canvas_error("expecting more arguments in command");}
3438
    if( ( c == '\n' || c == EOF ) && last == 0){canvas_error("expecting more arguments in command");}
3439
    if( c == '\n') { done = TRUE; line_number++; }
3439
    if( c == '\n') { done = TRUE; line_number++; }
3440
    if( c == EOF ) {
3440
    if( c == EOF ) {
3441
        finished = 1;
3441
        finished = 1;
3442
        if( last != 1 ){ canvas_error("expected more arguments");}
3442
        if( last != 1 ){ canvas_error("expected more arguments");}
3443
    }
3443
    }
Line 3454... Line 3454...
3454
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',')){
3454
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',')){
3455
        temp[i]=c;
3455
        temp[i]=c;
3456
        i++;
3456
        i++;
3457
        if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;}
3457
        if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;}
3458
    }
3458
    }
3459
    if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");}
3459
    if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");}
3460
    if( c == '\n') { line_number++; }
3460
    if( c == '\n') { line_number++; }
3461
    if( c == EOF ) {finished = 1;}
3461
    if( c == EOF ) {finished = 1;}
3462
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
3462
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
3463
    temp[i]='\0';
3463
    temp[i]='\0';
3464
    if( strlen(temp) == 0 ){ canvas_error("expected a word or string (without comma) , but found nothing !!");}
3464
    if( strlen(temp) == 0 ){ canvas_error("expected a word or string (without comma) , but found nothing !!");}
Line 3472... Line 3472...
3472
    int c,i=0,found_calc = 0;
3472
    int c,i=0,found_calc = 0;
3473
    double y;
3473
    double y;
3474
    char tmp[MAX_INT];
3474
    char tmp[MAX_INT];
3475
    while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){
3475
    while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){
3476
     if( c != ' ' ){
3476
     if( c != ' ' ){
3477
     /*
3477
     /*
3478
     libmatheval will segfault when for example: "xrange -10,+10" or "xrange -10,10+" is used
3478
     libmatheval will segfault when for example: "xrange -10,+10" or "xrange -10,10+" is used
3479
     We will check after assert() if it's a NULL pointer...and exit program via :
3479
     We will check after assert() if it's a NULL pointer...and exit program via :
3480
     canvas_error("I'm having trouble parsing your \"expression\" ");
3480
     canvas_error("I'm having trouble parsing your \"expression\" ");
3481
     */
3481
     */
3482
      if( i == 0 &&  c == '+' ){
3482
      if( i == 0 &&  c == '+' ){
3483
       continue;
3483
       continue;
3484
      }
3484
      }
3485
      else
3485
      else
3486
      {
3486
      {
3487
       if(canvas_iscalculation(c) != 0){
3487
       if(canvas_iscalculation(c) != 0){
3488
        found_calc = 1;
3488
        found_calc = 1;
3489
        c = tolower(c);
3489
        c = tolower(c);
Line 3492... Line 3492...
3492
       i++;
3492
       i++;
3493
      }
3493
      }
3494
     }
3494
     }
3495
     if( i > MAX_INT - 1){canvas_error("number too large");}
3495
     if( i > MAX_INT - 1){canvas_error("number too large");}
3496
    }
3496
    }
3497
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
3497
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
3498
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
3498
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
3499
    if( c == EOF ){done = TRUE ; finished = 1;}
3499
    if( c == EOF ){done = TRUE ; finished = 1;}
3500
    tmp[i]='\0';
3500
    tmp[i]='\0';
3501
    if( strlen(tmp) == 0 ){canvas_error("expected a number , but found nothing !!");}
3501
    if( strlen(tmp) == 0 ){canvas_error("expected a number , but found nothing !!");}
3502
    if( found_calc == 1 ){ /* use libmatheval to calculate 2*pi/3 */
3502
    if( found_calc == 1 ){ /* use libmatheval to calculate 2*pi/3 */
Line 3520... Line 3520...
3520
 
3520
 
3521
 
3521
 
3522
/* convert x/y coordinates to pixel */
3522
/* convert x/y coordinates to pixel */
3523
int x2px(double x){
3523
int x2px(double x){
3524
 return x*xsize/(xmax - xmin) -  xsize*xmin/(xmax - xmin);
3524
 return x*xsize/(xmax - xmin) -  xsize*xmin/(xmax - xmin);
3525
}
3525
}
3526
 
3526
 
3527
int y2px(double y){
3527
int y2px(double y){
3528
 return -1*y*ysize/(ymax - ymin) + ymax*ysize/(ymax - ymin);
3528
 return -1*y*ysize/(ymax - ymin) + ymax*ysize/(ymax - ymin);
3529
}
3529
}
3530
 
3530
 
3531
double px2x(int x){
3531
double px2x(int x){
3532
 return (x*(xmax - xmin)/xsize + xmin);
3532
 return (x*(xmax - xmin)/xsize + xmin);
3533
}
3533
}
3534
double px2y(int y){
3534
double px2y(int y){
3535
 return (y*(ymax - ymin)/ysize + ymin);
3535
 return (y*(ymax - ymin)/ysize + ymin);
3536
}
3536
}
3537
 
3537
 
3538
void add_to_buffer(char *tmp){
3538
void add_to_buffer(char *tmp){
3539
 if( tmp == NULL || tmp == 0 ){ canvas_error("nothing to add_to_buffer()...");}
3539
 if( tmp == NULL || tmp == 0 ){ canvas_error("nothing to add_to_buffer()...");}
3540
 /*  do we have enough space left in buffer[MAX_BUFFER] ? */
3540
 /*  do we have enough space left in buffer[MAX_BUFFER] ? */
3541
 int space_left = (int) (sizeof(buffer) - strlen(buffer));
3541
 int space_left = (int) (sizeof(buffer) - strlen(buffer));
3542
 if( space_left > strlen(tmp)){
3542
 if( space_left > strlen(tmp)){
Line 3555... Line 3555...
3555
 if(use_dashed == TRUE){use_dashed = FALSE;}
3555
 if(use_dashed == TRUE){use_dashed = FALSE;}
3556
 if(use_rotate == TRUE){use_rotate = FALSE;}
3556
 if(use_rotate == TRUE){use_rotate = FALSE;}
3557
   onclick = 0;
3557
   onclick = 0;
3558
}
3558
}
3559
 
3559
 
3560
 
3560
 
3561
 
3561
 
3562
/* What reply format in read_canvas();
3562
/* What reply format in read_canvas();
3563
 
3563
 
3564
note:if userdraw is combined with inputfields...every "userdraw" based answer will append "\n" and  inputfield.value()
3564
note:if userdraw is combined with inputfields...every "userdraw" based answer will append "\n" and  inputfield.value()
3565
1 = x1,x2,x3,x4....x_n
3565
1 = x1,x2,x3,x4....x_n
3566
    y1,y2,y3,y4....y_n
3566
    y1,y2,y3,y4....y_n
3567
 
3567
 
3568
    x/y in pixels
3568
    x/y in pixels
3569
 
3569
 
3570
2 = x1,x2,x3,x4....x_n
3570
2 = x1,x2,x3,x4....x_n
3571
    y1,y2,y3,y4....y_n
3571
    y1,y2,y3,y4....y_n
3572
    x/y in  xrange / yrange coordinate system
3572
    x/y in  xrange / yrange coordinate system
3573
 
3573
 
3574
3 = x1,x2,x3,x4....x_n
3574
3 = x1,x2,x3,x4....x_n
3575
    y1,y2,y3,y4....y_n
3575
    y1,y2,y3,y4....y_n
3576
    r1,r2,r3,r4....r_n
3576
    r1,r2,r3,r4....r_n
3577
 
3577
 
3578
    x/y in pixels
3578
    x/y in pixels
3579
    r in pixels
3579
    r in pixels
3580
 
3580
 
3581
4 = x1,x2,x3,x4....x_n
3581
4 = x1,x2,x3,x4....x_n
3582
    y1,y2,y3,y4....y_n
3582
    y1,y2,y3,y4....y_n
3583
    r1,r2,r3,r4....r_n
3583
    r1,r2,r3,r4....r_n
3584
 
3584
 
3585
    x/y in  xrange / yrange coordinate system
3585
    x/y in  xrange / yrange coordinate system
3586
    r in pixels
3586
    r in pixels
3587
 
3587
 
3588
5 = Ax1,Ax2,Ax3,Ax4....Ax_n
3588
5 = Ax1,Ax2,Ax3,Ax4....Ax_n
3589
    Ay1,Ay2,Ay3,Ay4....Ay_n
3589
    Ay1,Ay2,Ay3,Ay4....Ay_n
3590
    Bx1,Bx2,Bx3,Bx4....Bx_n
3590
    Bx1,Bx2,Bx3,Bx4....Bx_n
3591
    By1,By2,By3,By4....By_n
3591
    By1,By2,By3,By4....By_n
3592
    Cx1,Cx2,Cx3,Cx4....Cx_n
3592
    Cx1,Cx2,Cx3,Cx4....Cx_n
3593
    Cy1,Cy2,Cy3,Cy4....Cy_n
3593
    Cy1,Cy2,Cy3,Cy4....Cy_n
3594
    ....
3594
    ....
3595
    Zx1,Zx2,Zx3,Zx4....Zx_n
3595
    Zx1,Zx2,Zx3,Zx4....Zx_n
3596
    Zy1,Zy2,Zy3,Zy4....Zy_n
3596
    Zy1,Zy2,Zy3,Zy4....Zy_n
3597
   
3597
 
3598
    x/y in pixels
3598
    x/y in pixels
3599
 
3599
 
3600
6 = Ax1,Ax2,Ax3,Ax4....Ax_n
3600
6 = Ax1,Ax2,Ax3,Ax4....Ax_n
3601
    Ay1,Ay2,Ay3,Ay4....Ay_n
3601
    Ay1,Ay2,Ay3,Ay4....Ay_n
3602
    Bx1,Bx2,Bx3,Bx4....Bx_n
3602
    Bx1,Bx2,Bx3,Bx4....Bx_n
3603
    By1,By2,By3,By4....By_n
3603
    By1,By2,By3,By4....By_n
3604
    Cx1,Cx2,Cx3,Cx4....Cx_n
3604
    Cx1,Cx2,Cx3,Cx4....Cx_n
3605
    Cy1,Cy2,Cy3,Cy4....Cy_n
3605
    Cy1,Cy2,Cy3,Cy4....Cy_n
3606
    ....
3606
    ....
3607
    Zx1,Zx2,Zx3,Zx4....Zx_n
3607
    Zx1,Zx2,Zx3,Zx4....Zx_n
3608
    Zy1,Zy2,Zy3,Zy4....Zy_n
3608
    Zy1,Zy2,Zy3,Zy4....Zy_n
3609
 
3609
 
3610
    x/y in  xrange / yrange coordinate system
3610
    x/y in  xrange / yrange coordinate system
3611
   
3611
 
3612
7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
3612
7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
3613
   
3613
 
3614
    x/y in pixels
3614
    x/y in pixels
3615
 
3615
 
3616
8 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
3616
8 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
3617
   
3617
 
3618
    x/y in  xrange / yrange coordinate system
3618
    x/y in  xrange / yrange coordinate system
3619
 
3619
 
3620
9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n    
3620
9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n
3621
 
3621
 
3622
    x/y in pixels
3622
    x/y in pixels
3623
 
3623
 
3624
10 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n    
3624
10 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n
-
 
3625
 
-
 
3626
    x/y in  xrange / yrange coordinate system
-
 
3627
 
-
 
3628
11 = Ax1,Ay1,Ax2,Ay2
-
 
3629
     Bx1,By1,Bx2,By2
-
 
3630
     Cx1,Cy1,Cx2,Cy2
-
 
3631
     Dx1,Dy1,Dx2,Dy2
-
 
3632
     ......
-
 
3633
     Zx1,Zy1,Zx2,Zy2
3625
 
3634
 
3626
    x/y in  xrange / yrange coordinate system
-
 
3627
 
-
 
3628
11 = Ax1,Ay1,Ax2,Ay2
-
 
3629
     Bx1,By1,Bx2,By2
-
 
3630
     Cx1,Cy1,Cx2,Cy2
-
 
3631
     Dx1,Dy1,Dx2,Dy2
-
 
3632
     ......
-
 
3633
     Zx1,Zy1,Zx2,Zy2
-
 
3634
     
-
 
3635
    x/y in  xrange / yrange coordinate system
3635
    x/y in  xrange / yrange coordinate system
3636
 
3636
 
3637
12 = Ax1,Ay1,Ax2,Ay2
3637
12 = Ax1,Ay1,Ax2,Ay2
3638
     Bx1,By1,Bx2,By2
3638
     Bx1,By1,Bx2,By2
3639
     Cx1,Cy1,Cx2,Cy2
3639
     Cx1,Cy1,Cx2,Cy2
3640
     Dx1,Dy1,Dx2,Dy2
3640
     Dx1,Dy1,Dx2,Dy2
3641
     ......
3641
     ......
3642
     Zx1,Zy1,Zx2,Zy2
3642
     Zx1,Zy1,Zx2,Zy2
3643
     
3643
 
3644
    x/y in pixels
3644
    x/y in pixels
3645
 
3645
 
3646
13 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2
3646
13 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2
3647
 
3647
 
3648
    x/y in  xrange / yrange coordinate system
3648
    x/y in  xrange / yrange coordinate system
Line 3661... Line 3661...
3661
19 = return clicked object number (analogue to shape-library onclick)
3661
19 = return clicked object number (analogue to shape-library onclick)
3662
20 = return x/y-data in x-range/y-range of all 'draggable' images
3662
20 = return x/y-data in x-range/y-range of all 'draggable' images
3663
21 = return verbatim coordinates (x1:y1) (x2:y2)...(x_n:y_n)
3663
21 = return verbatim coordinates (x1:y1) (x2:y2)...(x_n:y_n)
3664
22 = array : x1,y1,x2,y2,x3,y3,x4,y4...x_n,y_n
3664
22 = array : x1,y1,x2,y2,x3,y3,x4,y4...x_n,y_n
3665
    x/y in  xrange / yrange coordinate system
3665
    x/y in  xrange / yrange coordinate system
3666
23 = answertype for a polyline : remove multiple occurences  due to reclick on a point to create next polyline segment
3666
23 = answertype for a polyline : remove multiple occurences  due to reclick on a point to create next polyline segment
3667
24 = read all inputfield values: even those set 'readonly'
3667
24 = read all inputfield values: even those set 'readonly'
3668
25 = return all userdrawn arcs in degrees:
3668
25 = return all userdrawn arcs in degrees:
3669
26 = return all userdrawn arcs in radians:
3669
26 = return all userdrawn arcs in radians:
3670
27 = return (only) userdraw inputfields array: x1:y1:text1,x2:y2:text2...
3670
27 = return (only) userdraw inputfields array: x1:y1:text1,x2:y2:text2...
3671
*/
3671
*/
3672
 
3672
 
3673
 
3673
 
3674
void add_read_canvas(int type_reply,int reply_precision){
3674
void add_read_canvas(int type_reply,int reply_precision){
Line 3689... Line 3689...
3689
  };\
3689
  };\
3690
 };\
3690
 };\
3691
};",reply_precision);
3691
};",reply_precision);
3692
 
3692
 
3693
switch(type_reply){
3693
switch(type_reply){
3694
/*  
3694
/*
3695
answers may have:
3695
answers may have:
3696
x-values,y-values,r-values,input-fields,mathml-inputfields,text-typed answers
3696
x-values,y-values,r-values,input-fields,mathml-inputfields,text-typed answers
3697
*/
3697
*/
3698
    case 1: fprintf(js_include_file,"\
3698
    case 1: fprintf(js_include_file,"\
3699
\n<!-- begin function 1 read_canvas() -->\n\
3699
\n<!-- begin function 1 read_canvas() -->\n\
3700
read_canvas = function(){\
3700
read_canvas = function(){\
3701
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3701
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3702
 set_reply_precision();\
3702
 set_reply_precision();\
3703
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3703
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3704
  var p = 0;var input_reply = new Array();\
-
 
3705
  if( document.getElementById(\"canvas_input0\")){\
-
 
3706
   var t = 0;\
-
 
3707
   while(document.getElementById(\"canvas_input\"+t)){\
-
 
3708
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
-
 
3709
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
-
 
3710
     p++;\
-
 
3711
    };\
-
 
3712
    t++;\
-
 
3713
   };\
-
 
3714
  };\
-
 
3715
  if( typeof userdraw_text != 'undefined' ){\
-
 
3716
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply + \"\\n\"+userdraw_text;\
-
 
3717
  }\
-
 
3718
  else\
-
 
3719
  {\
-
 
3720
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply;\
-
 
3721
  }\
-
 
3722
 }\
-
 
3723
 else\
-
 
3724
 {\
-
 
3725
  if( typeof userdraw_text != 'undefined' ){\
-
 
3726
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_text;\
-
 
3727
  }\
-
 
3728
  else\
-
 
3729
  {\
-
 
3730
   return userdraw_x+\"\\n\"+userdraw_y;\
-
 
3731
  }\
-
 
3732
 };\
-
 
3733
};\n\
-
 
3734
<!-- end function 1 read_canvas() -->");
-
 
3735
    break;
-
 
3736
    case 2: fprintf(js_include_file,"\
-
 
3737
\n<!-- begin function 2 read_canvas() -->\n\
-
 
3738
read_canvas = function(){\
-
 
3739
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
-
 
3740
 set_reply_precision();\
-
 
3741
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
-
 
3742
 var prec = %d;\
-
 
3743
 while(userdraw_x[p]){\
-
 
3744
  reply_x[p] = (Math.round(prec*(px2x(userdraw_x[p]))))/prec;\
-
 
3745
  reply_y[p] = (Math.round(prec*(px2y(userdraw_y[p]))))/prec;\
-
 
3746
  p++;\
-
 
3747
 };\
-
 
3748
 if(p == 0){alert(\"nothing drawn...\");return;};\
-
 
3749
 if( document.getElementById(\"canvas_input0\")){\
-
 
3750
  var p = 0;var input_reply = new Array();\
3704
  var p = 0;var input_reply = new Array();\
3751
  if( document.getElementById(\"canvas_input0\")){\
3705
  if( document.getElementById(\"canvas_input0\")){\
3752
   var t = 0;\
3706
   var t = 0;\
3753
   while(document.getElementById(\"canvas_input\"+t)){\
3707
   while(document.getElementById(\"canvas_input\"+t)){\
3754
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3708
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
Line 3757... Line 3711...
3757
    };\
3711
    };\
3758
    t++;\
3712
    t++;\
3759
   };\
3713
   };\
3760
  };\
3714
  };\
3761
  if( typeof userdraw_text != 'undefined' ){\
3715
  if( typeof userdraw_text != 'undefined' ){\
3762
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3716
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply + \"\\n\"+userdraw_text;\
3763
  }\
3717
  }\
3764
  else\
3718
  else\
3765
  {\
3719
  {\
3766
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\
3720
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply;\
3767
  }\
3721
  }\
3768
 }\
3722
 }\
3769
 else\
3723
 else\
3770
 {\
3724
 {\
3771
  if( typeof userdraw_text != 'undefined' ){\
3725
  if( typeof userdraw_text != 'undefined' ){\
-
 
3726
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_text;\
-
 
3727
  }\
-
 
3728
  else\
-
 
3729
  {\
-
 
3730
   return userdraw_x+\"\\n\"+userdraw_y;\
-
 
3731
  }\
-
 
3732
 };\
-
 
3733
};\n\
-
 
3734
<!-- end function 1 read_canvas() -->");
-
 
3735
    break;
-
 
3736
    case 2: fprintf(js_include_file,"\
-
 
3737
\n<!-- begin function 2 read_canvas() -->\n\
-
 
3738
read_canvas = function(){\
-
 
3739
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
-
 
3740
 set_reply_precision();\
-
 
3741
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
-
 
3742
 var prec = %d;\
-
 
3743
 while(userdraw_x[p]){\
-
 
3744
  reply_x[p] = (Math.round(prec*(px2x(userdraw_x[p]))))/prec;\
-
 
3745
  reply_y[p] = (Math.round(prec*(px2y(userdraw_y[p]))))/prec;\
-
 
3746
  p++;\
-
 
3747
 };\
-
 
3748
 if(p == 0){alert(\"nothing drawn...\");return;};\
-
 
3749
 if( document.getElementById(\"canvas_input0\")){\
-
 
3750
  var p = 0;var input_reply = new Array();\
-
 
3751
  if( document.getElementById(\"canvas_input0\")){\
-
 
3752
   var t = 0;\
-
 
3753
   while(document.getElementById(\"canvas_input\"+t)){\
-
 
3754
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
-
 
3755
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
-
 
3756
     p++;\
-
 
3757
    };\
-
 
3758
    t++;\
-
 
3759
   };\
-
 
3760
  };\
-
 
3761
  if( typeof userdraw_text != 'undefined' ){\
-
 
3762
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
-
 
3763
  }\
-
 
3764
  else\
-
 
3765
  {\
-
 
3766
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\
-
 
3767
  }\
-
 
3768
 }\
-
 
3769
 else\
-
 
3770
 {\
-
 
3771
  if( typeof userdraw_text != 'undefined' ){\
3772
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_text;\
3772
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_text;\
3773
  }\
3773
  }\
3774
  else\
3774
  else\
3775
  {\
3775
  {\
3776
   return reply_x+\"\\n\"+reply_y;\
3776
   return reply_x+\"\\n\"+reply_y;\
3777
  };\
3777
  };\
Line 3781... Line 3781...
3781
    break;
3781
    break;
3782
    case 3: fprintf(js_include_file,"\
3782
    case 3: fprintf(js_include_file,"\
3783
\n<!-- begin function 3 read_canvas() -->\n\
3783
\n<!-- begin function 3 read_canvas() -->\n\
3784
read_canvas = function(){\
3784
read_canvas = function(){\
3785
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3785
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3786
 set_reply_precision();\
3786
 set_reply_precision();\
3787
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3787
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3788
  var p = 0;var input_reply = new Array();\
3788
  var p = 0;var input_reply = new Array();\
3789
  if( document.getElementById(\"canvas_input0\")){\
3789
  if( document.getElementById(\"canvas_input0\")){\
3790
   var t = 0;\
3790
   var t = 0;\
3791
   while(document.getElementById(\"canvas_input\"+t)){\
3791
   while(document.getElementById(\"canvas_input\"+t)){\
3792
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3792
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3793
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3793
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3794
     p++;\
3794
     p++;\
3795
    };\
3795
    };\
3796
    t++;\
3796
    t++;\
3797
   };\
3797
   };\
3798
  };\
3798
  };\
3799
  if( typeof userdraw_text != 'undefined' ){\
3799
  if( typeof userdraw_text != 'undefined' ){\
3800
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3800
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3801
  }\
3801
  }\
3802
  else\
3802
  else\
3803
  {\
3803
  {\
3804
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3804
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3805
  }\
3805
  }\
3806
 }\
3806
 }\
3807
 else\
3807
 else\
3808
 {\
3808
 {\
3809
  if( typeof userdraw_text != 'undefined' ){\
3809
  if( typeof userdraw_text != 'undefined' ){\
3810
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+userdrawW_text;\
3810
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+userdrawW_text;\
3811
  }\
3811
  }\
3812
  else\
3812
  else\
3813
  {\
3813
  {\
3814
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius;\
3814
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius;\
3815
  }\
3815
  }\
3816
 }\
3816
 }\
3817
};\n\
3817
};\n\
Line 3859... Line 3859...
3859
  }\
3859
  }\
3860
 };\
3860
 };\
3861
};\n\
3861
};\n\
3862
<!-- end function 4 read_canvas() -->",reply_precision);
3862
<!-- end function 4 read_canvas() -->",reply_precision);
3863
    break;
3863
    break;
3864
    /*
3864
    /*
3865
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3865
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3866
        used for userdraw multiple paths
3866
        used for userdraw multiple paths
3867
    */
3867
    */
3868
    case 5: fprintf(js_include_file,"\
3868
    case 5: fprintf(js_include_file,"\
3869
\n<!-- begin function 5 read_canvas() -->\n\
3869
\n<!-- begin function 5 read_canvas() -->\n\
3870
read_canvas = function(){\
3870
read_canvas = function(){\
3871
 set_reply_precision();\
3871
 set_reply_precision();\
3872
 var p = 0;\
3872
 var p = 0;\
3873
 var reply = \"\";\
3873
 var reply = \"\";\
3874
 for(p = 0; p < userdraw_x.length;p++){\
3874
 for(p = 0; p < userdraw_x.length;p++){\
3875
  if(userdraw_x[p] != null ){\
3875
  if(userdraw_x[p] != null ){\
3876
   reply = reply + userdraw_x[p]+\"\\n\"+userdraw_y[p]+\"\\n\";\
3876
   reply = reply + userdraw_x[p]+\"\\n\"+userdraw_y[p]+\"\\n\";\
3877
  };\
3877
  };\
3878
 };\
3878
 };\
3879
 if(p == 0){alert(\"nothing drawn...\");return;};\
3879
 if(p == 0){alert(\"nothing drawn...\");return;};\
3880
 userdraw_x = [];userdraw_y = [];\
3880
 userdraw_x = [];userdraw_y = [];\
3881
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3881
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3882
  var p = 0;var input_reply = new Array();\
3882
  var p = 0;var input_reply = new Array();\
3883
  if( document.getElementById(\"canvas_input0\")){\
3883
  if( document.getElementById(\"canvas_input0\")){\
3884
   var t = 0;\
3884
   var t = 0;\
3885
   while(document.getElementById(\"canvas_input\"+t)){\
3885
   while(document.getElementById(\"canvas_input\"+t)){\
3886
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3886
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3887
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3887
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3888
     p++;\
3888
     p++;\
3889
    };\
3889
    };\
3890
    t++;\
3890
    t++;\
3891
   };\
3891
   };\
3892
  };\
3892
  };\
3893
  if( typeof userdraw_text != 'undefined' ){\
3893
  if( typeof userdraw_text != 'undefined' ){\
3894
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3894
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3895
  }\
3895
  }\
3896
  else\
3896
  else\
3897
  {\
3897
  {\
3898
   return reply +\"\\n\"+input_reply;\
3898
   return reply +\"\\n\"+input_reply;\
3899
  }\
3899
  }\
3900
 }\
3900
 }\
3901
 else\
3901
 else\
3902
 {\
3902
 {\
3903
  if( typeof userdraw_text != 'undefined' ){\
3903
  if( typeof userdraw_text != 'undefined' ){\
3904
   return reply+\"\\n\"+userdraw_text;\
3904
   return reply+\"\\n\"+userdraw_text;\
3905
  }\
3905
  }\
3906
  else\
3906
  else\
Line 3909... Line 3909...
3909
  }\
3909
  }\
3910
 };\
3910
 };\
3911
};\n\
3911
};\n\
3912
<!-- end function 5 read_canvas() -->");
3912
<!-- end function 5 read_canvas() -->");
3913
    break;
3913
    break;
3914
    /*
3914
    /*
3915
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3915
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3916
        used for userdraw multiple paths
3916
        used for userdraw multiple paths
3917
    */
3917
    */
3918
    case 6: fprintf(js_include_file,"\
3918
    case 6: fprintf(js_include_file,"\
3919
\n<!-- begin function 6 read_canvas() -->\n\
3919
\n<!-- begin function 6 read_canvas() -->\n\
3920
read_canvas = function(){\
3920
read_canvas = function(){\
3921
 var p = 0;\
3921
 var p = 0;\
Line 3934... Line 3934...
3934
   reply = reply + tmp_x + \"\\n\" + tmp_y +\"\\n\";\
3934
   reply = reply + tmp_x + \"\\n\" + tmp_y +\"\\n\";\
3935
  };\
3935
  };\
3936
 };\
3936
 };\
3937
 if(p == 0){alert(\"nothing drawn...\");return;};\
3937
 if(p == 0){alert(\"nothing drawn...\");return;};\
3938
 userdraw_x = [];userdraw_y = [];\
3938
 userdraw_x = [];userdraw_y = [];\
3939
 if( document.getElementById(\"canvas_input0\") ){\
3939
 if( document.getElementById(\"canvas_input0\") ){\
3940
  var p = 0;var input_reply = new Array();\
3940
  var p = 0;var input_reply = new Array();\
3941
  if( document.getElementById(\"canvas_input0\")){\
3941
  if( document.getElementById(\"canvas_input0\")){\
3942
   var t = 0;\
3942
   var t = 0;\
3943
   while(document.getElementById(\"canvas_input\"+t)){\
3943
   while(document.getElementById(\"canvas_input\"+t)){\
3944
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3944
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3945
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3945
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3946
     p++;\
3946
     p++;\
3947
    };\
3947
    };\
3948
    t++;\
3948
    t++;\
3949
   };\
3949
   };\
3950
  };\
3950
  };\
3951
  if( typeof userdraw_text != 'undefined' ){\
3951
  if( typeof userdraw_text != 'undefined' ){\
3952
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3952
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3953
  }\
3953
  }\
3954
  else\
3954
  else\
3955
  {\
3955
  {\
3956
   return reply +\"\\n\"+input_reply;\
3956
   return reply +\"\\n\"+input_reply;\
3957
  }\
3957
  }\
3958
 }\
3958
 }\
3959
 else\
3959
 else\
Line 3975... Line 3975...
3975
 set_reply_precision();\
3975
 set_reply_precision();\
3976
 var reply = new Array();\
3976
 var reply = new Array();\
3977
 var p = 0;\
3977
 var p = 0;\
3978
 while(userdraw_x[p]){\
3978
 while(userdraw_x[p]){\
3979
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p];\
3979
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p];\
3980
  p++;\
3980
  p++;\
3981
 };\
3981
 };\
3982
 if(p == 0){alert(\"nothing drawn...\");return;};\
3982
 if(p == 0){alert(\"nothing drawn...\");return;};\
3983
 if( document.getElementById(\"canvas_input0\") ){\
3983
 if( document.getElementById(\"canvas_input0\") ){\
3984
  var p = 0;var input_reply = new Array();\
3984
  var p = 0;var input_reply = new Array();\
3985
  if( document.getElementById(\"canvas_input0\")){\
3985
  if( document.getElementById(\"canvas_input0\")){\
3986
   var t = 0;\
3986
   var t = 0;\
3987
   while(document.getElementById(\"canvas_input\"+t)){\
3987
   while(document.getElementById(\"canvas_input\"+t)){\
3988
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3988
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3989
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3989
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3990
     p++;\
3990
     p++;\
3991
    };\
3991
    };\
3992
    t++;\
3992
    t++;\
3993
   };\
3993
   };\
3994
  };\
3994
  };\
3995
  if( typeof userdraw_text != 'undefined' ){\
3995
  if( typeof userdraw_text != 'undefined' ){\
3996
   return reply+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3996
   return reply+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3997
  }\
3997
  }\
3998
  else\
3998
  else\
3999
  {\
3999
  {\
4000
   return reply+\"\\n\"+input_reply;\
4000
   return reply+\"\\n\"+input_reply;\
4001
  }\
4001
  }\
4002
 }\
4002
 }\
4003
 else\
4003
 else\
4004
 {\
4004
 {\
4005
  if( typeof userdraw_text != 'undefined' ){\
4005
  if( typeof userdraw_text != 'undefined' ){\
4006
   return reply+\"\\n\"+userdraw_text;\
4006
   return reply+\"\\n\"+userdraw_text;\
4007
  }\
4007
  }\
4008
  else\
4008
  else\
4009
  {\
4009
  {\
4010
   return reply;\
4010
   return reply;\
4011
  }\
4011
  }\
4012
 };\
4012
 };\
4013
};\n\
4013
};\n\
4014
<!-- end function 7 read_canvas() -->");
4014
<!-- end function 7 read_canvas() -->");
4015
    break;
4015
    break;
4016
    case 8: fprintf(js_include_file,"\
4016
    case 8: fprintf(js_include_file,"\
4017
\n<!-- begin function 8 read_canvas() -->\n\
4017
\n<!-- begin function 8 read_canvas() -->\n\
4018
read_canvas = function(){\
4018
read_canvas = function(){\
4019
 var reply = new Array();\
4019
 var reply = new Array();\
4020
 var p = 0;\
4020
 var p = 0;\
4021
 var prec = %d;\
4021
 var prec = %d;\
4022
 while(userdraw_x[p]){\
-
 
4023
  reply[p] = (Math.round(prec*(px2x(userdraw_x[p]))))/prec +\":\" + (Math.round(prec*(px2y(userdraw_y[p]))))/prec;\
-
 
4024
  p++;\
-
 
4025
 };\
-
 
4026
 if(p == 0){alert(\"nothing drawn...\");return;};\
-
 
4027
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
-
 
4028
  var p = 0;var input_reply = new Array();\
-
 
4029
  if( document.getElementById(\"canvas_input0\")){\
-
 
4030
   var t = 0;\
-
 
4031
   while(document.getElementById(\"canvas_input\"+t)){\
-
 
4032
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
-
 
4033
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
-
 
4034
     p++;\
-
 
4035
    };\
-
 
4036
    t++;\
-
 
4037
   };\
-
 
4038
  };\
-
 
4039
  if( typeof userdraw_text != 'undefined' ){\
-
 
4040
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
-
 
4041
  }\
-
 
4042
  else\
-
 
4043
  {\
-
 
4044
   return reply +\"\\n\"+input_reply;\
-
 
4045
  }\
-
 
4046
 }\
-
 
4047
 else\
-
 
4048
 {\
-
 
4049
  if( typeof userdraw_text != 'undefined' ){\
-
 
4050
   return reply +\"\\n\"+userdraw_text;\
-
 
4051
  }\
-
 
4052
  else\
-
 
4053
  {\
-
 
4054
   return reply;\
-
 
4055
  }\
-
 
4056
 };\
-
 
4057
};\n\
-
 
4058
<!-- end function 8 read_canvas() -->",reply_precision);
-
 
4059
    break;
-
 
4060
    case 9: fprintf(js_include_file,"\
-
 
4061
\n<!-- begin function 9 read_canvas() -->\n\
-
 
4062
read_canvas = function(){\
-
 
4063
 set_reply_precision();\
-
 
4064
 var reply = new Array();\
-
 
4065
 var p = 0;\
-
 
4066
 while(userdraw_x[p]){\
4022
 while(userdraw_x[p]){\
4067
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p] + \":\" + userdraw_radius[p];\
4023
  reply[p] = (Math.round(prec*(px2x(userdraw_x[p]))))/prec +\":\" + (Math.round(prec*(px2y(userdraw_y[p]))))/prec;\
4068
  p++;\
4024
  p++;\
4069
 };\
4025
 };\
4070
 if(p == 0){alert(\"nothing drawn...\");return;};\
4026
 if(p == 0){alert(\"nothing drawn...\");return;};\
-
 
4027
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
-
 
4028
  var p = 0;var input_reply = new Array();\
-
 
4029
  if( document.getElementById(\"canvas_input0\")){\
-
 
4030
   var t = 0;\
-
 
4031
   while(document.getElementById(\"canvas_input\"+t)){\
-
 
4032
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
-
 
4033
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
-
 
4034
     p++;\
-
 
4035
    };\
-
 
4036
    t++;\
-
 
4037
   };\
-
 
4038
  };\
-
 
4039
  if( typeof userdraw_text != 'undefined' ){\
-
 
4040
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
-
 
4041
  }\
-
 
4042
  else\
-
 
4043
  {\
-
 
4044
   return reply +\"\\n\"+input_reply;\
-
 
4045
  }\
-
 
4046
 }\
-
 
4047
 else\
-
 
4048
 {\
-
 
4049
  if( typeof userdraw_text != 'undefined' ){\
-
 
4050
   return reply +\"\\n\"+userdraw_text;\
-
 
4051
  }\
-
 
4052
  else\
-
 
4053
  {\
-
 
4054
   return reply;\
-
 
4055
  }\
-
 
4056
 };\
-
 
4057
};\n\
-
 
4058
<!-- end function 8 read_canvas() -->",reply_precision);
-
 
4059
    break;
-
 
4060
    case 9: fprintf(js_include_file,"\
-
 
4061
\n<!-- begin function 9 read_canvas() -->\n\
-
 
4062
read_canvas = function(){\
-
 
4063
 set_reply_precision();\
-
 
4064
 var reply = new Array();\
-
 
4065
 var p = 0;\
-
 
4066
 while(userdraw_x[p]){\
-
 
4067
  reply[p] = userdraw_x[p] +\":\" + userdraw_y[p] + \":\" + userdraw_radius[p];\
-
 
4068
  p++;\
-
 
4069
 };\
-
 
4070
 if(p == 0){alert(\"nothing drawn...\");return;};\
4071
 if( document.getElementById(\"canvas_input0\") ){\
4071
 if( document.getElementById(\"canvas_input0\") ){\
4072
  var p = 0;var input_reply = new Array();\
4072
  var p = 0;var input_reply = new Array();\
4073
  if( document.getElementById(\"canvas_input0\")){\
4073
  if( document.getElementById(\"canvas_input0\")){\
4074
   var t = 0;\
4074
   var t = 0;\
4075
   while(document.getElementById(\"canvas_input\"+t)){\
4075
   while(document.getElementById(\"canvas_input\"+t)){\
4076
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
4076
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
Line 4285... Line 4285...
4285
 var reply = new Array();\
4285
 var reply = new Array();\
4286
 var p = 0;var i = 0;\
4286
 var p = 0;var i = 0;\
4287
 while(userdraw_x[p]){\
4287
 while(userdraw_x[p]){\
4288
  reply[i] = userdraw_x[p] +\":\" + userdraw_y[p] +\":\" + userdraw_x[p+1] +\":\" + userdraw_y[p+1];\
4288
  reply[i] = userdraw_x[p] +\":\" + userdraw_y[p] +\":\" + userdraw_x[p+1] +\":\" + userdraw_y[p+1];\
4289
  p = p+2;i++;\
4289
  p = p+2;i++;\
4290
 };\
4290
 };\
4291
 if(p == 0){alert(\"nothing drawn...\");return;};\
4291
 if(p == 0){alert(\"nothing drawn...\");return;};\
4292
 if( document.getElementById(\"canvas_input0\") ){\
4292
 if( document.getElementById(\"canvas_input0\") ){\
4293
  var p = 0;var input_reply = new Array();\
4293
  var p = 0;var input_reply = new Array();\
4294
  if( document.getElementById(\"canvas_input0\")){\
4294
  if( document.getElementById(\"canvas_input0\")){\
4295
   var t = 0;\
4295
   var t = 0;\
4296
   while(document.getElementById(\"canvas_input\"+t)){\
4296
   while(document.getElementById(\"canvas_input\"+t)){\
4297
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
4297
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
4298
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
4298
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
4299
     p++;\
4299
     p++;\
4300
    };\
4300
    };\
4301
    t++;\
4301
    t++;\
4302
   };\
4302
   };\
4303
  };\
4303
  };\
4304
  if( typeof userdraw_text != 'undefined' ){\
4304
  if( typeof userdraw_text != 'undefined' ){\
4305
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
4305
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
4306
  }\
4306
  }\
4307
  else\
4307
  else\
4308
  {\
4308
  {\
4309
   return reply +\"\\n\"+input_reply;\
4309
   return reply +\"\\n\"+input_reply;\
4310
  }\
4310
  }\
Line 4609... Line 4609...
4609
 for(var p = 0 ; p < lu ; p++){\
4609
 for(var p = 0 ; p < lu ; p++){\
4610
   reply[p] = (Math.round(prec*(px2x(userdraw_x[p]))))/prec+\":\"+(Math.round(prec*(px2y(userdraw_y[p]))))/prec+\":\"+ document.getElementById(\"canvas_input\"+p).value;\
4610
   reply[p] = (Math.round(prec*(px2x(userdraw_x[p]))))/prec+\":\"+(Math.round(prec*(px2y(userdraw_y[p]))))/prec+\":\"+ document.getElementById(\"canvas_input\"+p).value;\
4611
 };\
4611
 };\
4612
 return reply;\
4612
 return reply;\
4613
};\n\
4613
};\n\
4614
<!-- end function 27 read_canvas() -->",reply_precision);    
4614
<!-- end function 27 read_canvas() -->",reply_precision);
4615
    break;
4615
    break;
4616
    default: canvas_error("hmmm unknown replyformat...");break;
4616
    default: canvas_error("hmmm unknown replyformat...");break;
4617
}
4617
}
4618
 return;
4618
 return;
4619
}
4619
}
4620
 
4620
 
4621
 
4621
 
4622
/*
4622
/*
4623
 add drawfunction :
4623
 add drawfunction :
4624
 - functions used by userdraw_primitives (circle,rect,path,triangle...)
4624
 - functions used by userdraw_primitives (circle,rect,path,triangle...)
4625
 - things not covered by the drag&drop library (static objects like parallel, lattice ,gridfill , imagefill)
4625
 - things not covered by the drag&drop library (static objects like parallel, lattice ,gridfill , imagefill)
4626
 - grid / mathml
4626
 - grid / mathml
4627
 - will not scale or zoom in
4627
 - will not scale or zoom in
4628
 - will not be filled via pixel operations like fill / floodfill / filltoborder / clickfill
4628
 - will not be filled via pixel operations like fill / floodfill / filltoborder / clickfill
4629
 - is printed directly into 'js_include_file'
4629
 - is printed directly into 'js_include_file'
4630
*/
4630
*/
4631
 
4631
 
4632
void add_javascript_functions(int js_functions[],int canvas_root_id){
4632
void add_javascript_functions(int js_functions[],int canvas_root_id){
4633
int i;
4633
int i;
4634
for(i = 0 ; i < MAX_JS_FUNCTIONS; i++){
4634
for(i = 0 ; i < MAX_JS_FUNCTIONS; i++){
Line 4729... Line 4729...
4729
  canvas_bg_div.style.backgroundSize = width+\"px \"+height+\"px\";\
4729
  canvas_bg_div.style.backgroundSize = width+\"px \"+height+\"px\";\
4730
  canvas_bg_div.style.backgroundRepeat = \"no-repeat\";\
4730
  canvas_bg_div.style.backgroundRepeat = \"no-repeat\";\
4731
  canvas_bg_div.style.backgroundPosition= sx+\"px \"+sy+\"px\";\
4731
  canvas_bg_div.style.backgroundPosition= sx+\"px \"+sy+\"px\";\
4732
  canvas_bg_div.style.backgroundImage = \"url(\" + URL + \")\";\
4732
  canvas_bg_div.style.backgroundImage = \"url(\" + URL + \")\";\
4733
 };\
4733
 };\
4734
};",canvas_root_id);    
4734
};",canvas_root_id);
4735
    break;
4735
    break;
4736
    case DRAW_GRIDFILL:/* not used for userdraw */
4736
    case DRAW_GRIDFILL:/* not used for userdraw */
4737
fprintf(js_include_file,"\n<!-- draw gridfill -->\n\
4737
fprintf(js_include_file,"\n<!-- draw gridfill -->\n\
4738
var draw_gridfill = function(canvas_type,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize){\
4738
var draw_gridfill = function(canvas_type,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize){\
4739
 var obj;\
4739
 var obj;\
4740
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4740
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4741
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4741
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4742
 }\
4742
 }\
4743
 else\
4743
 else\
4744
 {\
4744
 {\
4745
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4745
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4746
 };\
4746
 };\
4747
 var ctx = obj.getContext(\"2d\");\
4747
 var ctx = obj.getContext(\"2d\");\
4748
 var x,y;\
4748
 var x,y;\
4749
 snap_x = dx;snap_y = dy;\
4749
 snap_x = dx;snap_y = dy;\
4750
 ctx.save();\
4750
 ctx.save();\
4751
 ctx.strokeStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4751
 ctx.strokeStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4752
 for( x = x0 ; x < xsize+dx ; x = x + dx ){\
4752
 for( x = x0 ; x < xsize+dx ; x = x + dx ){\
Line 4754... Line 4754...
4754
    ctx.lineTo(x,ysize);\
4754
    ctx.lineTo(x,ysize);\
4755
 };\
4755
 };\
4756
 for( y = y0 ; y < ysize+dy; y = y + dy ){\
4756
 for( y = y0 ; y < ysize+dy; y = y + dy ){\
4757
    ctx.moveTo(x0,y);\
4757
    ctx.moveTo(x0,y);\
4758
    ctx.lineTo(xsize,y);\
4758
    ctx.lineTo(xsize,y);\
4759
 };\
4759
 };\
4760
 ctx.stroke();\
4760
 ctx.stroke();\
4761
 ctx.restore();\
4761
 ctx.restore();\
4762
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4762
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4763
    break;
4763
    break;
4764
   
4764
 
4765
    case DRAW_IMAGEFILL:/* not  used for userdraw */
4765
    case DRAW_IMAGEFILL:/* not  used for userdraw */
4766
fprintf(js_include_file,"\n<!-- draw imagefill -->\n\
4766
fprintf(js_include_file,"\n<!-- draw imagefill -->\n\
4767
var draw_imagefill = function(canvas_type,x0,y0,URL,xsize,ysize){\
4767
var draw_imagefill = function(canvas_type,x0,y0,URL,xsize,ysize){\
4768
 var obj;\
4768
 var obj;\
4769
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4769
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4770
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4770
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4771
 }\
4771
 }\
4772
 else\
4772
 else\
4773
 {\
4773
 {\
4774
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4774
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4775
 };\
4775
 };\
4776
 var ctx = obj.getContext(\"2d\");\
4776
 var ctx = obj.getContext(\"2d\");\
4777
 ctx.save();\
4777
 ctx.save();\
Line 4801... Line 4801...
4801
 };\
4801
 };\
4802
 ctx.restore();\
4802
 ctx.restore();\
4803
 return;\
4803
 return;\
4804
};",canvas_root_id,canvas_root_id,canvas_root_id);
4804
};",canvas_root_id,canvas_root_id,canvas_root_id);
4805
    break;
4805
    break;
4806
   
4806
 
4807
    case DRAW_DOTFILL:/* not  used for userdraw */
4807
    case DRAW_DOTFILL:/* not  used for userdraw */
4808
fprintf(js_include_file,"\n<!-- draw dotfill -->\n\
4808
fprintf(js_include_file,"\n<!-- draw dotfill -->\n\
4809
var draw_dotfill = function(canvas_type,x0,y0,dx,dy,radius,color,opacity,xsize,ysize){\
4809
var draw_dotfill = function(canvas_type,x0,y0,dx,dy,radius,color,opacity,xsize,ysize){\
4810
 var obj;\
4810
 var obj;\
4811
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4811
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
Line 4828... Line 4828...
4828
  }\
4828
  }\
4829
 }\
4829
 }\
4830
 ctx.fill();\
4830
 ctx.fill();\
4831
 ctx.restore();\
4831
 ctx.restore();\
4832
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4832
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4833
    break;
4833
    break;
4834
 
4834
 
4835
    case DRAW_DIAMONDFILL:/* not used for userdraw */
4835
    case DRAW_DIAMONDFILL:/* not used for userdraw */
4836
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4836
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4837
var draw_diamondfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4837
var draw_diamondfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4838
  var obj;\
4838
  var obj;\
4839
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4839
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4840
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4840
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4841
 }\
4841
 }\
4842
 else\
4842
 else\
4843
 {\
4843
 {\
4844
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4844
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4845
 };\
4845
 };\
4846
 var ctx = obj.getContext(\"2d\");\
4846
 var ctx = obj.getContext(\"2d\");\
4847
 var x;\
4847
 var x;\
4848
 var y;\
4848
 var y;\
4849
 ctx.save();\
4849
 ctx.save();\
4850
 ctx.lineWidth = linewidth;\
4850
 ctx.lineWidth = linewidth;\
4851
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4851
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4852
 y = ysize;\
4852
 y = ysize;\
4853
 for( x = x0 ; x < xsize ; x = x + dx ){\
4853
 for( x = x0 ; x < xsize ; x = x + dx ){\
4854
  ctx.moveTo(x,y0);\
4854
  ctx.moveTo(x,y0);\
4855
  ctx.lineTo(xsize,y);\
4855
  ctx.lineTo(xsize,y);\
4856
  y = y - dy;\
4856
  y = y - dy;\
4857
 };\
4857
 };\
4858
 y = y0;\
4858
 y = y0;\
4859
 for( x = xsize ; x > 0 ; x = x - dx){\
4859
 for( x = xsize ; x > 0 ; x = x - dx){\
4860
  ctx.moveTo(x,ysize);\
4860
  ctx.moveTo(x,ysize);\
4861
  ctx.lineTo(x0,y);\
4861
  ctx.lineTo(x0,y);\
4862
  y = y + dy;\
4862
  y = y + dy;\
4863
 };\
4863
 };\
4864
 x = x0;\
4864
 x = x0;\
4865
 for( y = y0 ; y < ysize ; y = y + dy ){\
4865
 for( y = y0 ; y < ysize ; y = y + dy ){\
4866
  ctx.moveTo(xsize,y);\
4866
  ctx.moveTo(xsize,y);\
4867
  ctx.lineTo(x,ysize);\
4867
  ctx.lineTo(x,ysize);\
4868
  x = x + dx;\
4868
  x = x + dx;\
4869
 };\
4869
 };\
4870
 x = xsize;\
4870
 x = xsize;\
4871
 for( y = ysize ; y > y0 ; y = y - dy ){\
4871
 for( y = ysize ; y > y0 ; y = y - dy ){\
4872
  ctx.moveTo(x,y0);\
4872
  ctx.moveTo(x,y0);\
4873
  ctx.lineTo(x0,y);\
4873
  ctx.lineTo(x0,y);\
4874
  x = x - dx;\
4874
  x = x - dx;\
4875
 };\
4875
 };\
4876
 ctx.stroke();\
4876
 ctx.stroke();\
4877
 ctx.restore();\
4877
 ctx.restore();\
4878
 return;\
4878
 return;\
4879
 }",canvas_root_id,canvas_root_id,canvas_root_id);
4879
 }",canvas_root_id,canvas_root_id,canvas_root_id);
4880
    break;
4880
    break;
4881
   
4881
 
4882
    case DRAW_HATCHFILL:/* not used for userdraw */
4882
    case DRAW_HATCHFILL:/* not used for userdraw */
4883
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4883
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4884
var draw_hatchfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4884
var draw_hatchfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4885
  var obj;\
4885
  var obj;\
4886
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4886
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
Line 4925... Line 4925...
4925
  ctx.arc(x_points[p],y_points[p],radius[p],0,2*Math.PI,false);\
4925
  ctx.arc(x_points[p],y_points[p],radius[p],0,2*Math.PI,false);\
4926
  ctx.closePath();\
4926
  ctx.closePath();\
4927
  if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4927
  if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4928
  if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4928
  if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4929
  ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4929
  ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4930
  ctx.stroke();\
4930
  ctx.stroke();\
4931
 }\
4931
 }\
4932
 ctx.restore();\
4932
 ctx.restore();\
4933
 return;\
4933
 return;\
4934
};");
4934
};");
4935
    break;
4935
    break;
4936
    case DRAW_POLYLINE:/* user for userdraw : draw lines through points */
4936
    case DRAW_POLYLINE:/* user for userdraw : draw lines through points */
4937
fprintf(js_include_file,"\n<!-- draw polyline -->\n\
4937
fprintf(js_include_file,"\n<!-- draw polyline -->\n\
4938
var draw_polyline = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_affine,affine_matrix){\
4938
var draw_polyline = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_affine,affine_matrix){\
Line 4953... Line 4953...
4953
 ctx.fillStyle =\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4953
 ctx.fillStyle =\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4954
 for(var p = 0 ; p < x_points.length ; p++ ){\
4954
 for(var p = 0 ; p < x_points.length ; p++ ){\
4955
  ctx.beginPath();\
4955
  ctx.beginPath();\
4956
  ctx.arc(x_points[p],y_points[p],line_width,0,2*Math.PI,false);\
4956
  ctx.arc(x_points[p],y_points[p],line_width,0,2*Math.PI,false);\
4957
  ctx.closePath();ctx.fill();ctx.stroke();\
4957
  ctx.closePath();ctx.fill();ctx.stroke();\
4958
 };\
4958
 };\
4959
 ctx.restore();\
4959
 ctx.restore();\
4960
 return;\
4960
 return;\
4961
};");
4961
};");
4962
    break;
4962
    break;
4963
   
4963
 
4964
    case DRAW_SEGMENTS:/*  used for userdraw */
4964
    case DRAW_SEGMENTS:/*  used for userdraw */
4965
fprintf(js_include_file,"\n<!-- draw segments -->\n\
4965
fprintf(js_include_file,"\n<!-- draw segments -->\n\
4966
var draw_segments = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_affine,affine_matrix){\
4966
var draw_segments = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_affine,affine_matrix){\
4967
 ctx.save();\
4967
 ctx.save();\
4968
 if(use_affine == 1 ){ctx.translate(affine_matrix[4],affine_matrix[5]);}\
4968
 if(use_affine == 1 ){ctx.translate(affine_matrix[4],affine_matrix[5]);}\
4969
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4969
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4970
 ctx.lineWidth = line_width;\
4970
 ctx.lineWidth = line_width;\
4971
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4971
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4972
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4972
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4973
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4973
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4974
  ctx.beginPath();\
4974
  ctx.beginPath();\
4975
  ctx.moveTo(x_points[p],y_points[p]);\
4975
  ctx.moveTo(x_points[p],y_points[p]);\
4976
  ctx.lineTo(x_points[p+1],y_points[p+1]);\
4976
  ctx.lineTo(x_points[p+1],y_points[p+1]);\
4977
  ctx.closePath();\
4977
  ctx.closePath();\
4978
  ctx.stroke();\
4978
  ctx.stroke();\
4979
  }\
4979
  }\
4980
  ctx.restore();\
4980
  ctx.restore();\
4981
  return;\
4981
  return;\
4982
 };");
4982
 };");
4983
    break;
4983
    break;
4984
   
4984
 
4985
    case DRAW_LINES:/*  used for userdraw */
4985
    case DRAW_LINES:/*  used for userdraw */
4986
fprintf(js_include_file,"\n<!-- draw lines -->\n\
4986
fprintf(js_include_file,"\n<!-- draw lines -->\n\
4987
function calc_line(x1,x2,y1,y2){\
4987
function calc_line(x1,x2,y1,y2){\
4988
 var marge = 2;\
4988
 var marge = 2;\
4989
 if(x1 < x2+marge && x1>x2-marge){\
4989
 if(x1 < x2+marge && x1>x2-marge){\
Line 5028... Line 5028...
5028
 for(var p = 0 ; p < x_points.length ; p++ ){\
5028
 for(var p = 0 ; p < x_points.length ; p++ ){\
5029
  x1 = x_points[p] - crosshair_size;\
5029
  x1 = x_points[p] - crosshair_size;\
5030
  x2 = x_points[p] + crosshair_size;\
5030
  x2 = x_points[p] + crosshair_size;\
5031
  y1 = y_points[p] - crosshair_size;\
5031
  y1 = y_points[p] - crosshair_size;\
5032
  y2 = y_points[p] + crosshair_size;\
5032
  y2 = y_points[p] + crosshair_size;\
5033
  ctx.beginPath();\
5033
  ctx.beginPath();\
5034
  ctx.moveTo(x1,y1);\
5034
  ctx.moveTo(x1,y1);\
5035
  ctx.lineTo(x2,y2);\
5035
  ctx.lineTo(x2,y2);\
5036
  ctx.closePath();\
5036
  ctx.closePath();\
5037
  ctx.stroke();\
5037
  ctx.stroke();\
5038
  ctx.beginPath();\
5038
  ctx.beginPath();\
5039
  ctx.moveTo(x2,y1);\
5039
  ctx.moveTo(x2,y1);\
5040
  ctx.lineTo(x1,y2);\
5040
  ctx.lineTo(x1,y2);\
5041
  ctx.closePath();\
5041
  ctx.closePath();\
5042
  ctx.stroke();\
5042
  ctx.stroke();\
5043
 }\
5043
 }\
5044
 ctx.restore();\
5044
 ctx.restore();\
5045
  return;\
5045
  return;\
5046
};");
5046
};");
Line 5091... Line 5091...
5091
  if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();};\
5091
  if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();};\
5092
  ctx.stroke();\
5092
  ctx.stroke();\
5093
 }\
5093
 }\
5094
 ctx.restore();\
5094
 ctx.restore();\
5095
};");
5095
};");
5096
    break;
5096
    break;
5097
 
5097
 
5098
    case DRAW_ELLIPSES:/* not  used for userdraw */
5098
    case DRAW_ELLIPSES:/* not  used for userdraw */
5099
fprintf(js_include_file,"\n<!-- draw ellipses -->\n\
5099
fprintf(js_include_file,"\n<!-- draw ellipses -->\n\
5100
var 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_affine,affine_matrix){\
5100
var 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_affine,affine_matrix){\
5101
 var obj;\
5101
 var obj;\
Line 5145... Line 5145...
5145
 if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
5145
 if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
5146
 ctx.stroke();\
5146
 ctx.stroke();\
5147
 ctx.restore();\
5147
 ctx.restore();\
5148
 return;\
5148
 return;\
5149
};");
5149
};");
5150
   
5150
 
5151
    break;
5151
    break;
5152
    case DRAW_ARROWS:/*  used for userdraw */
5152
    case DRAW_ARROWS:/*  used for userdraw */
5153
fprintf(js_include_file,"\n<!-- draw arrows -->\n\
5153
fprintf(js_include_file,"\n<!-- draw arrows -->\n\
5154
var 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_affine,affine_matrix){\
5154
var 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_affine,affine_matrix){\
5155
 ctx.save();\
5155
 ctx.save();\
Line 5220... Line 5220...
5220
 src.type = \"video/mp4\";\
5220
 src.type = \"video/mp4\";\
5221
 src.src = URL;\
5221
 src.src = URL;\
5222
 video.appendChild(src);\
5222
 video.appendChild(src);\
5223
 video.load();\
5223
 video.load();\
5224
 return;\
5224
 return;\
5225
};");    
5225
};");
5226
    break;
5226
    break;
5227
   
5227
 
5228
    case DRAW_AUDIO:/* not used for userdraw */
5228
    case DRAW_AUDIO:/* not used for userdraw */
5229
fprintf(js_include_file,"\n<!-- draw audio -->\n\
5229
fprintf(js_include_file,"\n<!-- draw audio -->\n\
5230
var draw_audio = function(canvas_root_id,x,y,w,h,loop,visible,URL1,URL2){\
5230
var draw_audio = function(canvas_root_id,x,y,w,h,loop,visible,URL1,URL2){\
5231
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
5231
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
5232
 var audio_div = document.createElement(\"div\");\
5232
 var audio_div = document.createElement(\"div\");\
Line 5252... Line 5252...
5252
 audio.appendChild(src2);\
5252
 audio.appendChild(src2);\
5253
 audio.load();\
5253
 audio.load();\
5254
 return;\
5254
 return;\
5255
};");
5255
};");
5256
    break;
5256
    break;
5257
   
5257
 
5258
    case DRAW_HTTP:/* not  used for userdraw */
5258
    case DRAW_HTTP:/* not  used for userdraw */
5259
fprintf(js_include_file,"\n<!-- draw http -->\n\
5259
fprintf(js_include_file,"\n<!-- draw http -->\n\
5260
var draw_http = function(canvas_root_id,x,y,w,h,URL){\
5260
var draw_http = function(canvas_root_id,x,y,w,h,URL){\
5261
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
5261
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
5262
 var http_div = document.createElement(\"div\");\
5262
 var http_div = document.createElement(\"div\");\
Line 5267... Line 5267...
5267
 iframe.setAttribute(\"width\",w);\
5267
 iframe.setAttribute(\"width\",w);\
5268
 iframe.setAttribute(\"height\",h);\
5268
 iframe.setAttribute(\"height\",h);\
5269
 return;\
5269
 return;\
5270
};");
5270
};");
5271
    break;
5271
    break;
5272
   
5272
 
5273
    case DRAW_XML:
5273
    case DRAW_XML:
5274
fprintf(js_include_file,"\n<!-- draw xml -->\n\
5274
fprintf(js_include_file,"\n<!-- draw xml -->\n\
5275
var draw_xml = function(canvas_root_id,x,y,w,h,mathml,onclick){\
5275
var draw_xml = function(canvas_root_id,x,y,w,h,mathml,onclick){\
5276
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
5276
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
5277
 var xml_div = document.createElement(\"div\");\
5277
 var xml_div = document.createElement(\"div\");\
Line 5291... Line 5291...
5291
 return;\
5291
 return;\
5292
};"
5292
};"
5293
);
5293
);
5294
    break;
5294
    break;
5295
    case DRAW_SGRAPH:
5295
    case DRAW_SGRAPH:
5296
/*
5296
/*
5297
 xstart = given
5297
 xstart = given
5298
 ystart = given
5298
 ystart = given
5299
 sgraph(canvas_type,precision,xmajor,ymajor,xminor,yminor,majorcolor,minorcolor,fontfamily)
5299
 sgraph(canvas_type,precision,xmajor,ymajor,xminor,yminor,majorcolor,minorcolor,fontfamily)
5300
*/
5300
*/
5301
fprintf(js_include_file,"\n<!-- draw sgraph -->\n\
5301
fprintf(js_include_file,"\n<!-- draw sgraph -->\n\
Line 5328... Line 5328...
5328
 ctx.moveTo(zero_x,zero_y);\
5328
 ctx.moveTo(zero_x,zero_y);\
5329
 ctx.lineTo(zero_x + 0.25*snor_x,zero_y - 0.1*snor_x);\
5329
 ctx.lineTo(zero_x + 0.25*snor_x,zero_y - 0.1*snor_x);\
5330
 ctx.lineTo(zero_x + 0.5*snor_x,zero_y + 0.1*snor_x);\
5330
 ctx.lineTo(zero_x + 0.5*snor_x,zero_y + 0.1*snor_x);\
5331
 ctx.lineTo(zero_x + 0.75*snor_x,zero_y - 0.1*snor_x);\
5331
 ctx.lineTo(zero_x + 0.75*snor_x,zero_y - 0.1*snor_x);\
5332
 ctx.lineTo(zero_x + snor_x,zero_y);\
5332
 ctx.lineTo(zero_x + snor_x,zero_y);\
5333
 ctx.stroke();\
5333
 ctx.stroke();\
5334
 ctx.closePath();\
5334
 ctx.closePath();\
5335
 ctx.beginPath();\
5335
 ctx.beginPath();\
5336
 var num = xstart;\
5336
 var num = xstart;\
5337
 var flipflop = 1;\
5337
 var flipflop = 1;\
5338
 var step_x = xmajor*(xsize - zero_x - snor_x)/(xmax - xstart);\
5338
 var step_x = xmajor*(xsize - zero_x - snor_x)/(xmax - xstart);\
Line 5523... Line 5523...
5523
 ctx.lineTo(p,ysize);\
5523
 ctx.lineTo(p,ysize);\
5524
};\
5524
};\
5525
for(var p = zero_x ; p > 0; p = p - xstep){\
5525
for(var p = zero_x ; p > 0; p = p - xstep){\
5526
 ctx.moveTo(p,0);\
5526
 ctx.moveTo(p,0);\
5527
 ctx.lineTo(p,ysize);\
5527
 ctx.lineTo(p,ysize);\
5528
};\
5528
};\
5529
for(var p = zero_y ; p < ysize; p = p + ystep){\
5529
for(var p = zero_y ; p < ysize; p = p + ystep){\
5530
 ctx.moveTo(0,p);\
5530
 ctx.moveTo(0,p);\
5531
 ctx.lineTo(xsize,p);\
5531
 ctx.lineTo(xsize,p);\
5532
};\
5532
};\
5533
for(var p = zero_y ; p > 0; p = p - ystep){\
5533
for(var p = zero_y ; p > 0; p = p - ystep){\
Line 5537... Line 5537...
5537
if( typeof xaxislabel !== 'undefined' ){\
5537
if( typeof xaxislabel !== 'undefined' ){\
5538
 ctx.save();\
5538
 ctx.save();\
5539
 ctx.font = \"italic \"+font_size+\"px Ariel\";\
5539
 ctx.font = \"italic \"+font_size+\"px Ariel\";\
5540
 var corr =  ctx.measureText(xaxislabel).width;\
5540
 var corr =  ctx.measureText(xaxislabel).width;\
5541
 ctx.fillText(xaxislabel,xsize - 1.5*corr,zero_y - tics_length - 0.4*font_size);\
5541
 ctx.fillText(xaxislabel,xsize - 1.5*corr,zero_y - tics_length - 0.4*font_size);\
5542
 ctx.restore();\
5542
 ctx.restore();\
5543
};\
5543
};\
5544
if( typeof yaxislabel !== 'undefined' ){\
5544
if( typeof yaxislabel !== 'undefined' ){\
5545
 ctx.save();\
5545
 ctx.save();\
5546
 ctx.font = \"italic \"+font_size+\"px Ariel\";\
5546
 ctx.font = \"italic \"+font_size+\"px Ariel\";\
5547
 var corr =  ctx.measureText(yaxislabel).width;\
5547
 var corr =  ctx.measureText(yaxislabel).width;\
5548
 ctx.translate(zero_x+tics_length + font_size,corr+font_size);\
5548
 ctx.translate(zero_x+tics_length + font_size,corr+font_size);\
Line 5585... Line 5585...
5585
 ctx.stroke();\
5585
 ctx.stroke();\
5586
 ctx.closePath();\
5586
 ctx.closePath();\
5587
 ctx.lineWidth = line_width+0.5;\
5587
 ctx.lineWidth = line_width+0.5;\
5588
 ctx.beginPath();\
5588
 ctx.beginPath();\
5589
 for(var p = zero_x ; p < xsize; p = p + xstep){\
5589
 for(var p = zero_x ; p < xsize; p = p + xstep){\
5590
  ctx.moveTo(p,zero_y-tics_length);\
5590
  ctx.moveTo(p,zero_y-tics_length);\
5591
  ctx.lineTo(p,zero_y+tics_length);\
5591
  ctx.lineTo(p,zero_y+tics_length);\
5592
 };\
5592
 };\
5593
 for(var p = zero_x ; p > 0; p = p - xstep){\
5593
 for(var p = zero_x ; p > 0; p = p - xstep){\
5594
  ctx.moveTo(p,zero_y-tics_length);\
5594
  ctx.moveTo(p,zero_y-tics_length);\
5595
  ctx.lineTo(p,zero_y+tics_length);\
5595
  ctx.lineTo(p,zero_y+tics_length);\
5596
 };\
5596
 };\
5597
 for(var p = zero_y ; p < ysize; p = p + ystep){\
5597
 for(var p = zero_y ; p < ysize; p = p + ystep){\
5598
  ctx.moveTo(zero_x-tics_length,p);\
5598
  ctx.moveTo(zero_x-tics_length,p);\
5599
  ctx.lineTo(zero_x+tics_length,p);\
5599
  ctx.lineTo(zero_x+tics_length,p);\
5600
 };\
5600
 };\
5601
 for(var p = zero_y ; p > 0; p = p - ystep){\
5601
 for(var p = zero_y ; p > 0; p = p - ystep){\
5602
  ctx.moveTo(zero_x-tics_length,p);\
5602
  ctx.moveTo(zero_x-tics_length,p);\
5603
  ctx.lineTo(zero_x+tics_length,p);\
5603
  ctx.lineTo(zero_x+tics_length,p);\
5604
 };\
5604
 };\
5605
 for(var p = zero_x ; p < xsize; p = p + x2step){\
5605
 for(var p = zero_x ; p < xsize; p = p + x2step){\
5606
  ctx.moveTo(p,zero_y-0.5*tics_length);\
5606
  ctx.moveTo(p,zero_y-0.5*tics_length);\
5607
  ctx.lineTo(p,zero_y+0.5*tics_length);\
5607
  ctx.lineTo(p,zero_y+0.5*tics_length);\
5608
 };\
5608
 };\
5609
 for(var p = zero_x ; p > 0; p = p - x2step){\
5609
 for(var p = zero_x ; p > 0; p = p - x2step){\
5610
  ctx.moveTo(p,zero_y-0.5*tics_length);\
5610
  ctx.moveTo(p,zero_y-0.5*tics_length);\
5611
  ctx.lineTo(p,zero_y+0.5*tics_length);\
5611
  ctx.lineTo(p,zero_y+0.5*tics_length);\
5612
 };\
5612
 };\
5613
 for(var p = zero_y ; p < ysize; p = p + y2step){\
5613
 for(var p = zero_y ; p < ysize; p = p + y2step){\
5614
  ctx.moveTo(zero_x-0.5*tics_length,p);\
5614
  ctx.moveTo(zero_x-0.5*tics_length,p);\
5615
  ctx.lineTo(zero_x+0.5*tics_length,p);\
5615
  ctx.lineTo(zero_x+0.5*tics_length,p);\
5616
 };\
5616
 };\
5617
 for(var p = zero_y ; p > 0; p = p - y2step){\
5617
 for(var p = zero_y ; p > 0; p = p - y2step){\
5618
  ctx.moveTo(zero_x-0.5*tics_length,p);\
5618
  ctx.moveTo(zero_x-0.5*tics_length,p);\
5619
  ctx.lineTo(zero_x+0.5*tics_length,p);\
5619
  ctx.lineTo(zero_x+0.5*tics_length,p);\
5620
 };\
5620
 };\
5621
 ctx.stroke();\
5621
 ctx.stroke();\
Line 5649... Line 5649...
5649
 {\
5649
 {\
5650
  skip = 1;cnt = px2x(zero_x);\
5650
  skip = 1;cnt = px2x(zero_x);\
5651
  prec = Math.log(precision)/(Math.log(10));\
5651
  prec = Math.log(precision)/(Math.log(10));\
5652
  var y_basis;if(f_y == 1){ y_basis = ysize }else{ y_basis = zero_y + 1.4*font_size;};\
5652
  var y_basis;if(f_y == 1){ y_basis = ysize }else{ y_basis = zero_y + 1.4*font_size;};\
5653
  for( var p = zero_x ; p < xsize ; p = p+xstep){\
5653
  for( var p = zero_x ; p < xsize ; p = p+xstep){\
5654
   if(skip == 0 ){\
5654
   if(skip == 0 ){\
5655
    disp_cnt = cnt.toFixed(prec);\
5655
    disp_cnt = cnt.toFixed(prec);\
5656
    corr = ctx.measureText(disp_cnt).width;\
5656
    corr = ctx.measureText(disp_cnt).width;\
5657
    skip = parseInt(1.2*corr/xstep);\
5657
    skip = parseInt(1.2*corr/xstep);\
5658
    ctx.fillText(disp_cnt,p-0.5*corr,y_basis);\
5658
    ctx.fillText(disp_cnt,p-0.5*corr,y_basis);\
5659
   }\
5659
   }\
5660
   else\
5660
   else\
Line 5832... Line 5832...
5832
 ctx.restore();\
5832
 ctx.restore();\
5833
};\
5833
};\
5834
return;\
5834
return;\
5835
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5835
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5836
    break;
5836
    break;
5837
   
5837
 
5838
    case DRAW_PIECHART:
5838
    case DRAW_PIECHART:
5839
fprintf(js_include_file,"\n<!-- draw piecharts -->\n\
5839
fprintf(js_include_file,"\n<!-- draw piecharts -->\n\
5840
function draw_piechart(canvas_type,x_center,y_center,radius, data_color_list,fill_opacity,legend_cnt,font_family){\
5840
function draw_piechart(canvas_type,x_center,y_center,radius, data_color_list,fill_opacity,legend_cnt,font_family){\
5841
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5841
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5842
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
5842
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
5843
 }\
5843
 }\
5844
 else\
5844
 else\
5845
 {\
5845
 {\
5846
  obj = create_canvas%d(canvas_type,xsize,ysize);\
5846
  obj = create_canvas%d(canvas_type,xsize,ysize);\
5847
 };\
5847
 };\
5848
 var ld = data_color_list.length;\
5848
 var ld = data_color_list.length;\
5849
 var sum = 0;\
5849
 var sum = 0;\
5850
 var idx = 0;\
5850
 var idx = 0;\
5851
 var font_size = parseInt(font_family.replace(/[^0-9\\.]+/g, \"\"));\
5851
 var font_size = parseInt(font_family.replace(/[^0-9\\.]+/g, \"\"));\
5852
 var colors = new Array();\
5852
 var colors = new Array();\
Line 5854... Line 5854...
5854
 for(var p = 0;p < ld; p = p + 2){\
5854
 for(var p = 0;p < ld; p = p + 2){\
5855
  data[idx] = parseFloat(data_color_list[p]);\
5855
  data[idx] = parseFloat(data_color_list[p]);\
5856
  sum = sum + data[idx];\
5856
  sum = sum + data[idx];\
5857
  colors[idx] = data_color_list[p+1];\
5857
  colors[idx] = data_color_list[p+1];\
5858
  idx++;\
5858
  idx++;\
5859
 };\
5859
 };\
5860
 var ctx = obj.getContext(\"2d\");\
5860
 var ctx = obj.getContext(\"2d\");\
5861
 ctx.save();\
5861
 ctx.save();\
5862
 var angle;\
5862
 var angle;\
5863
 var angle_end = 0;\
5863
 var angle_end = 0;\
5864
 var offset = Math.PI / 2;\
5864
 var offset = Math.PI / 2;\
Line 5890... Line 5890...
5890
   y_offset = parseInt(y_offset + 1.5*font_size);\
5890
   y_offset = parseInt(y_offset + 1.5*font_size);\
5891
  };\
5891
  };\
5892
 };\
5892
 };\
5893
 ctx.restore();\
5893
 ctx.restore();\
5894
};",canvas_root_id,canvas_root_id,canvas_root_id);
5894
};",canvas_root_id,canvas_root_id,canvas_root_id);
5895
   
5895
 
5896
    break;
5896
    break;
5897
    case DRAW_ARCS:
5897
    case DRAW_ARCS:
5898
fprintf(js_include_file,"\n<!-- draw arcs -->\n\
5898
fprintf(js_include_file,"\n<!-- draw arcs -->\n\
5899
var draw_arc = function(ctx,xc,yc,r,start,end,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_affine,affine_matrix){\
5899
var draw_arc = function(ctx,xc,yc,r,start,end,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_affine,affine_matrix){\
5900
 ctx.save();\
5900
 ctx.save();\
Line 5916... Line 5916...
5916
  ctx.fill();\
5916
  ctx.fill();\
5917
 };\
5917
 };\
5918
 ctx.stroke();\
5918
 ctx.stroke();\
5919
 ctx.restore();\
5919
 ctx.restore();\
5920
};");
5920
};");
5921
   
5921
 
5922
    break;
5922
    break;
5923
    case DRAW_CENTERSTRING:
5923
    case DRAW_CENTERSTRING:
5924
fprintf(js_include_file,"\n<!-- draw centerstring -->\n\
5924
fprintf(js_include_file,"\n<!-- draw centerstring -->\n\
5925
var draw_centerstring = function(canvas_type,y,font_family,stroke_color,stroke_opacity,text){\
5925
var draw_centerstring = function(canvas_type,y,font_family,stroke_color,stroke_opacity,text){\
5926
 var obj;\
5926
 var obj;\
Line 5971... Line 5971...
5971
   ctx.translate(x,y);\
5971
   ctx.translate(x,y);\
5972
   ctx.rotate((360-angle2)*(Math.PI / 180));\
5972
   ctx.rotate((360-angle2)*(Math.PI / 180));\
5973
   ctx.fillText(text,0,0);\
5973
   ctx.fillText(text,0,0);\
5974
   ctx.restore();\
5974
   ctx.restore();\
5975
  }else{ctx.fillText(text,x,y);};\
5975
  }else{ctx.fillText(text,x,y);};\
5976
 ctx.restore();\
5976
 ctx.restore();\
5977
 return;\
5977
 return;\
5978
 };",canvas_root_id,canvas_root_id,canvas_root_id);
5978
 };",canvas_root_id,canvas_root_id,canvas_root_id);
5979
    break;
5979
    break;
5980
    case DRAW_CURVE:
5980
    case DRAW_CURVE:
5981
fprintf(js_include_file,"\n<!-- draw curve -->\n\
5981
fprintf(js_include_file,"\n<!-- draw curve -->\n\
Line 6010... Line 6010...
6010
 };\
6010
 };\
6011
 ctx.stroke();\
6011
 ctx.stroke();\
6012
 ctx.restore();\
6012
 ctx.restore();\
6013
};",canvas_root_id,canvas_root_id,canvas_root_id);
6013
};",canvas_root_id,canvas_root_id,canvas_root_id);
6014
    break;
6014
    break;
6015
   
6015
 
6016
    case DRAW_INPUTS:
6016
    case DRAW_INPUTS:
6017
fprintf(js_include_file,"\n<!-- draw input fields -->\n\
6017
fprintf(js_include_file,"\n<!-- draw input fields -->\n\
6018
var draw_inputs = function(root_id,input_cnt,x,y,size,readonly,style,value){\
6018
var draw_inputs = function(root_id,input_cnt,x,y,size,readonly,style,value){\
6019
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
6019
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
6020
var input = document.createElement(\"input\");\
6020
var input = document.createElement(\"input\");\
Line 6023... Line 6023...
6023
input.setAttribute(\"size\",size);\
6023
input.setAttribute(\"size\",size);\
6024
input.setAttribute(\"value\",value);\
6024
input.setAttribute(\"value\",value);\
6025
if( readonly == 0 || wims_status == \"done\" ){ input.setAttribute(\"readonly\",\"readonly\");if( wims_status == \"done\" ){input.setAttribute(\"value\",\"\");};};\
6025
if( readonly == 0 || wims_status == \"done\" ){ input.setAttribute(\"readonly\",\"readonly\");if( wims_status == \"done\" ){input.setAttribute(\"value\",\"\");};};\
6026
canvas_div.appendChild(input);};");
6026
canvas_div.appendChild(input);};");
6027
    break;
6027
    break;
6028
   
6028
 
6029
    case DRAW_TEXTAREAS:
6029
    case DRAW_TEXTAREAS:
6030
fprintf(js_include_file,"\n<!-- draw text area inputfields -->\n\
6030
fprintf(js_include_file,"\n<!-- draw text area inputfields -->\n\
6031
var draw_textareas = function(root_id,input_cnt,x,y,cols,rows,readonly,style,value){\
6031
var draw_textareas = function(root_id,input_cnt,x,y,cols,rows,readonly,style,value){\
6032
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
6032
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
6033
var textarea = document.createElement(\"textarea\");\
6033
var textarea = document.createElement(\"textarea\");\
Line 6037... Line 6037...
6037
textarea.setAttribute(\"rows\",rows);\
6037
textarea.setAttribute(\"rows\",rows);\
6038
textarea.value = value;\
6038
textarea.value = value;\
6039
if( readonly == 0 || wims_status == \"done\" ){ textarea.setAttribute(\"readonly\",\"readonly\");if( wims_status == \"done\" ){textarea.value=\"\";};};\
6039
if( readonly == 0 || wims_status == \"done\" ){ textarea.setAttribute(\"readonly\",\"readonly\");if( wims_status == \"done\" ){textarea.value=\"\";};};\
6040
canvas_div.appendChild(textarea);};");
6040
canvas_div.appendChild(textarea);};");
6041
    break;
6041
    break;
6042
   
6042
 
6043
case DRAW_PIXELS:
6043
case DRAW_PIXELS:
6044
fprintf(js_include_file,"\n<!-- draw pixel -->\n\
6044
fprintf(js_include_file,"\n<!-- draw pixel -->\n\
6045
var draw_setpixel = function(x,y,color,opacity,pixelsize){\
6045
var draw_setpixel = function(x,y,color,opacity,pixelsize){\
6046
 var canvas = create_canvas%d(10,xsize,ysize);\
6046
 var canvas = create_canvas%d(10,xsize,ysize);\
6047
 var d = 0.5*pixelsize;\
6047
 var d = 0.5*pixelsize;\
Line 7137... Line 7137...
7137
        }
7137
        }
7138
        if( strcmp(input_type, fellipse) == 0){
7138
        if( strcmp(input_type, fellipse) == 0){
7139
        free(input_type);
7139
        free(input_type);
7140
        use_filled = TRUE;
7140
        use_filled = TRUE;
7141
        return ELLIPSE;
7141
        return ELLIPSE;
7142
        }      
7142
        }
7143
        if( strcmp(input_type, blink) == 0 ){
7143
        if( strcmp(input_type, blink) == 0 ){
7144
        free(input_type);
7144
        free(input_type);
7145
        return BLINK;
7145
        return BLINK;
7146
        }
7146
        }
7147
        if( strcmp(input_type, clearbutton) == 0){
7147
        if( strcmp(input_type, clearbutton) == 0){
7148
        free(input_type);
7148
        free(input_type);
7149
        return CLEARBUTTON;
7149
        return CLEARBUTTON;
7150
        }
7150
        }
7151
        if( strcmp(input_type, translation) == 0 ||  strcmp(input_type, translate) == 0  ){
7151
        if( strcmp(input_type, translation) == 0 ||  strcmp(input_type, translate) == 0  ){
7152
        free(input_type);
7152
        free(input_type);
7153
        return TRANSLATION;
7153
        return TRANSLATION;
7154
        }
7154
        }
7155
        if( strcmp(input_type, killtranslation) == 0 ||  strcmp(input_type, killtranslate) == 0){
7155
        if( strcmp(input_type, killtranslation) == 0 ||  strcmp(input_type, killtranslate) == 0){
7156
        free(input_type);
7156
        free(input_type);
7157
        return KILLTRANSLATION;
7157
        return KILLTRANSLATION;
7158
        }
7158
        }
7159
        if( strcmp(input_type, rotate) == 0){
7159
        if( strcmp(input_type, rotate) == 0){
7160
        free(input_type);
7160
        free(input_type);
7161
        return ROTATE;
7161
        return ROTATE;
7162
        }
7162
        }
7163
        if( strcmp(input_type, affine) == 0){
7163
        if( strcmp(input_type, affine) == 0){
7164
        free(input_type);
7164
        free(input_type);
7165
        return AFFINE;
7165
        return AFFINE;
7166
        }
7166
        }
7167
        if( strcmp(input_type, killaffine) == 0){
7167
        if( strcmp(input_type, killaffine) == 0){
7168
        free(input_type);
7168
        free(input_type);
7169
        return KILLAFFINE;
7169
        return KILLAFFINE;
7170
        }
7170
        }
7171
        if( strcmp(input_type, audio) == 0 ){
7171
        if( strcmp(input_type, audio) == 0 ){
7172
        free(input_type);
7172
        free(input_type);
7173
        return AUDIO;
7173
        return AUDIO;
7174
        }
7174
        }
7175
        if( strcmp(input_type, audioobject) == 0 ){
7175
        if( strcmp(input_type, audioobject) == 0 ){
7176
        free(input_type);
7176
        free(input_type);
7177
        return AUDIOOBJECT;
7177
        return AUDIOOBJECT;
7178
        }
7178
        }
7179
        if( strcmp(input_type, slider) == 0 ){
7179
        if( strcmp(input_type, slider) == 0 ){
Line 7231... Line 7231...
7231
        if( strcmp(input_type, ylogscale) == 0 ){
7231
        if( strcmp(input_type, ylogscale) == 0 ){
7232
        free(input_type);
7232
        free(input_type);
7233
        return YLOGSCALE;
7233
        return YLOGSCALE;
7234
        }
7234
        }
7235
        if( strcmp(input_type, xylogscale) == 0 ){
7235
        if( strcmp(input_type, xylogscale) == 0 ){
7236
        free(input_type);
7236
        free(input_type);
7237
        return XYLOGSCALE;
7237
        return XYLOGSCALE;
7238
        }
7238
        }
7239
        if( strcmp(input_type, ylogscale) == 0 ){
7239
        if( strcmp(input_type, ylogscale) == 0 ){
7240
        free(input_type);
7240
        free(input_type);
7241
        return YLOGSCALE;
7241
        return YLOGSCALE;
7242
        }
7242
        }
7243
        if( strcmp(input_type, xlogbase) == 0 ){
7243
        if( strcmp(input_type, xlogbase) == 0 ){
7244
        free(input_type);
7244
        free(input_type);
7245
        return XLOGBASE;
7245
        return XLOGBASE;
7246
        }
7246
        }
7247
        if( strcmp(input_type, ylogbase) == 0 ){
7247
        if( strcmp(input_type, ylogbase) == 0 ){
7248
        free(input_type);
7248
        free(input_type);
7249
        return YLOGBASE;
7249
        return YLOGBASE;
7250
        }
7250
        }
7251
        if( strcmp(input_type, intooltip) == 0 ){
7251
        if( strcmp(input_type, intooltip) == 0 ){
7252
        free(input_type);
7252
        free(input_type);
7253
        return INTOOLTIP;
7253
        return INTOOLTIP;
7254
        }
7254
        }
7255
        if( strcmp(input_type,video) == 0 ){
7255
        if( strcmp(input_type,video) == 0 ){
7256
        free(input_type);
7256
        free(input_type);
7257
        return VIDEO;
7257
        return VIDEO;
7258
        }
7258
        }
7259
        if( strcmp(input_type,floodfill) == 0 || strcmp(input_type,fill) == 0 ){
7259
        if( strcmp(input_type,floodfill) == 0 || strcmp(input_type,fill) == 0 ){
7260
        free(input_type);
7260
        free(input_type);
7261
        return FLOODFILL;
7261
        return FLOODFILL;
7262
        }      
7262
        }
7263
        if( strcmp(input_type,filltoborder) == 0 ){
7263
        if( strcmp(input_type,filltoborder) == 0 ){
7264
        free(input_type);
7264
        free(input_type);
7265
        return FILLTOBORDER;
7265
        return FILLTOBORDER;
7266
        }      
7266
        }
7267
        if( strcmp(input_type,clickfill) == 0 ){
7267
        if( strcmp(input_type,clickfill) == 0 ){
7268
        free(input_type);
7268
        free(input_type);
7269
        return CLICKFILL;
7269
        return CLICKFILL;
7270
        }      
7270
        }
7271
        if( strcmp(input_type, replyformat) == 0 ){
7271
        if( strcmp(input_type, replyformat) == 0 ){
7272
        free(input_type);
7272
        free(input_type);
7273
        return REPLYFORMAT;
7273
        return REPLYFORMAT;
7274
        }
7274
        }
7275
        if( strcmp(input_type, pixelsize) == 0 ){
7275
        if( strcmp(input_type, pixelsize) == 0 ){