Subversion Repositories wimsdev

Rev

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

Rev 7848 Rev 7856
Line 7... Line 7...
7
* This source code file, and compiled objects derived from it,                  *
7
* This source code file, and compiled objects derived from it,                  *
8
* can be used and distributed without restriction, including for commercial use *
8
* can be used and distributed without restriction, including for commercial use *
9
* No warrenty whatsoever                                                        *
9
* No warrenty whatsoever                                                        *
10
*********************************************************************************
10
*********************************************************************************
11
*/
11
*/
-
 
12
 
12
#include "../../Lib/libwims.h"
13
#include "../../Lib/libwims.h"
13
#include "canvasdraw.h"
14
#include "canvasdraw.h"
14
#include <assert.h>
15
#include <assert.h>
15
#include "canvasmacro.c"
16
#include "canvasmacro.c"
16
 
17
 
Line 34... Line 35...
34
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 */
35
char    *convert_hex2rgb(char *hexcolor);
36
char    *convert_hex2rgb(char *hexcolor);
36
void    add_read_canvas(int reply_format);
37
void    add_read_canvas(int reply_format);
37
void    make_js_include(int canvas_root_id);
38
void    make_js_include(int canvas_root_id);
38
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 */
39
FILE    *js_include_file;
40
FILE    *js_include_file;
40
FILE    *get_file(int *line_number, char **filename);
41
FILE    *get_file(int *line_number, char **filename);
41
FILE    *infile;    /* will be stdin */
42
FILE    *infile;    /* will be stdin */
42
/******************************************************************************
43
/******************************************************************************
43
** global
44
** global
44
******************************************************************************/
45
******************************************************************************/
Line 52... Line 53...
52
double ymin = 0.0;
53
double ymin = 0.0;
53
double ymax = 320.0;
54
double ymax = 320.0;
54
double tmax = 2;
55
double tmax = 2;
55
double tmin = -2;
56
double tmin = -2;
56
/* flag to indicate parsing of line status */
57
/* flag to indicate parsing of line status */
57
int done = FALSE;
58
int done = FALSE;
58
int type; /* eg command number */
59
int type; /* eg command number */
59
int onclick = 0;/* 0 = noninteractive ; 1 = onclick ; 2 = draggable*/
60
int onclick = 0;/* 0 = noninteractive ; 1 = onclick ; 2 = draggable*/
60
int use_affine = FALSE;
61
int use_affine = FALSE;
61
int use_rotate = FALSE;
62
int use_rotate = FALSE;
62
int use_translate = FALSE;
63
int use_translate = FALSE;
Line 105... Line 106...
105
    int dashtype[2] = { 2 , 2 };
106
    int dashtype[2] = { 2 , 2 };
106
    int js_function[MAX_JS_FUNCTIONS]; /* javascript functions include objects on demand basis : only once per object type */
107
    int js_function[MAX_JS_FUNCTIONS]; /* javascript functions include objects on demand basis : only once per object type */
107
    for(i=0;i<MAX_JS_FUNCTIONS;i++){js_function[i]=0;}
108
    for(i=0;i<MAX_JS_FUNCTIONS;i++){js_function[i]=0;}
108
    int arrow_head = 8; /* size in px*/
109
    int arrow_head = 8; /* size in px*/
109
    int crosshair_size = 5; /* size in px*/
110
    int crosshair_size = 5; /* size in px*/
110
    int plot_steps = 250;
111
    int plot_steps = 250;
111
    int found_size_command = 0;
112
    int found_size_command = 0;
112
    int click_cnt = 1;
113
    int click_cnt = 1;
113
    int clock_cnt = 0; /* counts the amount of clocks used -> unique object clock%d */
114
    int clock_cnt = 0; /* counts the amount of clocks used -> unique object clock%d */
114
    int linegraph_cnt = 0; /* identifier for command 'linegraph' ; multiple line graphs may be plotted in a single plot*/
115
    int linegraph_cnt = 0; /* identifier for command 'linegraph' ; multiple line graphs may be plotted in a single plot*/
115
    double angle = 0.0;
116
    double angle = 0.0;
Line 122... Line 123...
122
    double stroke_opacity = 0.8;
123
    double stroke_opacity = 0.8;
123
    double fill_opacity = 0.8;
124
    double fill_opacity = 0.8;
124
    char *URL = "http://localhost/images";
125
    char *URL = "http://localhost/images";
125
    memset(buffer,'\0',MAX_BUFFER);
126
    memset(buffer,'\0',MAX_BUFFER);
126
    void *tmp_buffer = "";
127
    void *tmp_buffer = "";
127
 
128
   
128
    /* default writing a unzipped js-include file into wims getfile directory */
129
    /* default writing a unzipped js-include file into wims getfile directory */
129
    char *w_wims_session = getenv("w_wims_session");
130
    char *w_wims_session = getenv("w_wims_session");
130
    if(  w_wims_session == NULL || *w_wims_session == 0 ){
131
    if(  w_wims_session == NULL || *w_wims_session == 0 ){
131
        canvas_error("Hmmm, your wims environment does not exist...\nCanvasdraw should be used within wims.");
132
        canvas_error("Hmmm, your wims environment does not exist...\nCanvasdraw should be used within wims.");
132
    }
133
    }
133
    int L0=strlen(w_wims_session) + 21;
134
    int L0=strlen(w_wims_session) + 21;
134
    char *getfile_dir = my_newmem(L0); /* create memory to fit string precisely */
135
    char *getfile_dir = my_newmem(L0); /* create memory to fit string precisely */
135
    snprintf(getfile_dir,L0, "../sessions/%s/getfile",w_wims_session);/* string will fit precisely  */
136
    snprintf(getfile_dir,L0, "../sessions/%s/getfile",w_wims_session);/* string will fit precisely  */
136
    mode_t process_mask = umask(0); /* check if file exists */
137
    mode_t process_mask = umask(0); /* check if file exists */
137
    int result = mkdir(getfile_dir, S_IRWXU | S_IRWXG | S_IRWXO);
138
    int result = mkdir(getfile_dir, S_IRWXU | S_IRWXG | S_IRWXO);
138
    if( result == 0 || errno == EEXIST ){
139
    if( result == 0 || errno == EEXIST ){
139
     umask(process_mask); /* be sure to set correct permission */
140
     umask(process_mask); /* be sure to set correct permission */
140
     char *w_session = getenv("w_session");
141
     char *w_session = getenv("w_session");
141
     int L1 = (int) (strlen(w_session)) + find_number_of_digits(canvas_root_id) + 48;
142
     int L1 = (int) (strlen(w_session)) + find_number_of_digits(canvas_root_id) + 48;
142
    char *getfile_cmd = my_newmem(L1); /* create memory to fit string precisely */
143
    char *getfile_cmd = my_newmem(L1); /* create memory to fit string precisely */
143
     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 */
144
     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 */   
144
    /* write the include tag to html page:<script type="text/javascript" src="wims.cgi?session=%s&cmd=getfile&special_parm=11223344_js"></script> */
145
    /* write the include tag to html page:<script type="text/javascript" src="wims.cgi?session=%s&cmd=getfile&special_parm=11223344_js"></script> */
145
    /* now write file into getfile dir*/
146
    /* now write file into getfile dir*/
146
    char *w_wims_home = getenv("w_wims_home"); /* "/home/users/wims" : we need absolute path for location */
147
    char *w_wims_home = getenv("w_wims_home"); /* "/home/users/wims" : we need absolute path for location */
147
    int L2 = (int) (strlen(w_wims_home)) + (int) (strlen(w_wims_session)) + find_number_of_digits(canvas_root_id) + 23;
148
    int L2 = (int) (strlen(w_wims_home)) + (int) (strlen(w_wims_session)) + find_number_of_digits(canvas_root_id) + 23;
148
    char *location = my_newmem(L2); /* create memory to fit string precisely */
149
    char *location = my_newmem(L2); /* create memory to fit string precisely */
Line 158... Line 159...
158
        if(line_number>1 && found_size_command == FALSE){canvas_error("command \"size xsize,ysize\" needs to come first ! ");}
159
        if(line_number>1 && found_size_command == FALSE){canvas_error("command \"size xsize,ysize\" needs to come first ! ");}
159
        type = get_token(infile);
160
        type = get_token(infile);
160
        done = FALSE;
161
        done = FALSE;
161
        /*
162
        /*
162
        @canvasdraw
163
        @canvasdraw
163
        @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...)
164
        @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...)
164
        @General syntax <ul><li>The transparency of all objects can be controlled by command 'opacity [0-255],[0,255]'</il><li>a line based object can be controlled by command 'linewidth int'</li><li>a line based object may be dashed by using keyword 'dashed' before the object command.<br />the dashing type can be controled by command 'dashtype int,int'</li><li>a fillable object can be set fillable by starting the object command with an 'f'<br />(like frect,fcircle,ftriangle...)<br />or by using the keyword 'filled' before the object command.<br />The fill colour will be the stroke colour...(19/10/2013)<li> a draggable object can be set draggable by a preceding command 'drag x/y/xy'<br />The translation can be read by javascript:read_dragdrop();<br />Multiple objects may be set draggable / clickable (no limit)<br /> not all flydraw objects may be dragged / clicked<br />Only draggable / clickable objects will be scaled on zoom and will be translated in case of panning</li><li> a 'onclick object' can be set 'clickable' by the preceding keyword 'onclick'<br />not all flydraw objects can be set clickable</li><li><b>remarks using a ';' as command separator</b><br />commands with only numeric or colour arguments may be using a ';' as command separator (in stead of a new line)<br />commands with a string argument may not use a ';' as command separator !<br />these exceptions are not really straight forward... so keep this in mind.<br />example:<br />size 200,200;xrange -5,5;yrange -5,5;hline 0,0,black;vline 0,0,black<br />plot red,sin(x)<br />drag xy<br />html 0,0,5,-5, &amp;euro; <br />lines green,2,0,2,-2,-2,2,-2,0;rectangle 1,1,4,4,purple;frectangle -1,-1,-4,-4,yellow</li></ul>
165
        @General syntax <ul><li>The transparency of all objects can be controlled by command 'opacity [0-255],[0,255]'</il><li>a line based object can be controlled by command 'linewidth int'</li><li>a line based object may be dashed by using keyword 'dashed' before the object command.<br />the dashing type can be controled by command 'dashtype int,int'</li><li>a fillable object can be set fillable by starting the object command with an 'f'<br />(like frect,fcircle,ftriangle...)<br />or by using the keyword 'filled' before the object command.<br />The fill colour will be the stroke colour...(19/10/2013)<li> a draggable object can be set draggable by a preceding command 'drag x/y/xy'<br />The translation can be read by javascript:read_dragdrop();<br />Multiple objects may be set draggable / clickable (no limit)<br /> not all flydraw objects may be dragged / clicked<br />Only draggable / clickable objects will be scaled on zoom and will be translated in case of panning</li><li> a 'onclick object' can be set 'clickable' by the preceding keyword 'onclick'<br />not all flydraw objects can be set clickable</li><li><b>remarks using a ';' as command separator</b><br />commands with only numeric or colour arguments may be using a ';' as command separator (in stead of a new line)<br />commands with a string argument may not use a ';' as command separator !<br />these exceptions are not really straight forward... so keep this in mind.<br />example:<br />size 200,200;xrange -5,5;yrange -5,5;hline 0,0,black;vline 0,0,black<br />plot red,sin(x)<br />drag xy<br />html 0,0,5,-5, &amp;euro; <br />lines green,2,0,2,-2,-2,2,-2,0;rectangle 1,1,4,4,purple;frectangle -1,-1,-4,-4,yellow</li></ul>
165
        */
166
        */
166
        switch(type){
167
        switch(type){
167
        case END:
168
        case END:
168
        finished = 1;
169
        finished = 1;
Line 189... Line 190...
189
            ysize = (int)(abs(round(get_real(infile,1))));
190
            ysize = (int)(abs(round(get_real(infile,1))));
190
            /* sometimes we want xrange / yrange to be in pixels...without telling x/y-range */
191
            /* sometimes we want xrange / yrange to be in pixels...without telling x/y-range */
191
            xmin = 0;xmax = xsize;
192
            xmin = 0;xmax = xsize;
192
            ymin = 0;ymax = ysize;
193
            ymin = 0;ymax = ysize;
193
 
194
 
194
/*
195
/*
195
 The sequence in which stuff is finally printed is important !!
196
 The sequence in which stuff is finally printed is important !!
196
 for example, when writing a 'include.js" the may not be a "script tag <script>" etc etc
197
 for example, when writing a 'include.js" the may not be a "script tag <script>" etc etc
197
*/
198
*/
198
fprintf(stdout,"\n<script type=\"text/javascript\">var wims_status = \"$status\";</script>\n<!-- canvasdraw div and tooltip placeholder, if needed -->\n<div tabindex=\"0\" id=\"canvas_div%d\" style=\"position:relative;width:%dpx;height:%dpx;\" ></div><div id=\"tooltip_placeholder_div%d\" style=\"display:block\"><span id=\"tooltip_placeholder%d\" style=\"display:none\"></span></div>\n",canvas_root_id,xsize,ysize,canvas_root_id,canvas_root_id);
199
fprintf(stdout,"\n<script type=\"text/javascript\">var wims_status = \"$status\";</script>\n<!-- canvasdraw div and tooltip placeholder, if needed -->\n<div tabindex=\"0\" id=\"canvas_div%d\" style=\"position:relative;width:%dpx;height:%dpx;\" ></div><div id=\"tooltip_placeholder_div%d\" style=\"display:block\"><span id=\"tooltip_placeholder%d\" style=\"display:none\"></span></div>\n",canvas_root_id,xsize,ysize,canvas_root_id,canvas_root_id);
199
fprintf(js_include_file,"\n<!-- begin generated javascript include for canvasdraw -->\n");
200
fprintf(js_include_file,"\n<!-- begin generated javascript include for canvasdraw -->\n");
Line 229... Line 230...
229
add_drag_code(js_include_file,DRAG_CANVAS,canvas_root_id);
230
add_drag_code(js_include_file,DRAG_CANVAS,canvas_root_id);
230
            break;
231
            break;
231
        case XRANGE:
232
        case XRANGE:
232
        /*
233
        /*
233
        @ xrange xmin,xmax
234
        @ xrange xmin,xmax
234
        @ if not given: 0,xsize (eg in pixels)
235
        @ if not given: 0,xsize (eg in pixels)
235
        */
236
        */
236
            for(i = 0 ; i<2; i++){
237
            for(i = 0 ; i<2; i++){
237
                switch(i){
238
                switch(i){
238
                    case 0: xmin = get_real(infile,0);break;
239
                    case 0: xmin = get_real(infile,0);break;
239
                    case 1: xmax = get_real(infile,1);break;
240
                    case 1: xmax = get_real(infile,1);break;
Line 346... Line 347...
346
        /*
347
        /*
347
        @ point x,y,color
348
        @ point x,y,color
348
        @ draw a single point at (x;y) in color 'color'
349
        @ draw a single point at (x;y) in color 'color'
349
        @ use command 'linewidth int'  to adust size
350
        @ use command 'linewidth int'  to adust size
350
        @ may be set draggable / onclick
351
        @ may be set draggable / onclick
351
        @ will not resize on zooming <br />(command 'circle x,y,r,color' will resize on zooming)
352
        @ will not resize on zooming <br />(command 'circle x,y,r,color' will resize on zooming)
352
        */
353
        */
353
            for(i=0;i<3;i++){
354
            for(i=0;i<3;i++){
354
                switch(i){
355
                switch(i){
355
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
356
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
356
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
357
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
Line 382... Line 383...
382
                {
383
                {
383
                    double_data[i] = get_real(infile,1); /* y */
384
                    double_data[i] = get_real(infile,1); /* y */
384
                }
385
                }
385
                i++;
386
                i++;
386
            }
387
            }
387
            decimals = find_number_of_digits(precision);
388
            decimals = find_number_of_digits(precision);           
388
            for(c = 0 ; c < i-1 ; c = c+2){
389
            for(c = 0 ; c < i-1 ; c = c+2){
389
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,2,[%.*f],[%.*f],[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+1],line_width,line_width,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,1,0,0,0,use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
390
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,2,[%.*f],[%.*f],[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+1],line_width,line_width,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,1,0,0,0,use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
390
                click_cnt++;
391
                click_cnt++;
391
            }
392
            }
392
            reset();
393
            reset();
Line 396... Line 397...
396
        @ segment x1,y1,x2,y2,color
397
        @ segment x1,y1,x2,y2,color
397
        @ draw a line segment between points (x1:y1)--(x2:y2) in color 'color'
398
        @ draw a line segment between points (x1:y1)--(x2:y2) in color 'color'
398
        @ may be set draggable / onclick
399
        @ may be set draggable / onclick
399
        */
400
        */
400
            for(i=0;i<5;i++) {
401
            for(i=0;i<5;i++) {
401
                switch(i){
402
                switch(i){
402
                    case 0: double_data[0]= get_real(infile,0);break; /* x1-values */
403
                    case 0: double_data[0]= get_real(infile,0);break; /* x1-values */
403
                    case 1: double_data[1]= get_real(infile,0);break; /* y1-values */
404
                    case 1: double_data[1]= get_real(infile,0);break; /* y1-values */
404
                    case 2: double_data[2]= get_real(infile,0);break; /* x2-values */
405
                    case 2: double_data[2]= get_real(infile,0);break; /* x2-values */
405
                    case 3: double_data[3]= get_real(infile,0);break; /* y2-values */
406
                    case 3: double_data[3]= get_real(infile,0);break; /* y2-values */
406
                    case 4: stroke_color=get_color(infile,1);/* name or hex color */
407
                    case 4: stroke_color=get_color(infile,1);/* name or hex color */
407
                        decimals = find_number_of_digits(precision);
408
                        decimals = find_number_of_digits(precision);
408
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],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);
409
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],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);
409
                        click_cnt++;reset();
410
                        click_cnt++;reset();
410
                        break;
411
                        break;
411
                    default: break;
412
                    default: break;
412
                }
413
                }
413
            }
414
            }
414
            break;
415
            break;
415
        case LINE:
416
        case LINE:
416
        /*
417
        /*
417
        @ line x1,y1,x2,y2,color
418
        @ line x1,y1,x2,y2,color
418
        @ draw a line through points (x1:y1)--(x2:y2) in color 'color'
419
        @ draw a line through points (x1:y1)--(x2:y2) in color 'color'
Line 444... Line 445...
444
                        {
445
                        {
445
                        /* m */
446
                        /* m */
446
                        double_data[5] = (double_data[13] - double_data[11]) /(double_data[12] - double_data[10]);
447
                        double_data[5] = (double_data[13] - double_data[11]) /(double_data[12] - double_data[10]);
447
                        /* q */
448
                        /* q */
448
                        double_data[6] = double_data[11] - ((double_data[13] - double_data[11]) /(double_data[12] - double_data[10]))*double_data[10];
449
                        double_data[6] = double_data[11] - ((double_data[13] - double_data[11]) /(double_data[12] - double_data[10]))*double_data[10];
449
 
450
                       
450
                        /*xmin,m*xmin+q,xmax,m*xmax+q*/
451
                        /*xmin,m*xmin+q,xmax,m*xmax+q*/
451
 
452
                       
452
                            double_data[1] = (double_data[5])*(xmin)+(double_data[6]);
453
                            double_data[1] = (double_data[5])*(xmin)+(double_data[6]);
453
                            double_data[3] = (double_data[5])*(xmax)+(double_data[6]);
454
                            double_data[3] = (double_data[5])*(xmax)+(double_data[6]);
454
                            double_data[0] = xmin;
455
                            double_data[0] = xmin;
455
                            double_data[2] = xmax;
456
                            double_data[2] = xmax;
456
                        }
457
                        }
457
                    }
458
                    }
458
                    decimals = find_number_of_digits(precision);
459
                    decimals = find_number_of_digits(precision);
459
                    fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],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);
460
                    fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],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);
460
                    click_cnt++;reset();
461
                    click_cnt++;reset();
461
                    break;
462
                    break;
462
                }
463
                }
463
            }
464
            }
464
            break;
465
            break;
465
        case HLINE:
466
        case HLINE:
466
        /*
467
        /*
467
        @ hline x,y,color
468
        @ hline x,y,color
468
        @ draw a horizontal line through point (x:y) in color 'color'
469
        @ draw a horizontal line through point (x:y) in color 'color'
469
        @ or use command 'curve color,formula' to draw the line <br />(uses more points to draw the line; is however better draggable)
470
        @ or use command 'curve color,formula' to draw the line <br />(uses more points to draw the line; is however better draggable)
470
        @ may be set draggable / onclick
471
        @ may be set draggable / onclick
Line 494... Line 495...
494
                    case 1: double_data[1] = get_real(infile,0);break; /* y-values */
495
                    case 1: double_data[1] = get_real(infile,0);break; /* y-values */
495
                    case 2: stroke_color=get_color(infile,1);/* name or hex color */
496
                    case 2: stroke_color=get_color(infile,1);/* name or hex color */
496
                        double_data[2] = double_data[0];
497
                        double_data[2] = double_data[0];
497
                        decimals = find_number_of_digits(precision);
498
                        decimals = find_number_of_digits(precision);
498
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,ymin,decimals,ymax,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);
499
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,ymin,decimals,ymax,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);
499
                        click_cnt++;reset();
500
                        click_cnt++;reset();
500
                    break;
501
                    break;
501
                }
502
                }
502
            }
503
            }
503
            break;
504
            break;
504
        case SQUARE:
505
        case SQUARE:
Line 518... Line 519...
518
                           double_data[3] = double_data[2];
519
                           double_data[3] = double_data[2];
519
                           break; /* x-values */
520
                           break; /* x-values */
520
                    case 3:stroke_color = get_color(infile,1);/* name or hex color */
521
                    case 3:stroke_color = get_color(infile,1);/* name or hex color */
521
                        decimals = find_number_of_digits(precision);
522
                        decimals = find_number_of_digits(precision);
522
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,1,[%.*f,%.*f],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
523
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,1,[%.*f,%.*f],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
523
                        click_cnt++;reset();
524
                        click_cnt++;reset();
524
                        break;
525
                        break;
525
                }
526
                }
526
            }
527
            }
527
            break;
528
            break;
528
        case ROUNDRECT:
529
        case ROUNDRECT:
529
        /*
530
        /*
530
        @ roundrect x1,y1,x2,y2,radius,color
531
        @ roundrect x1,y1,x2,y2,radius,color
531
        @ use command 'froundrect x1,y1,x2,y2,radius,color' for a filled rectangle
532
        @ use command 'froundrect x1,y1,x2,y2,radius,color' for a filled rectangle
532
        @ use command/keyword  'filled' before command 'roundrect x1,y1,x2,y2,radius,color'
533
        @ use command/keyword  'filled' before command 'roundrect x1,y1,x2,y2,radius,color'
533
        @ use command 'fillcolor color' before 'froundrect' to set the fill colour.
534
        @ use command 'fillcolor color' before 'froundrect' to set the fill colour.
534
        @ may be set draggable / onclick
535
        @ may be set draggable / onclick
535
        */
536
        */
536
            for(i=0;i<6;i++){
537
            for(i=0;i<6;i++){
537
                switch(i){
538
                switch(i){
538
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
539
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
539
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
540
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
540
                    case 2:double_data[2] = get_real(infile,0);break; /* x-values */
541
                    case 2:double_data[2] = get_real(infile,0);break; /* x-values */
541
                    case 3:double_data[3] = get_real(infile,0);break; /* y-values */
542
                    case 3:double_data[3] = get_real(infile,0);break; /* y-values */
542
                    case 4:int_data[0] = (int) (get_real(infile,0));break; /* radius value in pixels */
543
                    case 4:int_data[0] = (int) (get_real(infile,0));break; /* radius value in pixels */
Line 571... Line 572...
571
            }
572
            }
572
            break;
573
            break;
573
        case POLYLINE:
574
        case POLYLINE:
574
        /*
575
        /*
575
        @ polyline color,x1,y1,x2,y2...x_n,y_n
576
        @ polyline color,x1,y1,x2,y2...x_n,y_n
576
        @ may be set draggable / onclick
577
        @ may be set draggable / onclick
577
        */
578
        */
578
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
579
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
579
            i=0;
580
            i=0;
580
            c=0;
581
            c=0;
581
            while( ! done ){     /* get next item until EOL*/
582
            while( ! done ){     /* get next item until EOL*/
582
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
583
                if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");}
583
                for( c = 0 ; c < 2; c++){
584
                for( c = 0 ; c < 2; c++){
584
                    if(c == 0 ){
585
                    if(c == 0 ){
585
                        double_data[i] = get_real(infile,0);
586
                        double_data[i] = get_real(infile,0);
586
                        i++;
587
                        i++;
587
                    }
588
                    }
588
                    else
589
                    else
589
                    {
590
                    {
590
                        double_data[i] = get_real(infile,1);
591
                        double_data[i] = get_real(infile,1);
591
                        i++;
592
                        i++;
592
                    }
593
                    }
593
                }
594
                }
594
            }
595
            }
595
            /* draw path : not closed & not filled */
596
            /* draw path : not closed & not filled */
596
            decimals = find_number_of_digits(precision);
597
            decimals = find_number_of_digits(precision);
597
            fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,%s,[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
598
            fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,%s,[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
598
            click_cnt++;reset();
599
            click_cnt++;reset();
Line 624... Line 625...
624
            /* draw path :  closed & optional filled */
625
            /* draw path :  closed & optional filled */
625
                decimals = find_number_of_digits(precision);
626
                decimals = find_number_of_digits(precision);
626
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,5,%s,[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
627
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,5,%s,[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,double_xy2js_array(double_data,i,decimals),line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
627
                click_cnt++;reset();
628
                click_cnt++;reset();
628
            break;
629
            break;
629
        case ARC:
630
        case ARC:
630
        /*
631
        /*
631
         @ arc xc,yc,width,height,start_angle,end_angle,color
632
         @ arc xc,yc,width,height,start_angle,end_angle,color
632
         @ can not be set "onclick" or "drag xy"
633
         @ can not be set "onclick" or "drag xy"
633
         @ attention: width == height == radius in pixels)
634
         @ attention: width == height == radius in pixels)
634
        */
635
        */
Line 642... Line 643...
642
                    case 5:double_data[3] = get_real(infile,0);break; /* end angle in degrees */
643
                    case 5:double_data[3] = get_real(infile,0);break; /* end angle in degrees */
643
                    case 6:stroke_color = get_color(infile,1);/* name or hex color */
644
                    case 6:stroke_color = get_color(infile,1);/* name or hex color */
644
                    /* in Shape library:
645
                    /* in Shape library:
645
                        x[0] = x[1] = xc
646
                        x[0] = x[1] = xc
646
                        y[0] = y[1] = yc
647
                        y[0] = y[1] = yc
647
                        w[0] = w[1] = radius = width = height
648
                        w[0] = w[1] = radius = width = height  
648
                        h[0] = start_angle ; h[1] = end_engle
649
                        h[0] = start_angle ; h[1] = end_engle
649
                    */
650
                    */
650
                        decimals = find_number_of_digits(precision);
651
                        decimals = find_number_of_digits(precision);
651
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,12,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[0],decimals,double_data[1],decimals,double_data[1],int_data[0],int_data[0],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
652
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,12,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%.*f,%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[0],decimals,double_data[1],decimals,double_data[1],int_data[0],int_data[0],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
652
                        reset();
653
                        reset();
653
                    break;
654
                    break;
Line 655... Line 656...
655
            }
656
            }
656
            break;
657
            break;
657
        case ELLIPSE:
658
        case ELLIPSE:
658
        /*
659
        /*
659
        @ ellipse xc,yc,radius_x,radius_y,color
660
        @ ellipse xc,yc,radius_x,radius_y,color
660
        @ a ellipse with center xc/yc in x/y-range
661
        @ a ellipse with center xc/yc in x/y-range
661
        @ radius_x and radius_y are in pixels
662
        @ radius_x and radius_y are in pixels
662
        @ may be set draggable / onclick
663
        @ may be set draggable / onclick
663
        @ will shrink / expand on zoom out / zoom in
664
        @ will shrink / expand on zoom out / zoom in
664
        */
665
        */
665
            for(i=0;i<5;i++){
666
            for(i=0;i<5;i++){
666
                switch(i){
667
                switch(i){
667
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
668
                    case 0:double_data[0] = get_real(infile,0);break; /* x-values */
668
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
669
                    case 1:double_data[1] = get_real(infile,0);break; /* y-values */
669
                    case 2:double_data[2] = get_real(infile,0);break; /* rx -> px  */
670
                    case 2:double_data[2] = get_real(infile,0);break; /* rx -> px  */
670
                    case 3:double_data[3] = get_real(infile,0);break; /* ry -> px  */
671
                    case 3:double_data[3] = get_real(infile,0);break; /* ry -> px  */
671
                    case 4:stroke_color = get_color(infile,1);/* name or hex color */
672
                    case 4:stroke_color = get_color(infile,1);/* name or hex color */
672
                        decimals = find_number_of_digits(precision);
673
                        decimals = find_number_of_digits(precision);
673
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,3,[%.*f],[%.*f],[%.*f],[%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
674
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,3,[%.*f],[%.*f],[%.*f],[%.*f],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],decimals,double_data[2],decimals,double_data[3],line_width,stroke_color,stroke_opacity,stroke_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
674
                        click_cnt++;reset();
675
                        click_cnt++;reset();
675
                    break;
676
                    break;
Line 693... Line 694...
693
        /*
694
        /*
694
        @ circle xc,yc,width (2*r in pixels),color
695
        @ circle xc,yc,width (2*r in pixels),color
695
        @ use command 'fcircle xc,yc,d,color' or command 'filled' for a filled disk
696
        @ use command 'fcircle xc,yc,d,color' or command 'filled' for a filled disk
696
        @ use command 'fillcolor color' to set the fillcolor
697
        @ use command 'fillcolor color' to set the fillcolor
697
        @ may be set draggable / onclick
698
        @ may be set draggable / onclick
698
        @ will shrink / expand on zoom out / zoom in
699
        @ will shrink / expand on zoom out / zoom in
699
        */
700
        */
700
            for(i=0;i<4;i++){
701
            for(i=0;i<4;i++){
701
                switch(i){
702
                switch(i){
702
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
703
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
703
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
704
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
Line 731... Line 732...
731
                    double_data[i] = get_real(infile,1); /* y */
732
                    double_data[i] = get_real(infile,1); /* y */
732
                }
733
                }
733
            fprintf(js_include_file,"/* double_data[%d] = %f */\n",i,double_data[i]);
734
            fprintf(js_include_file,"/* double_data[%d] = %f */\n",i,double_data[i]);
734
                i++;
735
                i++;
735
            }
736
            }
736
 
737
           
737
            if( i%2 != 0 ){canvas_error("in command rays: unpaired x or y value");}
738
            if( i%2 != 0 ){canvas_error("in command rays: unpaired x or y value");}
738
            decimals = find_number_of_digits(precision);
739
            decimals = find_number_of_digits(precision);           
739
            for(c=2; c<i;c = c+2){
740
            for(c=2; c<i;c = c+2){
740
                click_cnt++;
741
                click_cnt++;
741
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[c],decimals,double_data[1],decimals,double_data[c+1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
742
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[c],decimals,double_data[1],decimals,double_data[c+1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
742
            }
743
            }
743
            reset();
744
            reset();
744
            break;
745
            break;
745
        case ARROW:
746
        case ARROW:
746
        /*
747
        /*
747
        @ arrow x1,y1,x2,y2,h,color
748
        @ arrow x1,y1,x2,y2,h,color
748
        @ draw a single headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and in color 'color'
749
        @ draw a single headed arrow/vector from (x1:y1) to (x2:y2)<br />with arrowhead size h in px and in color 'color'
749
        @ use command 'linewidth int' to adjust thickness of the arrow
750
        @ use command 'linewidth int' to adjust thickness of the arrow
750
        @ may be set draggable / onclick
751
        @ may be set draggable / onclick
751
        */
752
        */
752
            for(i=0;i<6;i++){
753
            for(i=0;i<6;i++){
753
                switch(i){
754
                switch(i){
754
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
755
                    case 0: double_data[0] = get_real(infile,0);break; /* x */
755
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
756
                    case 1: double_data[1] = get_real(infile,0);break; /* y */
756
                    case 2: double_data[2] = get_real(infile,0);break; /* x */
757
                    case 2: double_data[2] = get_real(infile,0);break; /* x */
757
                    case 3: double_data[3] = get_real(infile,0);break; /* y */
758
                    case 3: double_data[3] = get_real(infile,0);break; /* y */
758
                    case 4: arrow_head = (int) get_real(infile,0);break;/* h */
759
                    case 4: arrow_head = (int) get_real(infile,0);break;/* h */
759
                    case 5: stroke_color = get_color(infile,1);/* name or hex color */
760
                    case 5: stroke_color = get_color(infile,1);/* name or hex color */
760
                        decimals = find_number_of_digits(precision);
761
                        decimals = find_number_of_digits(precision);
761
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,8,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%d,%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],arrow_head,arrow_head,arrow_head,arrow_head,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
762
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,8,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%d,%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],arrow_head,arrow_head,arrow_head,arrow_head,line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
762
                        click_cnt++;
763
                        click_cnt++;
763
                        reset();
764
                        reset();
764
                        break;
765
                        break;
765
                }
766
                }
766
            }
767
            }
767
            break;
768
            break;
768
        case ARROW2:
769
        case ARROW2:
769
        /*
770
        /*
770
        @ arrow2 x1,y1,x2,y2,h,color
771
        @ arrow2 x1,y1,x2,y2,h,color
Line 786... Line 787...
786
                        click_cnt++;reset();
787
                        click_cnt++;reset();
787
                        break;
788
                        break;
788
                }
789
                }
789
            }
790
            }
790
            break;
791
            break;
791
        case PARALLEL:
792
        case PARALLEL:
792
        /*
793
        /*
793
         @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor]
794
         @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor]
794
         @ can not be set "onclick" or "drag xy"
795
         @ can not be set "onclick" or "drag xy"
795
        */
796
        */
796
            for( i = 0;i < 8; i++ ){
797
            for( i = 0;i < 8; i++ ){
797
                switch(i){
798
                switch(i){
798
                    case 0: double_data[0] = get_real(infile,0);break; /* x1-values  -> x-pixels*/
799
                    case 0: double_data[0] = get_real(infile,0);break; /* x1-values  -> x-pixels*/
799
                    case 1: double_data[1] = get_real(infile,0);break; /* y1-values  -> y-pixels*/
800
                    case 1: double_data[1] = get_real(infile,0);break; /* y1-values  -> y-pixels*/
Line 834... Line 835...
834
            }
835
            }
835
            break;
836
            break;
836
        case LATTICE:
837
        case LATTICE:
837
        /*
838
        /*
838
         @lattice x0,y0,xv1,yv1,xv2,yv2,n1,n2,color
839
         @lattice x0,y0,xv1,yv1,xv2,yv2,n1,n2,color
839
         @can not be set "onclick" or "drag xy"
840
         @can not be set "onclick" or "drag xy"
840
        */
841
        */
841
            if( js_function[DRAW_LATTICE] != 1 ){ js_function[DRAW_LATTICE] = 1;}
842
            if( js_function[DRAW_LATTICE] != 1 ){ js_function[DRAW_LATTICE] = 1;}
842
            for( i = 0; i<9; i++){
843
            for( i = 0; i<9; i++){
843
                switch(i){
844
                switch(i){
844
                    case 0: int_data[0] = x2px(get_real(infile,0));break; /* x0-values  -> x-pixels*/
845
                    case 0: int_data[0] = x2px(get_real(infile,0));break; /* x0-values  -> x-pixels*/
Line 873... Line 874...
873
        case XSNAPTOGRID:
874
        case XSNAPTOGRID:
874
        /*
875
        /*
875
         @ xsnaptogrid
876
         @ xsnaptogrid
876
         @ keyword (no arguments rewquired) needs to be defined before command 'userdraw' and after command 'grid'
877
         @ keyword (no arguments rewquired) needs to be defined before command 'userdraw' and after command 'grid'
877
         @ in case of userdraw the drawn points will snap to xmajor grid
878
         @ in case of userdraw the drawn points will snap to xmajor grid
878
         @ if xminor / yminor is defined, the drawing will snap to xminor <br />use only even dividers in x-minor...for example<br />xsnaptogrid<br />axis<br />grid 2,1,grey,4,4,7,red<br /> will snap on x=0, x=0.5, x=1, x=1.5 ....<br /> will snap on y=0, y=0.25 y=0.5 y=0.75 ...<br />
879
         @ if xminor is defined, the drawing will snap to xminor <br />use only even dividers in x-minor...for example<br />xsnaptogrid<br />axis<br />grid 2,1,grey,4,4,7,red<br /> will snap on x=0, x=0.5, x=1, x=1.5 ....<br /> will snap on y=0, y=0.25 y=0.5 y=0.75 ...<br />
879
        */
880
        */
880
        fprintf(js_include_file,"\nx_use_snap_to_grid = 1;var snap_x = 1;if (typeof snap_y === 'undefined') { var snap_y = 1;};var snap_y = 1;function snap_to_x(x){return x2px(snap_x*(Math.round((px2x(x))/snap_x)));};\n");
881
        fprintf(js_include_file,"\nx_use_snap_to_grid = 1;var snap_x = 1;if (typeof snap_y === 'undefined') { var snap_y = 1;};var snap_y = 1;function snap_to_x(x){return x2px(snap_x*(Math.round((px2x(x))/snap_x)));};\n");
881
        break;
882
        break;
882
        case YSNAPTOGRID:
883
        case YSNAPTOGRID:
883
        /*
884
        /*
884
         @ ysnaptogrid
885
         @ ysnaptogrid
885
         @ keyword (no arguments rewquired) needs to be defined before command 'userdraw' and after command 'grid'
886
         @ keyword (no arguments rewquired) needs to be defined before command 'userdraw' and after command 'grid'
886
         @ in case of userdraw the drawn points will snap to ymajor grid
887
         @ in case of userdraw the drawn points will snap to ymajor grid
887
         @ if xminor / yminor is defined, the drawing will snap to yminor <br />use only even dividers in y-minor...for example<br />ysnaptogrid<br />axis<br />grid 2,1,grey,4,4,7,red<br /> will snap on x=0, x=0.5, x=1, x=1.5 ....<br /> will snap on y=0, y=0.25 y=0.5 y=0.75 ...<br />
888
         @ if yminor is defined, the drawing will snap to yminor <br />use only even dividers in y-minor...for example<br />ysnaptogrid<br />axis<br />grid 2,1,grey,4,4,7,red<br /> will snap on x=0, x=0.5, x=1, x=1.5 ....<br /> will snap on y=0, y=0.25 y=0.5 y=0.75 ...<br />
888
        */
889
        */
889
        fprintf(js_include_file,"\ny_use_snap_to_grid = 1;if (typeof snap_x === 'undefined') { var snap_x = 1;};var snap_y = 1;\nfunction snap_to_y(y){return y2px(snap_y*(Math.round((px2y(y))/snap_y)));};\n");
890
        fprintf(js_include_file,"\ny_use_snap_to_grid = 1;if (typeof snap_x === 'undefined') { var snap_x = 1;};var snap_y = 1;\nfunction snap_to_y(y){return y2px(snap_y*(Math.round((px2y(y))/snap_y)));};\n");
890
        break;
891
        break;
891
        case USERTEXTAREA_XY:
892
        case USERTEXTAREA_XY:
892
        /*
893
        /*
893
        @ usertextarea_xy
894
        @ usertextarea_xy
894
        @ keyword
895
        @ keyword
895
        @ to be used in combination with command "userdraw object_type,color" wherein object_type is only segment / polyline for the time being...
896
        @ to be used in combination with command "userdraw object_type,color" wherein object_type is only segment / polyline for the time being...
896
        @ if set two textareas are added to the document<br />(one for x-values , one for y-values)
897
        @ if set two textareas are added to the document<br />(one for x-values , one for y-values)
897
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
898
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
898
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
-
 
899
        @ user drawings will not zoom on zooming (or pan on panning)
899
        @ user drawings will not zoom on zooming (or pan on panning)
900
        */
900
        */
901
            if(use_tooltip == TRUE){canvas_error("usertextarea_xy can not be combined with intooltip command");}
-
 
902
            if( use_input_xy == 1 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
901
            if( use_input_xy != 0 ){canvas_error("usertextarea_xy can not be combined with userinput_xy command");}
903
            fprintf(js_include_file,"function safe_eval(exp){if(exp.indexOf('^') != -1){exp = exp.replace(/\\s*(.*)\\^\\s*(.*)/ig, \"pow($1, $2)\");};var reg = /(?:[a-z$_][a-z0-9$_]*)|(?:[;={}\\[\\]\"'!&<>^\\\\?:])/ig;var valid = true;exp = exp.replace(reg,function($0){if (Math.hasOwnProperty($0)){return \"Math.\"+$0;}else{valid = false;};});if (!valid){alert(\"hmmm \"+exp+\" ?\"); exp = null;}else{try { exp = eval(exp); } catch (e) {alert(\"Invalid arithmetic expression\"); exp = null;};};return exp;};");
902
            add_safe_eval(js_include_file);
904
            use_input_xy = 2;
903
            use_input_xy = 2;
905
            break;
904
            break;
906
        case USERINPUT_XY:
905
        case USERINPUT_XY:
907
        /*
906
        /*
908
        @ userinput_xy
907
        @ userinput_xy
909
        @ keyword
908
        @ keyword
910
        @ to be used in combination with command "userdraw object_type,color"
909
        @ to be used in combination with command "userdraw object_type,color"
911
        @ 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)
910
        @ 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)
912
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
911
        @ the student may use this as correction for (x:y) on a drawing (or to draw without mouse, using just the coordinates)
913
        @ 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.
912
        @ 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.
914
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
913
        @ can not be combined with command "intooltip tiptext" <br />note: the 'tooltip div element' is used for placing inputfields
915
        @ user drawings will not zoom on zooming (or pan on panning)
914
        @ user drawings will not zoom on zooming (or pan on panning)
916
        */
915
        */
917
            if(use_tooltip == TRUE){canvas_error("userinput_xy can not be combined with intooltip command");}
-
 
918
            /* add simple eval check to avoid code injection with unprotected eval(string) */
916
            /* add simple eval check to avoid code injection with unprotected eval(string) */
-
 
917
            if( use_input_xy != 0 ){canvas_error("userinput_xy can not be combined with usertextarea_xy command");}
919
            fprintf(js_include_file,"function safe_eval(exp){if(exp.indexOf('^') != -1){exp = exp.replace(/\\s*(.*)\\^\\s*(.*)/ig, \"pow($1, $2)\");};var reg = /(?:[a-z$_][a-z0-9$_]*)|(?:[;={}\\[\\]\"'!&<>^\\\\?:])/ig;var valid = true;exp = exp.replace(reg,function($0){if (Math.hasOwnProperty($0)){return \"Math.\"+$0;}else{valid = false;};});if (!valid){alert(\"hmmm \"+exp+\" ?\"); exp = null;}else{try { exp = eval(exp); } catch (e) {alert(\"Invalid arithmetic expression\"); exp = null;};};return exp;};");
918
            add_safe_eval(js_include_file);
920
            use_input_xy = 1;
919
            use_input_xy = 1;
921
            break;
920
            break;
922
        case USERDRAW:
921
        case USERDRAW:
923
        /*
922
        /*
924
        @ userdraw object_type,color
923
        @ userdraw object_type,color
925
        @ implemented object_type: <ul><li>point</li><li>points</li><li>crosshair</li><li>crosshairs</li><li>line</li><li>lines</li><li>segment</li><li>segments</li><li>polyline</li><li>circle</li><li>circles</li><li>arrow</li><li>arrows</li><li>triangle</li><li>polygon</li><li>poly[3-9]</li><li>rect</li><li>roundrect</li><li>rects</li><li>roundrects</li><li>freehandline</li><li>freehandlines</li><li>path</li><li>paths</li><li>text</li></ul>
924
        @ implemented object_type: <ul><li>point</li><li>points</li><li>crosshair</li><li>crosshairs</li><li>line</li><li>lines</li><li>segment</li><li>segments</li><li>polyline</li><li>circle</li><li>circles</li><li>arrow</li><li>arrows</li><li>triangle</li><li>polygon</li><li>poly[3-9]</li><li>rect</li><li>roundrect</li><li>rects</li><li>roundrects</li><li>freehandline</li><li>freehandlines</li><li>path</li><li>paths</li><li>text</li></ul>
926
        @ 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)
925
        @ 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)
927
        @ 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
926
        @ 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
928
        @ note: object_type polygone: Will be finished (the object is closed) when clicked on the first point of the polygone again.
927
        @ note: object_type polygone: Will be finished (the object is closed) when clicked on the first point of the polygone again.
929
        @ 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)
928
        @ 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)
930
        @ use command "filled", "opacity int,int"  and "fillcolor color" to trigger coloured filling of fillable objects
929
        @ use command "filled", "opacity int,int"  and "fillcolor color" to trigger coloured filling of fillable objects
931
        @ use command "dashed" and/or "dashtype int,int" to trigger dashing
930
        @ use command "dashed" and/or "dashtype int,int" to trigger dashing
932
        @ use command "replyformat int" to control / adjust output formatting of javascript function read_canvas();
931
        @ use command "replyformat int" to control / adjust output formatting of javascript function read_canvas();
933
        @ may be combined with onclick or drag xy  of other components of flyscript objects (although not very usefull...)
932
        @ may be combined with onclick or drag xy  of other components of flyscript objects (although not very usefull...)
934
        @ may be combined with keyword 'userinput_xy' or
933
        @ may be combined with keyword 'userinput_xy' or
935
        @ 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.!
934
        @ 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.!
936
        */
935
        */
937
            if( use_userdraw == TRUE ){ /* only one object type may be drawn*/
936
            if( use_userdraw == TRUE ){ /* only one object type may be drawn*/
938
                canvas_error("Only one userdraw primitive may be used: read documentation !!");
937
                canvas_error("Only one userdraw primitive may be used: read documentation !!");
939
            }
938
            }
940
            use_userdraw = TRUE;
939
            use_userdraw = TRUE;
941
            fprintf(js_include_file,"<!-- begin userdraw mouse events -->\nvar userdraw_x = new Array();var userdraw_y = new Array();var userdraw_radius = new Array();var xy_cnt=0;var canvas_userdraw = create_canvas%d(%d,xsize,ysize);var context_userdraw = canvas_userdraw.getContext(\"2d\");var use_dashed = %d;if(use_dashed == 1){if( context_userdraw.setLineDash ){context_userdraw.setLineDash([%d,%d]);}else{if(context_userdraw.mozDash){context_userdraw.mozDash = [%d,%d];};};};if(wims_status != \"done\"){canvas_div.addEventListener(\"mousedown\",user_draw,false);canvas_div.addEventListener(\"mousemove\",user_drag,false);canvas_div.addEventListener(\"touchstart\",user_draw,false);canvas_div.addEventListener(\"touchmove\",user_drag,false);}\n<!-- end userdraw mouse events -->",canvas_root_id,DRAW_CANVAS,use_dashed,dashtype[0],dashtype[1],dashtype[0],dashtype[1]);
940
            fprintf(js_include_file,"\n<!-- begin userdraw mouse events -->\nvar userdraw_x = new Array();var userdraw_y = new Array();var userdraw_radius = new Array();var xy_cnt=0;var canvas_userdraw = create_canvas%d(%d,xsize,ysize);var context_userdraw = canvas_userdraw.getContext(\"2d\");var use_dashed = %d;if(use_dashed == 1){if( context_userdraw.setLineDash ){context_userdraw.setLineDash([%d,%d]);}else{if(context_userdraw.mozDash){context_userdraw.mozDash = [%d,%d];};};};if(wims_status != \"done\"){canvas_div.addEventListener(\"mousedown\",user_draw,false);canvas_div.addEventListener(\"mousemove\",user_drag,false);canvas_div.addEventListener(\"touchstart\",user_draw,false);canvas_div.addEventListener(\"touchmove\",user_drag,false);}\n<!-- end userdraw mouse events -->",canvas_root_id,DRAW_CANVAS,use_dashed,dashtype[0],dashtype[1],dashtype[0],dashtype[1]);
942
            draw_type = get_string_argument(infile,0);
941
            draw_type = get_string_argument(infile,0);
943
            stroke_color = get_color(infile,1);
942
            stroke_color = get_color(infile,1);
944
            if( strcmp(draw_type,"point") == 0 ){
943
            if( strcmp(draw_type,"point") == 0 ){
945
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
944
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
946
                if(reply_format < 1 ){reply_format = 8;}
945
                if(reply_format < 1 ){reply_format = 8;}
947
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
946
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
948
                if(use_input_xy == 1){
947
                if(use_input_xy == 1){
949
                    add_input_circle(js_include_file,1,1);
948
                    add_input_circle(js_include_file,1,1);
950
                    add_input_xy(js_include_file,canvas_root_id);
949
                    add_input_xy(js_include_file,canvas_root_id);
951
                }
950
                }
952
                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);
951
                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);
953
            }
952
            }
954
            else
953
            else
955
            if( strcmp(draw_type,"points") == 0 ){
954
            if( strcmp(draw_type,"points") == 0 ){
956
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
955
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
957
                if(reply_format < 1 ){reply_format = 8;}
956
                if(reply_format < 1 ){reply_format = 8;}
958
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
957
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
959
                if(use_input_xy == 1){
958
                if(use_input_xy == 1){
960
                    add_input_circle(js_include_file,1,2);
959
                    add_input_circle(js_include_file,1,2);
961
                    add_input_xy(js_include_file,canvas_root_id);
960
                    add_input_xy(js_include_file,canvas_root_id);
962
                }
961
                }
963
                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);
962
                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);
964
            }
963
            }
965
            else
964
            else
966
            if( strcmp(draw_type,"segment") == 0 ){
965
            if( strcmp(draw_type,"segment") == 0 ){
967
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
966
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
968
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
967
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
969
                if(reply_format < 1){reply_format = 11;}
968
                if(reply_format < 1){reply_format = 11;}
970
                if(use_input_xy == 1){
969
                if(use_input_xy == 1){
971
                    add_input_segment(js_include_file,1);
970
                    add_input_segment(js_include_file,1);
972
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
971
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
973
                }
972
                }
974
                add_js_segments(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
973
                add_js_segments(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
975
            }
974
            }
Line 985... Line 984...
985
            }
984
            }
986
            else
985
            else
987
            if( strcmp(draw_type,"segments") == 0 ){
986
            if( strcmp(draw_type,"segments") == 0 ){
988
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
987
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
989
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
988
                if( js_function[DRAW_SEGMENTS] != 1 ){ js_function[DRAW_SEGMENTS] = 1;}
990
                if(reply_format < 1){reply_format = 11;}
989
                if(reply_format < 1){reply_format = 11;}
991
                if(use_input_xy == 1){
990
                if(use_input_xy == 1){
992
                    add_input_segment(js_include_file,2);
991
                    add_input_segment(js_include_file,2);
993
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
992
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
994
                }
993
                }
995
                add_js_segments(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
994
                add_js_segments(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
996
            }
995
            }
997
            else
996
            else
998
            if( strcmp(draw_type,"circle") == 0 ){
997
            if( strcmp(draw_type,"circle") == 0 ){
999
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
998
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1000
                if(reply_format < 1){reply_format = 10;}
999
                if(reply_format < 1){reply_format = 10;}
1001
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1000
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1002
                if(use_input_xy == 1){
1001
                if(use_input_xy == 1){
1003
                    add_input_circle(js_include_file,2,1);
1002
                    add_input_circle(js_include_file,2,1);
1004
                    add_input_xyr(js_include_file,canvas_root_id);
1003
                    add_input_xyr(js_include_file,canvas_root_id);
1005
                }
1004
                }
1006
                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]);
1005
                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]);
1007
            }
1006
            }
Line 1009... Line 1008...
1009
            if( strcmp(draw_type,"circles") == 0 ){
1008
            if( strcmp(draw_type,"circles") == 0 ){
1010
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1009
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1011
                if(reply_format < 1){reply_format = 10;}
1010
                if(reply_format < 1){reply_format = 10;}
1012
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1011
                /* 9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n in x/y-range */
1013
                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]);
1012
                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]);
1014
                if(use_input_xy == 1){
1013
                if(use_input_xy == 1){
1015
                    add_input_circle(js_include_file,2,2);
1014
                    add_input_circle(js_include_file,2,2);
1016
                    add_input_xyr(js_include_file,canvas_root_id);
1015
                    add_input_xyr(js_include_file,canvas_root_id);
1017
                }
1016
                }
1018
            }
1017
            }
1019
            else
1018
            else
1020
            if(strcmp(draw_type,"crosshair") == 0 ){
1019
            if(strcmp(draw_type,"crosshair") == 0 ){
1021
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1020
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1022
                if(reply_format < 1){reply_format = 8;}
1021
                if(reply_format < 1){reply_format = 8;}
1023
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1022
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1024
                add_js_crosshairs(js_include_file,1,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1023
                add_js_crosshairs(js_include_file,1,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1025
                if(use_input_xy == 1){
1024
                if(use_input_xy == 1){
1026
                    add_input_crosshair(js_include_file,1);
1025
                    add_input_crosshair(js_include_file,1);
1027
                    add_input_xy(js_include_file,canvas_root_id);
1026
                    add_input_xy(js_include_file,canvas_root_id);
1028
                }
1027
                }
1029
            }
1028
            }
1030
            else
1029
            else
1031
            if(strcmp(draw_type,"crosshairs") == 0 ){
1030
            if(strcmp(draw_type,"crosshairs") == 0 ){
1032
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1031
                if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1033
                if(reply_format < 1){reply_format = 8;}
1032
                if(reply_format < 1){reply_format = 8;}
1034
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1033
                /* 7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n in x/y-range */
1035
                add_js_crosshairs(js_include_file,2,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1034
                add_js_crosshairs(js_include_file,2,draw_type,line_width,crosshair_size ,stroke_color,stroke_opacity);
1036
                if(use_input_xy == 1){
1035
                if(use_input_xy == 1){
1037
                    add_input_crosshair(js_include_file,2);
1036
                    add_input_crosshair(js_include_file,2);
1038
                    add_input_xy(js_include_file,canvas_root_id);
1037
                    add_input_xy(js_include_file,canvas_root_id);
1039
                }
1038
                }
1040
            }
1039
            }
1041
            else
1040
            else
1042
            if(strcmp(draw_type,"freehandline") == 0 ){
1041
            if(strcmp(draw_type,"freehandline") == 0 ){
1043
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1042
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1044
                if(reply_format < 1){reply_format = 6;}
1043
                if(reply_format < 1){reply_format = 6;}
1045
                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]);
1044
                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]);  
1046
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1045
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1047
            }
1046
            }
1048
            else
1047
            else
1049
            if(strcmp(draw_type,"freehandlines") == 0 ){
1048
            if(strcmp(draw_type,"freehandlines") == 0 ){
1050
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1049
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1051
                if(reply_format < 1){reply_format = 6;}
1050
                if(reply_format < 1){reply_format = 6;}
1052
                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]);
1051
                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]);  
1053
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1052
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1054
            }
1053
            }
1055
            else
1054
            else
1056
            if(strcmp(draw_type,"path") == 0 ){
1055
            if(strcmp(draw_type,"path") == 0 ){
1057
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1056
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1058
                if(reply_format < 1){reply_format = 6;}
1057
                if(reply_format < 1){reply_format = 6;}
1059
                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]);
1058
                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]);  
1060
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1059
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1061
            }
1060
            }
1062
            else
1061
            else
1063
            if(strcmp(draw_type,"paths") == 0 ){
1062
            if(strcmp(draw_type,"paths") == 0 ){
1064
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1063
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1065
                if(reply_format < 1){reply_format = 6;}
1064
                if(reply_format < 1){reply_format = 6;}
1066
                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]);
1065
                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]);  
1067
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1066
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1068
            }
1067
            }
1069
            else
1068
            else
1070
            if(strcmp(draw_type,"arrows") == 0 ){
1069
            if(strcmp(draw_type,"arrows") == 0 ){
1071
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1070
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1072
                if(reply_format < 1){reply_format = 11;}
1071
                if(reply_format < 1){reply_format = 11;}
1073
                add_js_arrows(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1072
                add_js_arrows(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1074
                if(use_input_xy == 1){
1073
                if(use_input_xy == 1){
1075
                    add_input_arrow(js_include_file,2);
1074
                    add_input_arrow(js_include_file,2);
1076
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1075
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1077
                }
1076
                }
1078
            }
1077
            }
1079
            else
1078
            else
1080
            if(strcmp(draw_type,"arrow") == 0 ){
1079
            if(strcmp(draw_type,"arrow") == 0 ){
1081
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1080
                if( js_function[DRAW_ARROWS] != 1 ){ js_function[DRAW_ARROWS] = 1;}
1082
                if(reply_format < 1){reply_format = 11;}
1081
                if(reply_format < 1){reply_format = 11;}
1083
                add_js_arrows(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1082
                add_js_arrows(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1],arrow_head);
1084
                if(use_input_xy == 1){
1083
                if(use_input_xy == 1){
1085
                    add_input_arrow(js_include_file,1);
1084
                    add_input_arrow(js_include_file,1);
1086
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1085
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1087
                }
1086
                }
1088
            }
1087
            }
1089
            else
1088
            else
Line 1094... Line 1093...
1094
                if( use_input_xy == 2 ){
1093
                if( use_input_xy == 2 ){
1095
                  add_textarea_polygon(js_include_file);
1094
                  add_textarea_polygon(js_include_file);
1096
                  add_textarea_xy(js_include_file,canvas_root_id);
1095
                  add_textarea_xy(js_include_file,canvas_root_id);
1097
                }
1096
                }
1098
            }
1097
            }
1099
            else
1098
            else
1100
            if(strncmp(draw_type,"poly",4) == 0){
1099
            if(strncmp(draw_type,"poly",4) == 0){
1101
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1100
                if(strlen(draw_type) < 5){canvas_error("use command \"userdraw poly[3-9],color\" eg userdraw poly6,blue");}
1102
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1101
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1103
                if(reply_format < 1){reply_format = 2;}
1102
                if(reply_format < 1){reply_format = 2;}
1104
                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]);
1103
                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]);
1105
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1104
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1106
            }
1105
            }
1107
            else
1106
            else
1108
            if(strcmp(draw_type,"triangle") == 0){
1107
            if(strcmp(draw_type,"triangle") == 0){
1109
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1108
                if( js_function[DRAW_PATHS] != 1 ){ js_function[DRAW_PATHS] = 1;}
1110
                if(reply_format < 1){reply_format = 2;}
1109
                if(reply_format < 1){reply_format = 2;}
1111
                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]);
1110
                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]);
1112
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1111
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1113
            }
1112
            }
1114
            else
1113
            else
1115
            if( strcmp(draw_type,"line") == 0 ){
1114
            if( strcmp(draw_type,"line") == 0 ){
1116
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1115
                if( js_function[DRAW_CIRCLES] != 1 ){ js_function[DRAW_CIRCLES] = 1;}
1117
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1116
                if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1118
                if(reply_format < 1){reply_format = 11;}
1117
                if(reply_format < 1){reply_format = 11;}
1119
                add_js_lines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1118
                add_js_lines(js_include_file,1,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
Line 1130... Line 1129...
1130
                add_js_lines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1129
                add_js_lines(js_include_file,2,draw_type,line_width,stroke_color,stroke_opacity,use_dashed,dashtype[0],dashtype[1]);
1131
                if( use_input_xy == 1 ){
1130
                if( use_input_xy == 1 ){
1132
                    add_input_line(js_include_file,2);
1131
                    add_input_line(js_include_file,2);
1133
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1132
                    add_input_x1y1x2y2(js_include_file,canvas_root_id);
1134
                }
1133
                }
1135
            }
1134
            }
1136
            else
1135
            else
1137
            if( strcmp(draw_type,"rects") == 0){
1136
            if( strcmp(draw_type,"rects") == 0){
1138
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1137
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1139
                if(reply_format < 1){reply_format = 2;}
1138
                if(reply_format < 1){reply_format = 2;}
1140
                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]);
1139
                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]);
1141
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1140
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1142
            }
1141
            }
1143
            else
1142
            else
1144
            if( strcmp(draw_type,"roundrects") == 0){
1143
            if( strcmp(draw_type,"roundrects") == 0){
1145
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1144
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1146
                if(reply_format < 1){reply_format = 2;}
1145
                if(reply_format < 1){reply_format = 2;}
1147
                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]);
1146
                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]);
1148
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1147
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1149
            }
1148
            }
1150
            else
1149
            else
1151
            if( strcmp(draw_type,"rect") == 0){
1150
            if( strcmp(draw_type,"rect") == 0){
1152
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1151
                if( js_function[DRAW_RECTS] != 1 ){ js_function[DRAW_RECTS] = 1;}
1153
                if(reply_format < 1){reply_format = 2;}
1152
                if(reply_format < 1){reply_format = 2;}
1154
                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]);
1153
                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]);
1155
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1154
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1156
            }
1155
            }
1157
            else
1156
            else
1158
            if( strcmp(draw_type,"roundrect") == 0){
1157
            if( strcmp(draw_type,"roundrect") == 0){
1159
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1158
                if( js_function[DRAW_ROUNDRECTS] != 1 ){ js_function[DRAW_ROUNDRECTS] = 1;}
1160
                if(reply_format < 1){reply_format = 2;}
1159
                if(reply_format < 1){reply_format = 2;}
1161
                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]);
1160
                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]);
1162
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1161
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1163
            }
1162
            }
1164
            else
1163
            else
1165
            if( strcmp(draw_type,"text") == 0){
1164
            if( strcmp(draw_type,"text") == 0){
1166
                if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}
1165
                if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}      
1167
                if(reply_format < 1){reply_format = 17;}
1166
                if(reply_format < 1){reply_format = 17;}
1168
                add_js_text(js_include_file,canvas_root_id,font_size,font_family,font_color,stroke_opacity,use_rotate,angle,use_translate,translate_x,translate_y);
1167
                add_js_text(js_include_file,canvas_root_id,font_size,font_family,font_color,stroke_opacity,use_rotate,angle,use_translate,translate_x,translate_y);
1169
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1168
                if(use_input_xy == 1){ canvas_error("userinput_xy not yet implemented for this userdraw type !");}
1170
            }
1169
            }
1171
            else
1170
            else
1172
            {
1171
            {
1173
                canvas_error("unknown drawtype or typo? ");
1172
                canvas_error("unknown drawtype or typo? ");
1174
            }
1173
            }
1175
            reset();
1174
            reset();
1176
        break;
1175
        break;
Line 1228... Line 1227...
1228
             i++;
1227
             i++;
1229
            }
1228
            }
1230
            for(c = 0 ; c < i; c++){
1229
            for(c = 0 ; c < i; c++){
1231
             fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,16,%s,[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,eval_levelcurve(xsize,ysize,fun1,xmin,xmax,ymin,ymax,plot_steps,precision,double_data[c]),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);
1230
             fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,16,%s,[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,eval_levelcurve(xsize,ysize,fun1,xmin,xmax,ymin,ymax,plot_steps,precision,double_data[c]),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);
1232
             click_cnt++;
1231
             click_cnt++;
1233
            }
1232
            }
1234
            reset();
1233
            reset();
1235
            break;
1234
            break;
1236
        case TRACE_JSMATH:
1235
        case TRACE_JSMATH:
1237
        /*
1236
        /*
1238
         @trace_jsmath some_javascript_math_function
1237
         @trace_jsmath some_javascript_math_function
1239
         @will use a crosshair to trace the jsmath curve
1238
         @will use a crosshair to trace the jsmath curve
1240
         @two inputfields will display the current x/y-values (approximated)
1239
         @two inputfields will display the current x/y-values (numerical evaluation by javascript)
1241
         @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
1240
         @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  
1242
         @use linewidth,strokecolor,crosshairsize to adjust the corsshair.
1241
         @use linewidth,strokecolor,crosshairsize to adjust the corsshair.
1243
         @example: trace_jsmath Math.pow(x,2)+4*x+16
1242
         @example: trace_jsmath Math.pow(x,2)+4*x+16
1244
         @example: trace_jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1243
         @example: trace_jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1245
         @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1244
         @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1246
         @can not be combined with commands 'mouse color,fontsize' and 'intooltip tip_text'
-
 
1247
        */
1245
        */
1248
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1246
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1249
            if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1247
            if( js_function[DRAW_LINES] != 1 ){ js_function[DRAW_LINES] = 1;}
1250
            add_trace_js_mouse(js_include_file,TRACE_CANVAS,canvas_root_id,stroke_color,get_string(infile,1),font_size,stroke_opacity,line_width,crosshair_size);
1248
            add_trace_js_mouse(js_include_file,TRACE_CANVAS,canvas_root_id,stroke_color,get_string(infile,1),font_size,stroke_opacity,line_width,crosshair_size);
1251
            break;
1249
            break;
1252
        case JSMATH:
1250
        case JSMATH:
1253
        /*
1251
        /*
1254
            @jsmath some_javascript_math_function
1252
            @jsmath some_javascript_math_function
1255
            @will calculate an y-value from a userinput x-value and draws a crosshairs on these coordinates.
1253
            @will calculate an y-value from a userinput x-value and draws a crosshair on these coordinates.
1256
            @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
1254
            @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  
1257
            @example: jsmath Math.pow(x,2)+4*x+16
1255
            @example: jsmath Math.pow(x,2)+4*x+16
1258
            @example: jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1256
            @example: jsmath Math.sin(Math.pow(x,Math.Pi))+Math.sqrt(x)
1259
            @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1257
            @no check is done on the validity of your function and/or syntax<br />use error console to debug any errors...
1260
            @can not be combined with commands 'mouse color,fontsize' and 'intooltip tip_text'
-
 
1261
        */
1258
        */
1262
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1259
            if( js_function[DRAW_CROSSHAIRS] != 1 ){ js_function[DRAW_CROSSHAIRS] = 1;}
1263
            add_calc_y(js_include_file,canvas_root_id,get_string(infile,1));
1260
            add_calc_y(js_include_file,canvas_root_id,get_string(infile,1));
1264
            break;
1261
            break;
1265
        case CURVE:
1262
        case CURVE:
1266
        /*
1263
        /*
1267
         @curve color,formula(x)
1264
         @curve color,formula(x)
1268
         @plot color,formula(x)
1265
         @plot color,formula(x)
1269
         @use command trange before command curve / plot  (trange -pi,pi)<br />curve color,formula1(t),formula2(t)
1266
         @use command trange before command curve / plot  (trange -pi,pi)<br />curve color,formula1(t),formula2(t)
1270
         @use command "precision" to increase the number of digits of the plotted points
1267
         @use command "precision" to increase the number of digits of the plotted points
1271
         @use command "plotsteps" to increase / decrease the amount of plotted points (default 150)
1268
         @use command "plotsteps" to increase / decrease the amount of plotted points (default 150)
1272
         @may be set draggable / onclick
1269
         @may be set draggable / onclick
1273
        */
1270
        */
1274
            if( use_parametric == TRUE ){ /* parametric color,fun1(t),fun2(t)*/
1271
            if( use_parametric == TRUE ){ /* parametric color,fun1(t),fun2(t)*/
1275
                use_parametric = FALSE;
1272
                use_parametric = FALSE;
1276
                stroke_color = get_color(infile,0);
1273
                stroke_color = get_color(infile,0);
1277
                char *fun1 = get_string_argument(infile,0);
1274
                char *fun1 = get_string_argument(infile,0);
1278
                char *fun2 = get_string_argument(infile,1);
1275
                char *fun2 = get_string_argument(infile,1);
Line 1282... Line 1279...
1282
            }
1279
            }
1283
            else
1280
            else
1284
            {
1281
            {
1285
                stroke_color = get_color(infile,0);
1282
                stroke_color = get_color(infile,0);
1286
                char *fun1 = get_string_argument(infile,1);
1283
                char *fun1 = get_string_argument(infile,1);
1287
                if( strlen(fun1) == 0 ){canvas_error("function is NOT OK !");}
1284
                if( strlen(fun1) == 0 ){canvas_error("function is NOT OK !");} 
1288
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,%d,%s,[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,animation_type,eval(xsize,ysize,fun1,xmin,xmax,ymin,ymax,plot_steps,precision),line_width,line_width,line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
1285
                fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,%d,%s,[%d],[%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,animation_type,eval(xsize,ysize,fun1,xmin,xmax,ymin,ymax,plot_steps,precision),line_width,line_width,line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,use_affine,affine_matrix);
1289
                click_cnt++;
1286
                click_cnt++;
1290
            }
1287
            }
1291
            animation_type = 9;/* reset to curve plotting without animation */
1288
            animation_type = 9;/* reset to curve plotting without animation */
1292
            reset();
1289
            reset();
1293
            break;
1290
            break;
1294
        case FLY_TEXT:
1291
        case FLY_TEXT:
1295
        /*
1292
        /*
1296
        @ text fontcolor,x,y,font,text_string
1293
        @ text fontcolor,x,y,font,text_string
1297
        @ font may be described by keywords : giant,huge,normal,small,tiny
1294
        @ font may be described by keywords : giant,huge,normal,small,tiny
1298
        @ use command 'fontsize' to increase base fontsize for the keywords
1295
        @ use command 'fontsize' to increase base fontsize for the keywords
1299
        @ may be set "onclick" or "drag xy"
1296
        @ may be set "onclick" or "drag xy"
1300
        @ backwards compatible with flydraw
1297
        @ backwards compatible with flydraw
1301
        @ unicode supported: text red,0,0,huge,\\u2232
1298
        @ unicode supported: text red,0,0,huge,\\u2232
1302
        @ use command 'string' and 'fontfamily' for a more fine grained control over html5 canvas text element
1299
        @ use command 'string' and 'fontfamily' for a more fine grained control over html5 canvas text element
1303
        @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1300
        @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
Line 1305... Line 1302...
1305
            for(i = 0; i < 5 ;i++){
1302
            for(i = 0; i < 5 ;i++){
1306
                switch(i){
1303
                switch(i){
1307
                    case 0: stroke_color = get_color(infile,0);break;/* font_color == stroke_color name or hex color */
1304
                    case 0: stroke_color = get_color(infile,0);break;/* font_color == stroke_color name or hex color */
1308
                    case 1: double_data[0] = get_real(infile,0);break; /* x */
1305
                    case 1: double_data[0] = get_real(infile,0);break; /* x */
1309
                    case 2: double_data[1] = get_real(infile,0);break; /* y */
1306
                    case 2: double_data[1] = get_real(infile,0);break; /* y */
1310
                    case 3: fly_font = get_string_argument(infile,0);
1307
                    case 3: fly_font = get_string_argument(infile,0);
1311
                            if(strcmp(fly_font,"giant") == 0){
1308
                            if(strcmp(fly_font,"giant") == 0){
1312
                                font_size = (int)(font_size + 24);
1309
                                font_size = (int)(font_size + 24);
1313
                            }
1310
                            }
1314
                            else
1311
                            else
1315
                            {
1312
                            {
1316
                                if(strcmp(fly_font,"huge") == 0){
1313
                                if(strcmp(fly_font,"huge") == 0){
1317
                                    font_size = (int)(font_size + 14);
1314
                                    font_size = (int)(font_size + 14);
1318
                                }
1315
                                }
1319
                                else
1316
                                else
1320
                                {
1317
                                {
1321
                                    if(strcmp(fly_font,"large") == 0){
1318
                                    if(strcmp(fly_font,"large") == 0){
1322
                                        font_size = (int)(font_size + 6);
1319
                                        font_size = (int)(font_size + 6);
1323
                                        }
1320
                                        }
1324
                                        else
1321
                                        else
1325
                                        {
1322
                                        {
1326
                                            if(strcmp(fly_font,"small") == 0){
1323
                                            if(strcmp(fly_font,"small") == 0){
1327
                                                font_size = (int)(font_size - 4);
1324
                                                font_size = (int)(font_size - 4);
1328
                                                if(font_size<0){font_size = 8;}
1325
                                                if(font_size<0){font_size = 8;}
1329
                                        }
1326
                                        }
1330
                                    }
1327
                                    }
1331
                                }
1328
                                }
1332
                            }
1329
                            }
1333
                            break; /* font_size ! */
1330
                            break; /* font_size ! */
1334
                    case 4:
1331
                    case 4:
1335
                        temp = get_string_argument(infile,1);
1332
                        temp = get_string_argument(infile,1);
1336
                        decimals = find_number_of_digits(precision);
1333
                        decimals = find_number_of_digits(precision);
1337
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,14,[%.*f],[%.*f],[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%d,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,0,0,temp,font_size,font_family,use_affine,affine_matrix);
1334
                        fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,14,[%.*f],[%.*f],[30],[30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%d,\"%s\",%d,\"%s\",%d,%s));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[1],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,0,0,0,0,0,temp,font_size,font_family,use_affine,affine_matrix);
1338
                        click_cnt++;reset();break;
1335
                        click_cnt++;reset();break;
1339
                    default:break;
1336
                    default:break;
Line 1343... Line 1340...
1343
        case FLY_TEXTUP:
1340
        case FLY_TEXTUP:
1344
        /*
1341
        /*
1345
         @ textup fontcolor,x,y,font,text_string
1342
         @ textup fontcolor,x,y,font,text_string
1346
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1343
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1347
         @ font may be described by keywords : giant,huge,normal,small,tiny
1344
         @ font may be described by keywords : giant,huge,normal,small,tiny
1348
         @ use command 'fontsize' to increase base fontsize for the keywords
1345
         @ use command 'fontsize' to increase base fontsize for the keywords
1349
         @ backwards compatible with flydraw
1346
         @ backwards compatible with flydraw
1350
         @ unicode supported: textup red,0,0,huge,\\u2232
1347
         @ unicode supported: textup red,0,0,huge,\\u2232
1351
         @ use command 'stringup' and 'fontfamily' for a more fine grained control over html5 canvas text element
1348
         @ use command 'stringup' and 'fontfamily' for a more fine grained control over html5 canvas text element
1352
         @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1349
         @ Avoid  mixing old flydraw commands 'text' 'textup' with new canvasdraw commands 'string' stringup'<br />If the fontfamily was set completely like "fontfamily italic 24px Ariel".<br />In that case rested 'fontfamily' to something lke 'fontfamily Ariel' before the old flydraw commands.
1353
        */
1350
        */
1354
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}
1351
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}  
1355
            for(i = 0; i<5 ;i++){
1352
            for(i = 0; i<5 ;i++){
1356
                switch(i){
1353
                switch(i){
1357
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1354
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1358
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1355
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1359
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
1356
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
Line 1379... Line 1376...
1379
                                        }
1376
                                        }
1380
                                    }
1377
                                    }
1381
                                }
1378
                                }
1382
                            }
1379
                            }
1383
                            break; /* font_size ! */
1380
                            break; /* font_size ! */
1384
                    case 4:
1381
                    case 4:
1385
                    decimals = find_number_of_digits(precision);
1382
                    decimals = find_number_of_digits(precision);
1386
                    temp = get_string_argument(infile,1);
1383
                    temp = get_string_argument(infile,1);
1387
                    string_length = snprintf(NULL,0,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
1384
                    string_length = snprintf(NULL,0,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
1388
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1385
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1389
                    snprintf(tmp_buffer,string_length,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
1386
                    snprintf(tmp_buffer,string_length,"draw_text(%d,%d,%d,%d,\"%s\",\"%s\",%.2f,90,\"%s\",%d,%.2f,%d,[%d,%d]);\n",STATIC_CANVAS,int_data[0],int_data[1],font_size,font_family,font_color,stroke_opacity,temp,use_rotate,angle,use_translate,translate_x,translate_y);
1390
                    add_to_buffer(tmp_buffer);
1387
                    add_to_buffer(tmp_buffer);
1391
                    break;
1388
                    break;
1392
                    default:break;
1389
                    default:break;
1393
                }
1390
                }
1394
            }
1391
            }
1395
            reset();
1392
            reset();
1396
            break;
1393
            break;
1397
        case FONTFAMILY:
1394
        case FONTFAMILY:
1398
        /*
1395
        /*
1399
         @ fontfamily font_description
1396
         @ fontfamily font_description
1400
         @ set the font family; for browsers that support it
1397
         @ set the font family; for browsers that support it
1401
         @ font_description: Ariel ,Courier, Helvetica etc
1398
         @ font_description: Ariel ,Courier, Helvetica etc
1402
         @ in case commands<br /> 'string color,x,y,the string'<br /> 'stringup color,x,y,rotation,the string'<br />fontfamily can be something like:<br />italic 34px Ariel
1399
         @ in case commands<br /> 'string color,x,y,the string'<br /> 'stringup color,x,y,rotation,the string'<br />fontfamily can be something like:<br />italic 34px Ariel
1403
         @ use correct syntax : 'font style' 'font size'px 'fontfamily'
1400
         @ use correct syntax : 'font style' 'font size'px 'fontfamily'
1404
        */
1401
        */
1405
            font_family = get_string(infile,1);
1402
            font_family = get_string(infile,1);
1406
            break;
1403
            break;
1407
        case STRINGUP:
1404
        case STRINGUP:
1408
        /*
1405
        /*
1409
         @ stringup color,x,y,rotation_degrees,the text string
1406
         @ stringup color,x,y,rotation_degrees,the text string
1410
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1407
         @ can <b>not</b> be set "onclick" or "drag xy" (because of translaton matrix...mouse incompatible)
1411
         @ unicode supported: stringup red,0,0,45,\\u2232
1408
         @ unicode supported: stringup red,0,0,45,\\u2232
1412
         @ use a command like 'fontfamily bold 34px Courier' <br />to set fonts on browser that support font change
1409
         @ use a command like 'fontfamily bold 34px Courier' <br />to set fonts on browser that support font change
1413
 
1410
 
1414
        */
1411
        */
1415
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}   /* can not be added to shape library : rotate / mouse issues */
1412
            if( js_function[DRAW_TEXTS] != 1 ){ js_function[DRAW_TEXTS] = 1;}   /* can not be added to shape library : rotate / mouse issues */
1416
            for(i=0;i<6;i++){
1413
            for(i=0;i<6;i++){
1417
                switch(i){
1414
                switch(i){
1418
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1415
                    case 0: font_color = get_color(infile,0);break;/* name or hex color */
1419
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1416
                    case 1: int_data[0] = x2px(get_real(infile,0));break; /* x */
1420
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
1417
                    case 2: int_data[1] = y2px(get_real(infile,0));break; /* y */
1421
                    case 3: double_data[0] = get_real(infile,0);break;/* rotation */
1418
                    case 3: double_data[0] = get_real(infile,0);break;/* rotation */
1422
                    case 4: decimals = find_number_of_digits(precision);
1419
                    case 4: decimals = find_number_of_digits(precision);
Line 1430... Line 1427...
1430
                }
1427
                }
1431
            }
1428
            }
1432
            reset();
1429
            reset();
1433
            break;
1430
            break;
1434
        case STRING:
1431
        case STRING:
1435
        /*
1432
        /*
1436
         @ string color,x,y,the text string
1433
         @ string color,x,y,the text string
1437
         @ may be set "onclick" or "drag xy"
1434
         @ may be set "onclick" or "drag xy"
1438
         @ unicode supported: string red,0,0,\\u2232
1435
         @ unicode supported: string red,0,0,\\u2232
1439
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1436
         @ use a command like 'fontfamily italic 24px Ariel' <br />to set fonts on browser that support font change
1440
        */
1437
        */
1441
            for(i=0;i<5;i++){
1438
            for(i=0;i<5;i++){
1442
                switch(i){
1439
                switch(i){
1443
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1440
                    case 0: stroke_color = get_color(infile,0);break;/* name or hex color */
1444
                    case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/
1441
                    case 1: double_data[0] = get_real(infile,0);break; /* x in xrange*/
Line 1454... Line 1451...
1454
            }
1451
            }
1455
            break;
1452
            break;
1456
        case MATHML:
1453
        case MATHML:
1457
        /*
1454
        /*
1458
        @ mathml x1,y1,x2,y2,mathml_string
1455
        @ mathml x1,y1,x2,y2,mathml_string
1459
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1456
        @ mathml will be displayed in a rectangle left top (x1:y1) , right bottom (x2:y2)
1460
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1457
        @ can be set onclick <br />(however dragging is not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1461
        @ 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();"
1458
        @ 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();"
1462
        @ 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....
1459
        @ 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....
1463
 
1460
       
1464
        */
1461
        */
1465
            if( js_function[DRAW_XML] != 1 ){ js_function[DRAW_XML] = 1;}
1462
            if( js_function[DRAW_XML] != 1 ){ js_function[DRAW_XML] = 1;}
1466
            for(i=0;i<5;i++){
1463
            for(i=0;i<5;i++){
1467
                switch(i){
1464
                switch(i){
1468
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1465
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1469
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1466
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1470
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1467
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1471
                    case 3: int_data[3]=y2px(get_real(infile,0)) - int_data[1];break; /* height in x/y-range coord system  -> pixel height */
1468
                    case 3: int_data[3]=y2px(get_real(infile,0)) - int_data[1];break; /* height in x/y-range coord system  -> pixel height */
1472
                    case 4: decimals = find_number_of_digits(precision);
1469
                    case 4: decimals = find_number_of_digits(precision);
1473
                            if(onclick == 1 ){ onclick = click_cnt;click_cnt++;}
1470
                            if(onclick == 1 ){ onclick = click_cnt;click_cnt++;}
1474
                            temp = get_string(infile,1);
1471
                            temp = get_string(infile,1);
1475
                            if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","'"); }
1472
                            if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","'"); }
1476
                            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);
1473
                            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);
1477
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1474
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1478
                            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);
1475
                            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);
1479
                            add_to_buffer(tmp_buffer);
1476
                            add_to_buffer(tmp_buffer);
1480
                            /*
1477
                            /*
1481
                             in case inputs are present , trigger adding the read_mathml()
1478
                             in case inputs are present , trigger adding the read_mathml()
1482
                             if no other reply_format is defined
1479
                             if no other reply_format is defined
1483
                             note: all other reply types will include a reading of elements with id='mathml'+p)
1480
                             note: all other reply types will include a reading of elements with id='mathml'+p)
1484
                             */
1481
                             */
1485
                            if(strstr(temp,"mathml0") != NULL){
1482
                            if(strstr(temp,"mathml0") != NULL){
1486
                             if(reply_format < 1 ){reply_format = 16;} /* no other reply type is defined */
1483
                             if(reply_format < 1 ){reply_format = 16;} /* no other reply type is defined */
1487
                            }
1484
                            }
1488
                            break;
1485
                            break;
1489
                    default:break;
1486
                    default:break;
1490
                }
1487
                }
1491
            }
1488
            }
1492
            reset();
1489
            reset();
1493
            break;
1490
            break;
1494
        case HTTP:
1491
        case HTTP:
1495
        /*
1492
        /*
1496
         @http x1,y1,x2,y2,http://some_adress.com
1493
         @http x1,y1,x2,y2,http://some_adress.com
1497
         @an active html-page will be displayed in an "iframe" rectangle left top (x1:y1) , right bottom (x2:y2)
1494
         @an active html-page will be displayed in an "iframe" rectangle left top (x1:y1) , right bottom (x2:y2)
1498
         @do not use interactivity (or mouse) if the mouse needs to be active in the iframe
1495
         @do not use interactivity (or mouse) if the mouse needs to be active in the iframe
1499
         @can not be 'set onclick' or 'drag xy'
1496
         @can not be 'set onclick' or 'drag xy'
1500
        */
1497
        */
1501
            if( js_function[DRAW_HTTP] != 1 ){ js_function[DRAW_HTTP] = 1;}
1498
            if( js_function[DRAW_HTTP] != 1 ){ js_function[DRAW_HTTP] = 1;}    
1502
            for(i=0;i<5;i++){
1499
            for(i=0;i<5;i++){
1503
                switch(i){
1500
                switch(i){
1504
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1501
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in x/y-range coord system -> pixel width */
1505
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1502
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in x/y-range coord system  -> pixel height */
1506
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
1503
                    case 2: int_data[2]=x2px(get_real(infile,0)) - int_data[0];break; /* width in x/y-range coord system -> pixel width */
Line 1516... Line 1513...
1516
                }
1513
                }
1517
            }
1514
            }
1518
            reset();
1515
            reset();
1519
            break;
1516
            break;
1520
        case HTML:
1517
        case HTML:
1521
        /*
1518
        /*
1522
         @ html x1,y1,x2,y2,html_string
1519
         @ html x1,y1,x2,y2,html_string
1523
         @ all tags are allowed
1520
         @ all tags are allowed
1524
         @ can be set onclick <br />(dragging not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1521
         @ can be set onclick <br />(dragging not supported)<br />javascript:read_dragdrop(); will return click number of mathml-object
1525
         @ 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.
1522
         @ 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.
1526
 
1523
         
1527
         note: uses the same code as 'mathml'
1524
         note: uses the same code as 'mathml'
1528
        */
1525
        */
1529
            break;
1526
            break;
1530
        case X_AXIS_STRINGS:
1527
        case X_AXIS_STRINGS:
1531
        /*
1528
        /*
1532
         @ xaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1529
         @ xaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1533
         @ xaxistext num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1530
         @ xaxistext num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
1534
         @ use these x-axis values in stead of default xmin...xmax
1531
         @ use these x-axis values in stead of default xmin...xmax
1535
         @ use command "fontcolor", "fontsize" , "fontfamily" to adjust font <br />defaults: black,12,Ariel
1532
         @ use command "fontcolor", "fontsize" , "fontfamily" to adjust font <br />defaults: black,12,Ariel
1536
         @ if the 'x-axis words' are to big amd will overlap, a simple alternating offset will be applied
1533
         @ if the 'x-axis words' are to big amd will overlap, a simple alternating offset will be applied
1537
         @ example:<br />size 400,400<br />xrange 0,13<br />yrange -100,500<br />axis<br />xaxis 1:january:2:february:3:march:5:may:6:june:7:july:8:august:9:september:10:october:11:november:12:december<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid 1,100,grey,1,4,6,grey
1534
         @ example:<br />size 400,400<br />xrange 0,13<br />yrange -100,500<br />axis<br />xaxis 1:january:2:february:3:march:5:may:6:june:7:july:8:august:9:september:10:october:11:november:12:december<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid 1,100,grey,1,4,6,grey
1538
         @ example:<br />size 400,400<br />xrange -5*pi,5*pi<br />yrange -100,500<br />axis<br />xaxis -4*pi:-4\\u03c0:-3*pi:-3\\u03c0:-2*pi:-2\\u03c0:-1*pi:-\\u03c0:0:0:pi:\\u03c0:2*pi:2\\u03c01:3*pi:3\\u03c0:4*pi:4\\u03c0<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid pi,1,grey,1,3,6,grey
1535
         @ example:<br />size 400,400<br />xrange -5*pi,5*pi<br />yrange -100,500<br />axis<br />xaxis -4*pi:-4\\u03c0:-3*pi:-3\\u03c0:-2*pi:-2\\u03c0:-1*pi:-\\u03c0:0:0:pi:\\u03c0:2*pi:2\\u03c01:3*pi:3\\u03c0:4*pi:4\\u03c0<br />#'xmajor' steps should be synchronised with numbers eg. "1" in this example<br />grid pi,1,grey,1,3,6,grey
1539
        */
1536
        */
1540
            temp = get_string(infile,1);
1537
            temp = get_string(infile,1);
1541
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1538
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1542
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1539
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1543
            fprintf(js_include_file,"x_strings = [\"%s\"];\n ",temp);
1540
            fprintf(js_include_file,"x_strings = [\"%s\"];\n ",temp);
1544
            use_axis_numbering = 1;
1541
            use_axis_numbering = 1;
1545
            break;
1542
            break;
1546
        case Y_AXIS_STRINGS:
1543
        case Y_AXIS_STRINGS:
Line 1555... Line 1552...
1555
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1552
            if( strstr(temp,":") != 0 ){ temp = str_replace(temp,":","\",\"");}
1556
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1553
            if( strstr(temp,"pi") != 0 ){ temp = str_replace(temp,"pi","(3.1415927)");}/* we need to replace pi for javascript y-value*/
1557
            fprintf(js_include_file,"y_strings = [\"%s\"];\n ",temp);
1554
            fprintf(js_include_file,"y_strings = [\"%s\"];\n ",temp);
1558
            use_axis_numbering = 1;
1555
            use_axis_numbering = 1;
1559
            break;
1556
            break;
1560
 
1557
         
1561
        case AXIS_NUMBERING:
1558
        case AXIS_NUMBERING:
1562
        /*
1559
        /*
1563
            @ axisnumbering
1560
            @ axisnumbering
1564
            @ keyword, no aguments required
1561
            @ keyword, no aguments required
1565
        */
1562
        */
1566
            use_axis_numbering = 1;
1563
            use_axis_numbering = 1;
1567
            break;
1564
            break;
1568
        case AXIS:
1565
        case AXIS:
Line 1578... Line 1575...
1578
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
1575
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
1579
         @ primitive implementation of a 'broken scale' graph...
1576
         @ primitive implementation of a 'broken scale' graph...
1580
         @ not very versatile.
1577
         @ not very versatile.
1581
         @ 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
1578
         @ 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
1582
        */
1579
        */
1583
            if( js_function[DRAW_SGRAPH] != 1 ){ js_function[DRAW_SGRAPH] = 1;}
1580
            if( js_function[DRAW_SGRAPH] != 1 ){ js_function[DRAW_SGRAPH] = 1;}
1584
            for(i = 0 ; i < 8 ;i++){
1581
            for(i = 0 ; i < 8 ;i++){
1585
                switch(i){
1582
                switch(i){
1586
                    case 0:double_data[0] = get_real(infile,0);break;
1583
                    case 0:double_data[0] = get_real(infile,0);break;
1587
                    case 1:double_data[1] = get_real(infile,0);break;
1584
                    case 1:double_data[1] = get_real(infile,0);break;
1588
                    case 2:double_data[2] = get_real(infile,0);break;
1585
                    case 2:double_data[2] = get_real(infile,0);break;
Line 1679... Line 1676...
1679
        /*
1676
        /*
1680
        @ killaffine
1677
        @ killaffine
1681
        @ keyword : resets the transformation matrix to 1,0,0,1,0,0
1678
        @ keyword : resets the transformation matrix to 1,0,0,1,0,0
1682
        */
1679
        */
1683
            use_affine = FALSE;
1680
            use_affine = FALSE;
1684
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");
1681
            snprintf(affine_matrix,14,"[1,0,0,1,0,0]");    
1685
            break;
1682
            break;
1686
        case AFFINE:
1683
        case AFFINE:
1687
        /*
1684
        /*
1688
         @affine a,b,c,d,tx,ty
1685
         @affine a,b,c,d,tx,ty
1689
         @ defines a transformation matrix for subsequent objects
1686
         @ defines a transformation matrix for subsequent objects
1690
         @ use keyword 'killaffine' to end the transformation
1687
         @ use keyword 'killaffine' to end the transformation
1691
         @ note 1: only 'draggable' / 'noclick' objects can be transformed.
1688
         @ note 1: only 'draggable' / 'noclick' objects can be transformed.
1692
         @ note 2: do not use 'onclick' or 'drag xy' with tranformation objects : the mouse coordinates do not get transformed (yet)
1689
         @ note 2: do not use 'onclick' or 'drag xy' with tranformation objects : the mouse coordinates do not get transformed (yet)
1693
         @ note 3: no matrix operations on the transformation matrix implemented (yet)
1690
         @ note 3: no matrix operations on the transformation matrix implemented (yet)
1694
         @ a : Scales the drawings horizontally
1691
         @ a : Scales the drawings horizontally
Line 1707... Line 1704...
1707
                    case 4: int_data[0] = (int)(get_real(infile,0));break;
1704
                    case 4: int_data[0] = (int)(get_real(infile,0));break;
1708
                    case 5: int_data[1] = (int)(get_real(infile,1));
1705
                    case 5: int_data[1] = (int)(get_real(infile,1));
1709
                        use_affine = TRUE;
1706
                        use_affine = TRUE;
1710
                        string_length = snprintf(NULL,0,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);
1707
                        string_length = snprintf(NULL,0,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);
1711
                        check_string_length(string_length);affine_matrix = my_newmem(string_length+1);
1708
                        check_string_length(string_length);affine_matrix = my_newmem(string_length+1);
1712
                        snprintf(affine_matrix,string_length,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);
1709
                        snprintf(affine_matrix,string_length,"[%.2f,%.2f,%.2f,%.2f,%d,%d] ",double_data[0],double_data[1],double_data[2],double_data[3],int_data[0],int_data[1]);    
1713
                    break;
1710
                    break;
1714
                    default: break;
1711
                    default: break;
1715
                }
1712
                }
1716
            }
1713
            }
1717
        break;
1714
        break;
Line 1737... Line 1734...
1737
        */
1734
        */
1738
            use_dashed = TRUE;
1735
            use_dashed = TRUE;
1739
            break;
1736
            break;
1740
        case FILLED:
1737
        case FILLED:
1741
        /*
1738
        /*
1742
        @ keyword "filled"
1739
        @ keyword "filled"
1743
        @ the next 'fillable' object (only) will be filled
1740
        @ the next 'fillable' object (only) will be filled
1744
        @ use command "fillcolor color" to set fillcolor
1741
        @ use command "fillcolor color" to set fillcolor
1745
        @ use command "opacity 0-255,0-255" to set stroke and fill-opacity
1742
        @ use command "opacity 0-255,0-255" to set stroke and fill-opacity
1746
        @ 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 !
1743
        @ 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 !
1747
        */
1744
        */
1748
            use_filled = TRUE;
1745
            use_filled = TRUE;
Line 1767... Line 1764...
1767
        @ strokecolor colorname or #hex
1764
        @ strokecolor colorname or #hex
1768
        @ to be used for commands that do not supply a color argument (like command 'linegraph')
1765
        @ to be used for commands that do not supply a color argument (like command 'linegraph')
1769
        */
1766
        */
1770
            stroke_color = get_color(infile,1);
1767
            stroke_color = get_color(infile,1);
1771
            break;
1768
            break;
1772
        case BGIMAGE:
1769
        case BGIMAGE:
1773
        /*
1770
        /*
1774
         @bgimage image_location
1771
         @bgimage image_location
1775
         @use an image as background .<br />(we use the background of 'canvas_div' )
1772
         @use an image as background .<br />(we use the background of 'canvas_div' )
1776
         @the background image will be resized to match "width = xsize" and "height = ysize"
1773
         @the background image will be resized to match "width = xsize" and "height = ysize"
1777
        */
1774
        */
1778
        URL = get_string(infile,1);
1775
        URL = get_string(infile,1);
1779
        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);
1776
        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);
1780
            break;
1777
            break;
1781
        case BGCOLOR:
1778
        case BGCOLOR:
1782
        /*
1779
        /*
1783
         @bgcolor colorname or #hex
1780
         @bgcolor colorname or #hex
1784
         @use this color as background of the "div" containing the canvas(es)
1781
         @use this color as background of the "div" containing the canvas(es)
1785
        */
1782
        */
1786
        /* [255,255,255]*/
1783
        /* [255,255,255]*/
Line 1801... Line 1798...
1801
        case COPY:
1798
        case COPY:
1802
        /*
1799
        /*
1803
        @ copy x,y,x1,y1,x2,y2,[filename URL]
1800
        @ copy x,y,x1,y1,x2,y2,[filename URL]
1804
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y) in x/y-range
1801
        @ Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y) in x/y-range
1805
        @ If x1=y1=x2=y2=-1, the whole [filename URL] is copied.
1802
        @ If x1=y1=x2=y2=-1, the whole [filename URL] is copied.
1806
        @ [filename] is the URL of the image
1803
        @ [filename] is the URL of the image   
1807
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1804
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1808
        @ 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
1805
        @ 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
1809
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1806
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1810
 
1807
 
1811
        context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1808
        context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1812
        draw_external_image(canvas_type,URL,sx,sy,swidth,sheight,x,y,width,height,drag_drop){
1809
        draw_external_image(canvas_type,URL,sx,sy,swidth,sheight,x,y,width,height,drag_drop){
1813
        */
1810
        */
1814
            for(i = 0 ; i<7;i++){
1811
            for(i = 0 ; i<7;i++){
Line 1825... Line 1822...
1825
                            if( drag_type > -1 ){
1822
                            if( drag_type > -1 ){
1826
                                if( js_function[DRAG_EXTERNAL_IMAGE] != 1 ){ js_function[DRAG_EXTERNAL_IMAGE] = 1;}
1823
                                if( js_function[DRAG_EXTERNAL_IMAGE] != 1 ){ js_function[DRAG_EXTERNAL_IMAGE] = 1;}
1827
                                if(reply_format < 1 ){reply_format = 20;}
1824
                                if(reply_format < 1 ){reply_format = 20;}
1828
                                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);
1825
                                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);
1829
                                check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1826
                                check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1830
                                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);
1827
                                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);                       
1831
                                drag_type = -1;
1828
                                drag_type = -1;
1832
                                ext_img_cnt++;
1829
                                ext_img_cnt++;
1833
                            }
1830
                            }
1834
                            else
1831
                            else
1835
                            {
1832
                            {
Line 1851... Line 1848...
1851
/*
1848
/*
1852
context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1849
context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);
1853
img     Specifies the image, canvas, or video element to use
1850
img     Specifies the image, canvas, or video element to use
1854
sx      The x coordinate where to start clipping : x1 = int_data[0]
1851
sx      The x coordinate where to start clipping : x1 = int_data[0]
1855
sy      The y coordinate where to start clipping : x2 = int_data[1]
1852
sy      The y coordinate where to start clipping : x2 = int_data[1]
1856
swidth  The width of the clipped image : int_data[2] - int_data[0]
1853
swidth  The width of the clipped image : int_data[2] - int_data[0]
1857
sheight The height of the clipped image : int_data[3] - int_data[1]
1854
sheight The height of the clipped image : int_data[3] - int_data[1]
1858
x       The x coordinate where to place the image on the canvas : dx1 = int_data[4]
1855
x       The x coordinate where to place the image on the canvas : dx1 = int_data[4]
1859
y       The y coordinate where to place the image on the canvas : dy1 = int_data[5]
1856
y       The y coordinate where to place the image on the canvas : dy1 = int_data[5]
1860
width   The width of the image to use (stretch or reduce the image) : dx2 - dx1 = int_data[6]
1857
width   The width of the image to use (stretch or reduce the image) : dx2 - dx1 = int_data[6]
1861
height  The height of the image to use (stretch or reduce the image) : dy2 - dy1 = int_data[7]
1858
height  The height of the image to use (stretch or reduce the image) : dy2 - dy1 = int_data[7]
1862
*/
1859
*/
1863
        case COPYRESIZED:
1860
        case COPYRESIZED:
1864
        /*
1861
        /*
1865
        @ copyresized x1,y2,x2,y2,dx1,dy1,dx2,dy2,image_file_url
1862
        @ copyresized x1,y2,x2,y2,dx1,dy1,dx2,dy2,image_file_url
1866
        @ 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
1863
        @ 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
1867
        @ If x1=y1=x2=y2=-1, the whole [filename / URL ] is copied and resized.
1864
        @ If x1=y1=x2=y2=-1, the whole [filename / URL ] is copied and resized.
1868
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1865
        @ URL is normal URL of network reachable image file location<br />(eg special url for 'classexo' not -yet- implemented)
1869
        @ 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
1866
        @ 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
1870
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1867
        @ if you want to draw / userdraw  on an "imported" image, make sure it is transparent.<br />for example GNUPlot: set terminal gif transparent
1871
        */
1868
        */
1872
            for(i = 0 ; i<9;i++){
1869
            for(i = 0 ; i<9;i++){
1873
                switch(i){
1870
                switch(i){
1874
                    case 0: int_data[0] = (int)(get_real(infile,0));break; /* x1 */
1871
                    case 0: int_data[0] = (int)(get_real(infile,0));break; /* x1 */
1875
                    case 1: int_data[1] = (int)(get_real(infile,0));break; /* y1 */
1872
                    case 1: int_data[1] = (int)(get_real(infile,0));break; /* y1 */
Line 1913... Line 1910...
1913
        @ example: inputstyle color:blue;font-weight:bold;font-style:italic;font-size:16pt
1910
        @ example: inputstyle color:blue;font-weight:bold;font-style:italic;font-size:16pt
1914
        */
1911
        */
1915
            input_style = get_string(infile,1);
1912
            input_style = get_string(infile,1);
1916
            break;
1913
            break;
1917
        case INPUT:
1914
        case INPUT:
1918
        /*
1915
        /*
1919
         @ input x,y,size,editable,value
1916
         @ input x,y,size,editable,value
1920
         @ to set inputfield "readonly", use editable = 0
1917
         @ to set inputfield "readonly", use editable = 0
1921
         @ only active inputfields (editable = 1) will be read with read_canvas();
1918
         @ only active inputfields (editable = 1) will be read with read_canvas();
1922
         @ may be further controlled by "inputstyle" (inputcss is not yet implemented...)
1919
         @ may be further controlled by "inputstyle" (inputcss is not yet implemented...)
1923
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1920
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1924
        */
1921
        */
1925
        if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}
1922
        if( js_function[DRAW_INPUTS] != 1 ){ js_function[DRAW_INPUTS] = 1;}    
1926
            for(i = 0 ; i<5;i++){
1923
            for(i = 0 ; i<5;i++){
1927
                switch(i){
1924
                switch(i){
1928
                    case 0: int_data[0]=x2px(get_real(infile,0));break;/* x in px */
1925
                    case 0: int_data[0]=x2px(get_real(infile,0));break;/* x in px */
1929
                    case 1: int_data[1]=y2px(get_real(infile,0));break;/* y in px */
1926
                    case 1: int_data[1]=y2px(get_real(infile,0));break;/* y in px */
1930
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break; /* size */
1927
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break; /* size */
1931
                    case 3: if( get_real(infile,1) >0){int_data[3] = 1;}else{int_data[3] = 0;};break; /* readonly */
1928
                    case 3: if( get_real(infile,1) >0){int_data[3] = 1;}else{int_data[3] = 0;};break; /* readonly */
1932
                    case 4:
1929
                    case 4:
1933
                            temp = get_string_argument(infile,1);
1930
                            temp = get_string_argument(infile,1);
1934
                            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);
1931
                            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);
1935
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1932
                            check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
1936
                            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);
1933
                            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);
1937
                            add_to_buffer(tmp_buffer);
1934
                            add_to_buffer(tmp_buffer);
Line 1941... Line 1938...
1941
            }
1938
            }
1942
            if(reply_format < 1 ){reply_format = 15;}
1939
            if(reply_format < 1 ){reply_format = 15;}
1943
            reset();
1940
            reset();
1944
            break;
1941
            break;
1945
        case TEXTAREA:
1942
        case TEXTAREA:
1946
        /*
1943
        /*
1947
         @ textarea x,y,cols,rows,readonly,value
1944
         @ textarea x,y,cols,rows,readonly,value
1948
         @ may be further controlled by "inputstyle"
1945
         @ may be further controlled by "inputstyle"
1949
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1946
         @ if mathml inputfields are present and / or some userdraw is performed, these data will NOT be send as well (javascript:read_canvas();)
1950
        */
1947
        */
1951
            if( js_function[DRAW_TEXTAREAS] != 1 ){ js_function[DRAW_TEXTAREAS] = 1;}
1948
            if( js_function[DRAW_TEXTAREAS] != 1 ){ js_function[DRAW_TEXTAREAS] = 1;}  
1952
            for(i = 0 ; i<6;i++){
1949
            for(i = 0 ; i<6;i++){
1953
                switch(i){
1950
                switch(i){
1954
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in px */
1951
                    case 0: int_data[0]=x2px(get_real(infile,0));break; /* x in px */
1955
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in px */
1952
                    case 1: int_data[1]=y2px(get_real(infile,0));break; /* y in px */
1956
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break;/* cols */
1953
                    case 2: int_data[2]=abs( (int)(get_real(infile,0)));break;/* cols */
Line 1976... Line 1973...
1976
        */
1973
        */
1977
            precision = (int) (get_real(infile,1));
1974
            precision = (int) (get_real(infile,1));
1978
            break;
1975
            break;
1979
        case SETLIMITS:
1976
        case SETLIMITS:
1980
        /*
1977
        /*
1981
            @setlimits
1978
            @setlimits
1982
            @keyword : if set, it will produce 4 inputfields for 'xmin,xmax,ymin,ymax' and an 'ok' button
1979
            @keyword : if set, it will produce 4 inputfields for 'xmin,xmax,ymin,ymax' and an 'ok' button
1983
            @may be used for inputfield based zooming / panning
1980
            @may be used for inputfield based zooming / panning
1984
            @note:the input value will not be checked on validity
1981
            @note:the input value will not be checked on validity
1985
        */
1982
        */
1986
            add_setlimits(js_include_file,canvas_root_id);
1983
            add_setlimits(js_include_file,canvas_root_id);
1987
            /* add_setlimits provides 'fprintf(js_include_file,"use_pan_and_zoom = 1;");' */
1984
            /* add_setlimits provides 'fprintf(js_include_file,"use_pan_and_zoom = 1;");' */
1988
            use_pan_and_zoom = TRUE;
1985
            use_pan_and_zoom = TRUE;
1989
            done = TRUE;
1986
            done = TRUE;
Line 1993... Line 1990...
1993
         @ zoom button_color
1990
         @ zoom button_color
1994
         @ introduce a controlpanel at the lower right corner
1991
         @ introduce a controlpanel at the lower right corner
1995
         @ 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
1992
         @ 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
1996
         @ the 'x' symbol will do a 'location.reload' of the page, and thus reset all canvas drawings.
1993
         @ the 'x' symbol will do a 'location.reload' of the page, and thus reset all canvas drawings.
1997
         @ choose an appropriate colour, so the small 'x,arrows,-,+' are clearly visible
1994
         @ choose an appropriate colour, so the small 'x,arrows,-,+' are clearly visible
1998
         @ command 'opacity' may be used to set stroke_opacity of 'buttons
1995
         @ command 'opacity' may be used to set stroke_opacity of 'buttons
1999
         @ NOTE: only objects that may be set draggable / clickable will be zoomed / panned
1996
         @ NOTE: only objects that may be set draggable / clickable will be zoomed / panned
2000
         @ 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 !!
1997
         @ 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 !!
2001
        */
1998
        */
2002
            fprintf(js_include_file,"use_pan_and_zoom = 1;");
1999
            fprintf(js_include_file,"use_pan_and_zoom = 1;");
2003
            use_pan_and_zoom = TRUE;
2000
            use_pan_and_zoom = TRUE;
Line 2013... Line 2010...
2013
        case ONCLICK:
2010
        case ONCLICK:
2014
        /*
2011
        /*
2015
         @ onclick
2012
         @ onclick
2016
         @ keyword, no arguments
2013
         @ keyword, no arguments
2017
         @ if the next object is clicked, it's 'object sequence number' in fly script is returned <br /> by javascript:read_canvas();
2014
         @ if the next object is clicked, it's 'object sequence number' in fly script is returned <br /> by javascript:read_canvas();
2018
         @ Line based object will show an increase in linewidth<br />Font based objects will show the text in 'bold' when clicked.
2015
         @ Line based object will show an increase in linewidth<br />Font based objects will show the text in 'bold' when clicked.
2019
         @ NOTE: not all objects  may be set clickable
2016
         @ NOTE: not all objects  may be set clickable
2020
        */
2017
        */
2021
 
2018
           
2022
            onclick = 1;
2019
            onclick = 1;
2023
            break;
2020
            break;
2024
        case DRAG:
2021
        case DRAG:
2025
        /*
2022
        /*
2026
         @ drag [x][y][xy]
2023
         @ drag [x][y][xy]
2027
         @ the next object will be draggable in x / y / xy direction
2024
         @ the next object will be draggable in x / y / xy direction
2028
         @ the displacement can be read by 'javascript:read_dragdrop();'
2025
         @ the displacement can be read by 'javascript:read_dragdrop();'
2029
         @ 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.
2026
         @ 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.
2030
         @ 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 !!
2027
         @ 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 !!
2031
        */
2028
        */
2032
            temp = get_string(infile,1);
2029
            temp = get_string(infile,1);
2033
            if(strstr(temp,"xy") != NULL ){
2030
            if(strstr(temp,"xy") != NULL ){
2034
                drag_type = 0;
2031
                drag_type = 0;
2035
            }
2032
            }
2036
            else
2033
            else
2037
            {
2034
            {
2038
                if(strstr(temp,"x") != NULL ){
2035
                if(strstr(temp,"x") != NULL ){
2039
                    drag_type = 1;
2036
                    drag_type = 1;
2040
                }
2037
                }
2041
                else
2038
                else
2042
                {
2039
                {
2043
                    drag_type = 2;
2040
                    drag_type = 2;
Line 2097... Line 2094...
2097
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y in x/y-range coord system  -> pixel */
2094
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y in x/y-range coord system  -> pixel */
2098
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* pixel width */
2095
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* pixel width */
2099
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* height pixel height */
2096
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* height pixel height */
2100
                    case 4: int_data[4] = (int) (get_real(infile,0)); if(int_data[4] != TRUE){int_data[4] = FALSE;} break; /* loop boolean */
2097
                    case 4: int_data[4] = (int) (get_real(infile,0)); if(int_data[4] != TRUE){int_data[4] = FALSE;} break; /* loop boolean */
2101
                    case 5: int_data[5] = (int) (get_real(infile,0)); if(int_data[5] != TRUE){int_data[5] = FALSE;} break; /* visible boolean */
2098
                    case 5: int_data[5] = (int) (get_real(infile,0)); if(int_data[5] != TRUE){int_data[5] = FALSE;} break; /* visible boolean */
2102
                    case 6:
2099
                    case 6:
2103
                    temp = get_string(infile,1);
2100
                    temp = get_string(infile,1);
2104
                    if( strstr(temp,".mp3") != 0 ){ temp = str_replace(temp,".mp3","");}
2101
                    if( strstr(temp,".mp3") != 0 ){ temp = str_replace(temp,".mp3","");}
2105
                    if( strstr(temp,".ogg") != 0 ){ temp = str_replace(temp,".ogg","");}
2102
                    if( strstr(temp,".ogg") != 0 ){ temp = str_replace(temp,".ogg","");}
2106
                    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);
2103
                    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);
2107
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2104
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
Line 2155... Line 2152...
2155
                    case 4: stroke_color = get_color(infile,1);
2152
                    case 4: stroke_color = get_color(infile,1);
2156
                    /* draw_hatchfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2153
                    /* draw_hatchfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2157
                    string_length = snprintf(NULL,0,  "draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2154
                    string_length = snprintf(NULL,0,  "draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2158
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2155
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2159
                    snprintf(tmp_buffer,string_length,"draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2156
                    snprintf(tmp_buffer,string_length,"draw_hatchfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2160
                    add_to_buffer(tmp_buffer);
2157
                    add_to_buffer(tmp_buffer);
2161
                    break;
2158
                    break;
2162
                    default:break;
2159
                    default:break;
2163
                }
2160
                }
2164
            }
2161
            }
2165
            reset();
2162
            reset();
2166
        break;
2163
        break;
2167
        case DIAMONDFILL:
2164
        case DIAMONDFILL:
2168
        /*
2165
        /*
2169
        @ diamondfill x0,y0,dx,dy,color
2166
        @ diamondfill x0,y0,dx,dy,color
2170
        @ x0,y0 in xrange / yrange
2167
        @ x0,y0 in xrange / yrange
2171
        @ distances dx,dy in pixels
2168
        @ distances dx,dy in pixels
2172
        */
2169
        */
2173
            if( js_function[DRAW_DIAMONDFILL] != 1 ){ js_function[DRAW_DIAMONDFILL] = 1;}
2170
            if( js_function[DRAW_DIAMONDFILL] != 1 ){ js_function[DRAW_DIAMONDFILL] = 1;}
2174
            for(i=0;i<5;i++){
2171
            for(i=0;i<5;i++){
2175
                switch(i){
2172
                switch(i){
2176
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2173
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2177
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2174
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2178
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2175
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2179
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
2176
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
2180
                    case 4: stroke_color = get_color(infile,1);
2177
                    case 4: stroke_color = get_color(infile,1);
2181
                    /* draw_hatchfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2178
                    /* draw_hatchfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2182
                    string_length = snprintf(NULL,0,  "draw_diamondfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2179
                    string_length = snprintf(NULL,0,  "draw_diamondfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2183
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2180
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2184
                    snprintf(tmp_buffer,string_length,"draw_diamondfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2181
                    snprintf(tmp_buffer,string_length,"draw_diamondfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2185
                    add_to_buffer(tmp_buffer);
2182
                    add_to_buffer(tmp_buffer);
2186
                    break;
2183
                    break;
2187
                    default:break;
2184
                    default:break;
2188
                }
2185
                }
2189
            }
2186
            }
2190
            reset();
2187
            reset();
2191
        break;
2188
        break;
2192
        case GRIDFILL:
2189
        case GRIDFILL:
2193
        /*
2190
        /*
Line 2203... Line 2200...
2203
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2200
                    case 2: int_data[2] = (int) (get_real(infile,0)); break; /* dx pixel */
2204
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
2201
                    case 3: int_data[3] = (int) (get_real(infile,0)); break; /* dy pixel*/
2205
                    case 4: stroke_color = get_color(infile,1);
2202
                    case 4: stroke_color = get_color(infile,1);
2206
                    /* draw_gridfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2203
                    /* draw_gridfill(ctx,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize) */
2207
                    string_length = snprintf(NULL,0,  "draw_gridfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2204
                    string_length = snprintf(NULL,0,  "draw_gridfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2208
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2205
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2209
                    snprintf(tmp_buffer,string_length,"draw_gridfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2206
                    snprintf(tmp_buffer,string_length,"draw_gridfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2210
                    add_to_buffer(tmp_buffer);
2207
                    add_to_buffer(tmp_buffer);
2211
                    break;
2208
                    break;
2212
                    default:break;
2209
                    default:break;
2213
                }
2210
                }
Line 2232... Line 2229...
2232
                    /* draw_dotfill(ctx,x0,y0,dx,dy,radius,color,opacity,xsize,ysize) */
2229
                    /* draw_dotfill(ctx,x0,y0,dx,dy,radius,color,opacity,xsize,ysize) */
2233
                    string_length = snprintf(NULL,0,  "draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2230
                    string_length = snprintf(NULL,0,  "draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2234
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2231
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2235
                    snprintf(tmp_buffer,string_length,"draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2232
                    snprintf(tmp_buffer,string_length,"draw_dotfill(%d,%d,%d,%d,%d,%d,\"%s\",%.2f,%d,%d);\n",STATIC_CANVAS,int_data[0],int_data[1],int_data[2],int_data[3],line_width,stroke_color,stroke_opacity,xsize,ysize);
2236
                    add_to_buffer(tmp_buffer);
2233
                    add_to_buffer(tmp_buffer);
2237
                    break;
2234
                    break;
2238
                    default:break;
2235
                    default:break;
2239
                }
2236
                }
2240
            }
2237
            }
2241
            reset();
2238
            reset();
2242
        break;
2239
        break;
2243
        case IMAGEFILL:
2240
        case IMAGEFILL:
2244
        /*
2241
        /*
2245
        @ imagefill dx,dy,image_url
2242
        @ imagefill dx,dy,image_url
2246
        @ The next suitable <b>filled object</b> will be filled with "image_url" tiled
2243
        @ The next suitable <b>filled object</b> will be filled with "image_url" tiled
Line 2265... Line 2262...
2265
            }
2262
            }
2266
        break;
2263
        break;
2267
        case FILLTOBORDER:
2264
        case FILLTOBORDER:
2268
        /*
2265
        /*
2269
        @ filltoborder x,y,bordercolor,color
2266
        @ filltoborder x,y,bordercolor,color
2270
        @ fill the region  of point (x:y) bounded by 'bordercolor' with color 'color'
2267
        @ fill the region  of point (x:y) bounded by 'bordercolor' with color 'color'
2271
        @ any other color will not act as border to the bucket fill
2268
        @ any other color will not act as border to the bucket fill
2272
        @ use this command  after all boundary objects are declared.
2269
        @ use this command  after all boundary objects are declared.
2273
        @ 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..
2270
        @ 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..
2274
        */
2271
        */
2275
            for(i=0 ;i < 4 ; i++){
2272
            for(i=0 ;i < 4 ; i++){
Line 2314... Line 2311...
2314
                           }
2311
                           }
2315
                           decimals = find_number_of_digits(precision);/*floodfill(interaction,x,y,[R,G,B,A]) */
2312
                           decimals = find_number_of_digits(precision);/*floodfill(interaction,x,y,[R,G,B,A]) */
2316
                           string_length = snprintf(NULL,0,  "floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2313
                           string_length = snprintf(NULL,0,  "floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2317
                           check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2314
                           check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2318
                           snprintf(tmp_buffer,string_length,"floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2315
                           snprintf(tmp_buffer,string_length,"floodfill(0,%.*f,%.*f,[%s,%d]);\n",decimals,double_data[0],decimals,double_data[1],fill_color,(int) (fill_opacity/0.0039215));
2319
                           add_to_buffer(tmp_buffer);
2316
                           add_to_buffer(tmp_buffer);
2320
                           break;
2317
                           break;
2321
                    default:break;
2318
                    default:break;
2322
                    }
2319
                    }
2323
                }
2320
                }
2324
        break;
2321
        break;
Line 2423... Line 2420...
2423
        case LEGENDCOLORS:
2420
        case LEGENDCOLORS:
2424
        /*
2421
        /*
2425
        @ legendcolors color1:color2:color3:...:color_n
2422
        @ legendcolors color1:color2:color3:...:color_n
2426
        @ will be used to colour a legend
2423
        @ will be used to colour a legend
2427
        @ make sure the number of colours match the number of legend items
2424
        @ make sure the number of colours match the number of legend items
2428
        @ command 'legend' in case of 'piechart' and 'barchart' will use these colours per default (no need to specify 'legendcolors'
2425
        @ command 'legend' in case of 'piechart' and 'barchart' will use these colours per default (no need to specify 'legendcolors'
2429
        */
2426
        */
2430
            temp = get_string(infile,1);
2427
            temp = get_string(infile,1);
2431
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2428
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2432
            fprintf(js_include_file,"var legendcolors%d = [\"%s\"];",canvas_root_id,temp);
2429
            fprintf(js_include_file,"var legendcolors%d = [\"%s\"];",canvas_root_id,temp);
2433
            break;
2430
            break;
2434
        case LEGEND:
2431
        case LEGEND:
2435
        /*
2432
        /*
2436
        @ legend string1:string2:string3....string_n
2433
        @ legend string1:string2:string3....string_n
2437
        @ will be used to create a legend for a graph
2434
        @ will be used to create a legend for a graph
2438
        @ also see command 'piechart'
2435
        @ also see command 'piechart'  
2439
        */
2436
        */
2440
            temp = get_string(infile,1);
2437
            temp = get_string(infile,1);
2441
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2438
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2442
            fprintf(js_include_file,"var legend%d = [\"%s\"];",canvas_root_id,temp);
2439
            fprintf(js_include_file,"var legend%d = [\"%s\"];",canvas_root_id,temp);
2443
            break;
2440
            break;
2444
        case XLABEL:
2441
        case XLABEL:
2445
        /*
2442
        /*
2446
        @ xlabel some_string
2443
        @ xlabel some_string
2447
        @ will be used to create a label for the x-axis (label is in quadrant I)
2444
        @ will be used to create a label for the x-axis (label is in quadrant I)
2448
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2445
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2449
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2446
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2450
        */
2447
        */
2451
            temp = get_string(infile,1);
2448
            temp = get_string(infile,1);
2452
            fprintf(js_include_file,"var xaxislabel = \"%s\";",temp);
2449
            fprintf(js_include_file,"var xaxislabel = \"%s\";",temp);
2453
            break;
2450
            break;
2454
        case YLABEL:
2451
        case YLABEL:
2455
        /*
2452
        /*
2456
        @ ylabel some_string
2453
        @ ylabel some_string
2457
        @ will be used to create a (vertical) label for the y-axis (label is in quadrant I)
2454
        @ will be used to create a (vertical) label for the y-axis (label is in quadrant I)
2458
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2455
        @ can only be used together with command 'grid'<br />not depending on keywords 'axis' and 'axisnumbering'
2459
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2456
        @ font setting: italic Courier, fontsize will be slightly larger (fontsize + 4)
2460
        */
2457
        */
2461
            temp = get_string(infile,1);
2458
            temp = get_string(infile,1);
2462
            fprintf(js_include_file,"var yaxislabel = \"%s\";",temp);
2459
            fprintf(js_include_file,"var yaxislabel = \"%s\";",temp);
2463
            break;
2460
            break;
2464
        case LINEGRAPH: /* scheme: var linegraph_0 = [ 'stroke_color','line_width','use_dashed' ,'dashtype0','dashtype1','x1','y1',...,'x_n','y_n'];*/
2461
        case LINEGRAPH: /* scheme: var linegraph_0 = [ 'stroke_color','line_width','use_dashed' ,'dashtype0','dashtype1','x1','y1',...,'x_n','y_n'];*/
Line 2469... Line 2466...
2469
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2466
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2470
        @ use command 'legend' to provide an optional legend in right-top-corner
2467
        @ use command 'legend' to provide an optional legend in right-top-corner
2471
        @ also see command 'piechart'
2468
        @ also see command 'piechart'
2472
        @ multiple linegraphs may be used in a single plot
2469
        @ multiple linegraphs may be used in a single plot
2473
        @ <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>
2470
        @ <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>
2474
        */
2471
        */    
2475
            temp = get_string(infile,1);
2472
            temp = get_string(infile,1);
2476
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2473
            if( strstr( temp,":") != 0 ){ temp = str_replace(temp,":","\",\""); }
2477
            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);
2474
            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);
2478
            linegraph_cnt++;
2475
            linegraph_cnt++;
2479
            reset();
2476
            reset();
Line 2532... Line 2529...
2532
                            }
2529
                            }
2533
                     break;
2530
                     break;
2534
                     default: canvas_error("interactive must be set 0,1 or 2");break;
2531
                     default: canvas_error("interactive must be set 0,1 or 2");break;
2535
                }
2532
                }
2536
                break;
2533
                break;
2537
                case 8:
2534
                case 8:
2538
                        temp = get_string(infile,1);
2535
                        temp = get_string(infile,1);
2539
                        if( strstr( temp,",") != 0 ){ temp = str_replace(temp,",","\",\""); }
2536
                        if( strstr( temp,",") != 0 ){ temp = str_replace(temp,",","\",\""); }
2540
                        if( strlen(temp) < 1 ){temp = ",\"\",\"\",\"\",\"\",\"\"";}
2537
                        if( strlen(temp) < 1 ){temp = ",\"\",\"\",\"\",\"\",\"\"";}
2541
                        string_length = snprintf(NULL,0,"clocks%d = new clock(%d,%d,%d,%d,%d,%d,%d,%d,\"%s\");\n",clock_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],int_data[5],int_data[6],int_data[7],temp);
2538
                        string_length = snprintf(NULL,0,"clocks%d = new clock(%d,%d,%d,%d,%d,%d,%d,%d,\"%s\");\n",clock_cnt,int_data[0],int_data[1],int_data[2],int_data[3],int_data[4],int_data[5],int_data[6],int_data[7],temp);
2542
                        check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
2539
                        check_string_length(string_length);tmp_buffer = my_newmem(string_length+1);
Line 2553... Line 2550...
2553
        @ barchart x_1:y_1:color_1:x_2:y_2:color_2:...x_n:y_n:color_n
2550
        @ barchart x_1:y_1:color_1:x_2:y_2:color_2:...x_n:y_n:color_n
2554
        @ will be used to create a legend for bar graph
2551
        @ will be used to create a legend for bar graph
2555
        @ may only to be used together with command 'grid'
2552
        @ may only to be used together with command 'grid'
2556
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2553
        @ can be used together with freestyle x-axis/y-axis texts : see commands 'xaxis' and 'yaxis'
2557
        @ use command 'legend' to provide an optional legend in right-top-corner
2554
        @ use command 'legend' to provide an optional legend in right-top-corner
2558
        @ also see command 'piechart'
2555
        @ also see command 'piechart'  
2559
        */
2556
        */
2560
            temp = get_string(infile,1);
2557
            temp = get_string(infile,1);
2561
            if( strstr( temp,":" ) != 0 ){ temp = str_replace(temp,":","\",\""); }
2558
            if( strstr( temp,":" ) != 0 ){ temp = str_replace(temp,":","\",\""); }
2562
            fprintf(js_include_file,"var barchart%d = [\"%s\"];",canvas_root_id,temp);
2559
            fprintf(js_include_file,"var barchart%d = [\"%s\"];",canvas_root_id,temp);
2563
            reset();
2560
            reset();
Line 2571... Line 2568...
2571
        @ example data+colorlist : 132:red:23565:green:323:black:234324:orange:23434:yellow:2543:white
2568
        @ example data+colorlist : 132:red:23565:green:323:black:234324:orange:23434:yellow:2543:white
2572
        @ the number of colors must match the number of data.
2569
        @ the number of colors must match the number of data.
2573
        @ use command "opacity 0-255,0-255" to adjust fill_opacity of colours
2570
        @ use command "opacity 0-255,0-255" to adjust fill_opacity of colours
2574
        @ 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...
2571
        @ 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...
2575
        */
2572
        */
2576
            if( js_function[DRAW_PIECHART] != 1 ){ js_function[DRAW_PIECHART] = 1;}
2573
            if( js_function[DRAW_PIECHART] != 1 ){ js_function[DRAW_PIECHART] = 1;}    
2577
            for(i=0;i<5;i++){
2574
            for(i=0;i<5;i++){
2578
                switch(i){
2575
                switch(i){
2579
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2576
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
2580
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2577
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
2581
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
2578
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
Line 2618... Line 2615...
2618
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2615
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2619
         @ ymajor is the major step on the y-axis; yminor is the divisor for the y-step
2616
         @ ymajor is the major step on the y-axis; yminor is the divisor for the y-step
2620
         @ the linewidth is set using command 'linewidth int'
2617
         @ the linewidth is set using command 'linewidth int'
2621
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2618
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2622
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number'
2619
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number'
2623
         @ 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>
2620
         @ 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>
2624
         @ note: the complete canvas will be used for the 'log paper'
2621
         @ note: the complete canvas will be used for the 'log paper'
2625
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2622
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2626
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2623
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2627
         @ 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')
2624
         @ 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')  
2628
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2625
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2629
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2626
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2630
        */
2627
        */
2631
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2628
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2632
            if( js_function[DRAW_XLOGSCALE] != 1 ){ js_function[DRAW_XLOGSCALE] = 1;}
2629
            if( js_function[DRAW_XLOGSCALE] != 1 ){ js_function[DRAW_XLOGSCALE] = 1;}
2633
            for(i=0;i<4;i++){
2630
            for(i=0;i<4;i++){
2634
                switch(i){
2631
                switch(i){
2635
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2632
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2636
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2633
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2637
                    case 2: stroke_color = get_color(infile,0); break;
2634
                    case 2: stroke_color = get_color(infile,0); break;
2638
                    case 3: fill_color = get_color(infile,1);
2635
                    case 3: fill_color = get_color(infile,1);
2639
                        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);
2636
                        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);
2640
                        tmp_buffer = my_newmem(string_length+1);
2637
                        tmp_buffer = my_newmem(string_length+1);
2641
                        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);
2638
                        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);
2642
                        fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]);
2639
                        fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]);
2643
                        add_to_buffer(tmp_buffer);
2640
                        add_to_buffer(tmp_buffer);
Line 2652... Line 2649...
2652
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2649
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2653
         @ xmajor is the major step on the x-axis; xminor is the divisor for the x-step
2650
         @ xmajor is the major step on the x-axis; xminor is the divisor for the x-step
2654
         @ the linewidth is set using command 'linewidth int'
2651
         @ the linewidth is set using command 'linewidth int'
2655
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2652
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2656
         @ default logbase number = 10 ... when needed , set the logbase number with command 'ylogbase number'
2653
         @ default logbase number = 10 ... when needed , set the logbase number with command 'ylogbase number'
2657
         @ 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>
2654
         @ 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>
2658
         @ note: the complete canvas will be used for the 'log paper'
2655
         @ note: the complete canvas will be used for the 'log paper'
2659
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2656
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2660
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2657
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2661
         @ 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')
2658
         @ 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')  
2662
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2659
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2663
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2660
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2664
        */
2661
        */
2665
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2662
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2666
            if( js_function[DRAW_YLOGSCALE] != 1 ){ js_function[DRAW_YLOGSCALE] = 1;}
2663
            if( js_function[DRAW_YLOGSCALE] != 1 ){ js_function[DRAW_YLOGSCALE] = 1;}
2667
            for(i=0;i<4;i++){
2664
            for(i=0;i<4;i++){
2668
                switch(i){
2665
                switch(i){
2669
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2666
                    case 0: double_data[0] = get_real(infile,0);break; /* xmajor */
2670
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2667
                    case 1: int_data[0] = (int) (get_real(infile,0));break; /* xminor */
2671
                    case 2: stroke_color = get_color(infile,0); break;
2668
                    case 2: stroke_color = get_color(infile,0); break;
2672
                    case 3: fill_color = get_color(infile,1);
2669
                    case 3: fill_color = get_color(infile,1);
2673
                        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);
2670
                        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);
2674
                        tmp_buffer = my_newmem(string_length+1);
2671
                        tmp_buffer = my_newmem(string_length+1);
2675
                        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);
2672
                        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);
2676
                        fprintf(js_include_file,"use_ylogscale=1;snap_x = %f;snap_y = ylogbase;",double_data[0]/int_data[0]);
2673
                        fprintf(js_include_file,"use_ylogscale=1;snap_x = %f;snap_y = ylogbase;",double_data[0]/int_data[0]);
2677
                        add_to_buffer(tmp_buffer);
2674
                        add_to_buffer(tmp_buffer);
Line 2685... Line 2682...
2685
         @ xylogscale majorcolor,minorcolor
2682
         @ xylogscale majorcolor,minorcolor
2686
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2683
         @ the x/y-range are set using commands 'xrange xmin,xmax' and 'yrange ymin,ymax'
2687
         @ the linewidth is set using command 'linewidth int'
2684
         @ the linewidth is set using command 'linewidth int'
2688
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2685
         @ the opacity of major / minor grid lines is set by command 'opacity [0-255],[0-255]'
2689
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number' and/or 'ylogbase number'
2686
         @ default logbase number = 10 ... when needed , set the logbase number with command 'xlogbase number' and/or 'ylogbase number'
2690
         @ 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>
2687
         @ 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>
2691
         @ note: the complete canvas will be used for the 'log paper'
2688
         @ note: the complete canvas will be used for the 'log paper'
2692
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2689
         @ note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
2693
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2690
         @ note: command 'mouse color,fontsize' will show the real values in the logpaper.<br />\
2694
         @ 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')
2691
         @ 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')  
2695
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2692
         @ note: in case of userdraw , the use of keyword 'userinput_xy' may be handy !
2696
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2693
         @ attention: keyword 'snaptogrid' may not lead to the desired result...
2697
        */
2694
        */
2698
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2695
            if( js_function[DRAW_GRID] == 1 ){canvas_error("only one type of grid is allowed...");}
2699
            if( js_function[DRAW_XYLOGSCALE] != 1 ){ js_function[DRAW_XYLOGSCALE] = 1;}
2696
            if( js_function[DRAW_XYLOGSCALE] != 1 ){ js_function[DRAW_XYLOGSCALE] = 1;}
2700
            for(i=0;i<2;i++){
2697
            for(i=0;i<2;i++){
2701
                switch(i){
2698
                switch(i){
2702
                    case 0: stroke_color = get_color(infile,0); break;
2699
                    case 0: stroke_color = get_color(infile,0); break;
2703
                    case 1: fill_color = get_color(infile,1);
2700
                    case 1: fill_color = get_color(infile,1);
2704
                        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);
2701
                        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);
2705
                        tmp_buffer = my_newmem(string_length+1);
2702
                        tmp_buffer = my_newmem(string_length+1);
2706
                        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);
2703
                        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);
2707
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
2704
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
2708
                        add_to_buffer(tmp_buffer);
2705
                        add_to_buffer(tmp_buffer);
Line 2712... Line 2709...
2712
            }
2709
            }
2713
        break;
2710
        break;
2714
        default:sync_input(infile);
2711
        default:sync_input(infile);
2715
        break;
2712
        break;
2716
    }
2713
    }
2717
  }
2714
  }
2718
  /* we are done parsing script file */
2715
  /* we are done parsing script file */
2719
 
2716
 
2720
  /* if needed, add generic draw functions (grid / xml etc) to buffer : these are no draggable shapes / objects  ! */
2717
  /* if needed, add generic draw functions (grid / xml etc) to buffer : these are no draggable shapes / objects  ! */
2721
  add_javascript_functions(js_function,canvas_root_id);
2718
  add_javascript_functions(js_function,canvas_root_id);
2722
   /* add read_canvas() etc functions if needed */
2719
   /* add read_canvas() etc functions if needed */
2723
  if( reply_format > 0 ){ add_read_canvas(reply_format);}
2720
  if( reply_format > 0 ){ add_read_canvas(reply_format);}
2724
  if( use_pan_and_zoom == TRUE ){
2721
  if( use_pan_and_zoom == TRUE ){
Line 2813... Line 2810...
2813
    if (oldlen != newlen){
2810
    if (oldlen != newlen){
2814
        for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){
2811
        for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){
2815
            count++;
2812
            count++;
2816
            retlen = p - str + strlen(p) + count * (newlen - oldlen);
2813
            retlen = p - str + strlen(p) + count * (newlen - oldlen);
2817
        }
2814
        }
2818
    }
2815
    }
2819
    else
2816
    else
2820
    {
2817
    {
2821
        retlen = strlen(str);
2818
        retlen = strlen(str);
2822
    }
2819
    }
2823
 
2820
   
2824
    if ((ret = malloc(retlen + 1)) == NULL){
2821
    if ((ret = malloc(retlen + 1)) == NULL){
2825
        ret = NULL;
2822
        ret = NULL;
2826
        canvas_error("string argument is NULL");
2823
        canvas_error("string argument is NULL");
2827
    }
2824
    }
2828
    else
2825
    else
Line 2835... Line 2832...
2835
            r += newlen;
2832
            r += newlen;
2836
        }
2833
        }
2837
        strcpy(r, p);
2834
        strcpy(r, p);
2838
    }
2835
    }
2839
    return ret;
2836
    return ret;
2840
}
2837
}
2841
 
2838
 
2842
/******************************************************************************/
2839
/******************************************************************************/
2843
/*
-
 
2844
avoid the use of ctypes.h for tolower() toupper();
-
 
2845
it gives trouble in FreeBSD 9.0 / 9.1 when used in a chroot environment (C library bug) : Undefined symbol "_ThreadRuneLocale"
-
 
2846
Upper case -> Lower case : c = c - 'A'+ 'a';
-
 
2847
Lower case ->  Upper case  c = c + 'A'  - 'a';
-
 
2848
 
-
 
2849
int tolower(int c){
-
 
2850
 if(c <= 'Z'){
-
 
2851
  if (c >= 'A'){
-
 
2852
   return c - 'A' + 'a';
-
 
2853
  }
-
 
2854
 }
-
 
2855
 return c;
-
 
2856
}
-
 
2857
 
2840
 
2858
int toupper(int c){
-
 
2859
 if(c >= 'a' && c <= 'z'){
-
 
2860
   return c + 'A' - 'a';
-
 
2861
 }
-
 
2862
 return c;
-
 
2863
}
-
 
2864
*/
-
 
2865
char *get_color(FILE *infile , int last){
2841
char *get_color(FILE *infile , int last){
2866
    int c,i = 0,is_hex = 0;
2842
    int c,i = 0,is_hex = 0;
2867
    char temp[MAX_COLOR_STRING], *string;
2843
    char temp[MAX_COLOR_STRING], *string;
2868
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',' ) && ( c != ';' ) ){
2844
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',' ) && ( c != ';' ) ){
2869
        if( i > MAX_COLOR_STRING ){ canvas_error("colour string is too big ... ? ");}
2845
        if( i > MAX_COLOR_STRING ){ canvas_error("colour string is too big ... ? ");}
Line 2873... Line 2849...
2873
        if( c != ' '){
2849
        if( c != ' '){
2874
            temp[i]=tolower(c);
2850
            temp[i]=tolower(c);
2875
            i++;
2851
            i++;
2876
        }
2852
        }
2877
    }
2853
    }
2878
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
2854
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
2879
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
2855
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
2880
    if( c == EOF ){finished = 1;}
2856
    if( c == EOF ){finished = 1;}
2881
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2857
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2882
    temp[i]='\0';
2858
    temp[i]='\0';
2883
    if( strlen(temp) == 0 ){ canvas_error("expected a colorname or hexnumber, but found nothing !!");}
2859
    if( strlen(temp) == 0 ){ canvas_error("expected a colorname or hexnumber, but found nothing !!");}
Line 2915... Line 2891...
2915
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){
2891
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){
2916
        temp[i]=c;
2892
        temp[i]=c;
2917
        i++;
2893
        i++;
2918
        if(i > MAX_BUFFER){ canvas_error("string size too big...repeat command to fit string");break;}
2894
        if(i > MAX_BUFFER){ canvas_error("string size too big...repeat command to fit string");break;}
2919
    }
2895
    }
2920
    if( ( c == '\n' || c == EOF ) && last == 0){canvas_error("expecting more arguments in command");}
2896
    if( ( c == '\n' || c == EOF ) && last == 0){canvas_error("expecting more arguments in command");}
2921
    if( c == '\n') { done = TRUE; line_number++; }
2897
    if( c == '\n') { done = TRUE; line_number++; }
2922
    if( c == EOF ) {
2898
    if( c == EOF ) {
2923
        finished = 1;
2899
        finished = 1;
2924
        if( last != 1 ){ canvas_error("expected more arguments");}
2900
        if( last != 1 ){ canvas_error("expected more arguments");}
2925
    }
2901
    }
Line 2936... Line 2912...
2936
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',')){
2912
    while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',')){
2937
        temp[i]=c;
2913
        temp[i]=c;
2938
        i++;
2914
        i++;
2939
        if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;}
2915
        if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;}
2940
    }
2916
    }
2941
    if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");}
2917
    if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");}
2942
    if( c == '\n') { line_number++; }
2918
    if( c == '\n') { line_number++; }
2943
    if( c == EOF ) {finished = 1;}
2919
    if( c == EOF ) {finished = 1;}
2944
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2920
    if( finished == 1 && last != 1 ){ canvas_error("expected more arguments");}
2945
    temp[i]='\0';
2921
    temp[i]='\0';
2946
    if( strlen(temp) == 0 ){ canvas_error("expected a word or string (without comma) , but found nothing !!");}
2922
    if( strlen(temp) == 0 ){ canvas_error("expected a word or string (without comma) , but found nothing !!");}
Line 2954... Line 2930...
2954
    int c,i=0,found_calc = 0;
2930
    int c,i=0,found_calc = 0;
2955
    double y;
2931
    double y;
2956
    char tmp[MAX_INT];
2932
    char tmp[MAX_INT];
2957
    while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){
2933
    while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){
2958
     if( c != ' ' ){
2934
     if( c != ' ' ){
2959
     /*
2935
     /*
2960
     libmatheval will segfault when for example: "xrange -10,+10" or "xrange -10,10+" is used
2936
     libmatheval will segfault when for example: "xrange -10,+10" or "xrange -10,10+" is used
2961
     We will check after assert() if it's a NULL pointer...and exit program via :
2937
     We will check after assert() if it's a NULL pointer...and exit program via :
2962
     canvas_error("I'm having trouble parsing your \"expression\" ");
2938
     canvas_error("I'm having trouble parsing your \"expression\" ");
2963
     */
2939
     */
2964
      if( i == 0 &&  c == '+' ){
2940
      if( i == 0 &&  c == '+' ){
2965
       continue;
2941
       continue;
2966
      }
2942
      }
2967
      else
2943
      else
2968
      {
2944
      {
2969
       if(canvas_iscalculation(c) != 0){
2945
       if(canvas_iscalculation(c) != 0){
2970
        found_calc = 1;
2946
        found_calc = 1;
2971
        c = tolower(c);
2947
        c = tolower(c);
Line 2974... Line 2950...
2974
       i++;
2950
       i++;
2975
      }
2951
      }
2976
     }
2952
     }
2977
     if( i > MAX_INT - 1){canvas_error("number too large");}
2953
     if( i > MAX_INT - 1){canvas_error("number too large");}
2978
    }
2954
    }
2979
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
2955
    if( ( c == '\n' || c == EOF || c == ';' ) && last == 0){canvas_error("expecting more arguments in command");}
2980
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
2956
    if( c == '\n' || c == ';' ){ done = TRUE; line_number++; }
2981
    if( c == EOF ){done = TRUE ; finished = 1;}
2957
    if( c == EOF ){done = TRUE ; finished = 1;}
2982
    tmp[i]='\0';
2958
    tmp[i]='\0';
2983
    if( strlen(tmp) == 0 ){canvas_error("expected a number , but found nothing !!");}
2959
    if( strlen(tmp) == 0 ){canvas_error("expected a number , but found nothing !!");}
2984
    if( found_calc == 1 ){ /* use libmatheval to calculate 2*pi/3 */
2960
    if( found_calc == 1 ){ /* use libmatheval to calculate 2*pi/3 */
Line 3056... Line 3032...
3056
 
3032
 
3057
3 = x1,x2,x3,x4....x_n
3033
3 = x1,x2,x3,x4....x_n
3058
    y1,y2,y3,y4....y_n
3034
    y1,y2,y3,y4....y_n
3059
    r1,r2,r3,r4....r_n
3035
    r1,r2,r3,r4....r_n
3060
 
3036
 
3061
    x/y in pixels
3037
    x/y in pixels
3062
    r in pixels
3038
    r in pixels
3063
 
3039
 
3064
4 = x1,x2,x3,x4....x_n
3040
4 = x1,x2,x3,x4....x_n
3065
    y1,y2,y3,y4....y_n
3041
    y1,y2,y3,y4....y_n
3066
    r1,r2,r3,r4....r_n
3042
    r1,r2,r3,r4....r_n
3067
 
3043
 
3068
    x/y in  xrange / yrange coordinate system
3044
    x/y in  xrange / yrange coordinate system
3069
    r in pixels
3045
    r in pixels
3070
 
3046
 
3071
5 = Ax1,Ax2,Ax3,Ax4....Ax_n
3047
5 = Ax1,Ax2,Ax3,Ax4....Ax_n
3072
    Ay1,Ay2,Ay3,Ay4....Ay_n
3048
    Ay1,Ay2,Ay3,Ay4....Ay_n
3073
    Bx1,Bx2,Bx3,Bx4....Bx_n
3049
    Bx1,Bx2,Bx3,Bx4....Bx_n
3074
    By1,By2,By3,By4....By_n
3050
    By1,By2,By3,By4....By_n
3075
    Cx1,Cx2,Cx3,Cx4....Cx_n
3051
    Cx1,Cx2,Cx3,Cx4....Cx_n
3076
    Cy1,Cy2,Cy3,Cy4....Cy_n
3052
    Cy1,Cy2,Cy3,Cy4....Cy_n
3077
    ....
3053
    ....
3078
    Zx1,Zx2,Zx3,Zx4....Zx_n
3054
    Zx1,Zx2,Zx3,Zx4....Zx_n
3079
    Zy1,Zy2,Zy3,Zy4....Zy_n
3055
    Zy1,Zy2,Zy3,Zy4....Zy_n
3080
 
3056
   
3081
    x/y in pixels
3057
    x/y in pixels
3082
 
3058
 
3083
6 = Ax1,Ax2,Ax3,Ax4....Ax_n
3059
6 = Ax1,Ax2,Ax3,Ax4....Ax_n
3084
    Ay1,Ay2,Ay3,Ay4....Ay_n
3060
    Ay1,Ay2,Ay3,Ay4....Ay_n
3085
    Bx1,Bx2,Bx3,Bx4....Bx_n
3061
    Bx1,Bx2,Bx3,Bx4....Bx_n
3086
    By1,By2,By3,By4....By_n
3062
    By1,By2,By3,By4....By_n
3087
    Cx1,Cx2,Cx3,Cx4....Cx_n
3063
    Cx1,Cx2,Cx3,Cx4....Cx_n
3088
    Cy1,Cy2,Cy3,Cy4....Cy_n
3064
    Cy1,Cy2,Cy3,Cy4....Cy_n
3089
    ....
3065
    ....
3090
    Zx1,Zx2,Zx3,Zx4....Zx_n
3066
    Zx1,Zx2,Zx3,Zx4....Zx_n
3091
    Zy1,Zy2,Zy3,Zy4....Zy_n
3067
    Zy1,Zy2,Zy3,Zy4....Zy_n
3092
 
3068
 
3093
    x/y in  xrange / yrange coordinate system
3069
    x/y in  xrange / yrange coordinate system
-
 
3070
   
-
 
3071
7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
-
 
3072
   
-
 
3073
    x/y in pixels
3094
 
3074
 
3095
7 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
3075
8 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
-
 
3076
   
-
 
3077
    x/y in  xrange / yrange coordinate system
-
 
3078
 
-
 
3079
9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n    
3096
 
3080
 
3097
    x/y in pixels
3081
    x/y in pixels
3098
 
3082
 
3099
8 = x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n
-
 
3100
 
-
 
3101
    x/y in  xrange / yrange coordinate system
-
 
3102
 
-
 
3103
9 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n
-
 
3104
 
-
 
3105
    x/y in pixels
-
 
3106
 
-
 
3107
10 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n
3083
10 = x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n    
3108
 
3084
 
3109
    x/y in  xrange / yrange coordinate system
3085
    x/y in  xrange / yrange coordinate system
3110
 
3086
 
3111
11 = Ax1,Ay1,Ax2,Ay2
3087
11 = Ax1,Ay1,Ax2,Ay2
3112
     Bx1,By1,Bx2,By2
3088
     Bx1,By1,Bx2,By2
3113
     Cx1,Cy1,Cx2,Cy2
3089
     Cx1,Cy1,Cx2,Cy2
3114
     Dx1,Dy1,Dx2,Dy2
3090
     Dx1,Dy1,Dx2,Dy2
3115
     ......
3091
     ......
3116
     Zx1,Zy1,Zx2,Zy2
3092
     Zx1,Zy1,Zx2,Zy2
3117
 
3093
     
3118
    x/y in  xrange / yrange coordinate system
3094
    x/y in  xrange / yrange coordinate system
3119
 
3095
 
3120
12 = Ax1,Ay1,Ax2,Ay2
3096
12 = Ax1,Ay1,Ax2,Ay2
3121
     Bx1,By1,Bx2,By2
3097
     Bx1,By1,Bx2,By2
3122
     Cx1,Cy1,Cx2,Cy2
3098
     Cx1,Cy1,Cx2,Cy2
3123
     Dx1,Dy1,Dx2,Dy2
3099
     Dx1,Dy1,Dx2,Dy2
3124
     ......
3100
     ......
3125
     Zx1,Zy1,Zx2,Zy2
3101
     Zx1,Zy1,Zx2,Zy2
3126
 
3102
     
3127
    x/y in pixels
3103
    x/y in pixels
3128
 
3104
 
3129
13 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2
3105
13 = Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2
3130
 
3106
 
3131
    x/y in  xrange / yrange coordinate system
3107
    x/y in  xrange / yrange coordinate system
Line 3143... Line 3119...
3143
19 = return clicked object number (analogue to shape-library onclick)
3119
19 = return clicked object number (analogue to shape-library onclick)
3144
20 = return x/y-data in x-range/y-range of all 'draggable' images
3120
20 = return x/y-data in x-range/y-range of all 'draggable' images
3145
21 = return verbatim coordinates (x1:y1) (x2:y2)...(x_n:y_n)
3121
21 = return verbatim coordinates (x1:y1) (x2:y2)...(x_n:y_n)
3146
22 = array : x1,y1,x2,y2,x3,y3,x4,y4...x_n,y_n
3122
22 = array : x1,y1,x2,y2,x3,y3,x4,y4...x_n,y_n
3147
    x/y in  xrange / yrange coordinate system
3123
    x/y in  xrange / yrange coordinate system
3148
23 = answertype for a polyline : remove multiple occurences  due to reclick on a point to create next polyline segment
3124
23 = answertype for a polyline : remove multiple occurences  due to reclick on a point to create next polyline segment
3149
*/
3125
*/
3150
 
3126
 
3151
 
3127
 
3152
void add_read_canvas(int type_reply){
3128
void add_read_canvas(int type_reply){
3153
/* just 1 reply type allowed */
3129
/* just 1 reply type allowed */
3154
switch(type_reply){
3130
switch(type_reply){
3155
/*  TO DO
3131
/*  TO DO
3156
!!!!  NEED TO SIMPLIFY !!!!
3132
!!!!  NEED TO SIMPLIFY !!!!  
3157
answers may have:
3133
answers may have:
3158
x-values,y-values,r-values,input-fields,mathml-inputfields,text-typed answers
3134
x-values,y-values,r-values,input-fields,mathml-inputfields,text-typed answers
3159
*/
3135
*/
3160
    case 1: fprintf(js_include_file,"\
3136
    case 1: fprintf(js_include_file,"\
3161
\n<!-- begin function 1 read_canvas() -->\n\
3137
\n<!-- begin function 1 read_canvas() -->\n\
Line 3173... Line 3149...
3173
    t++;\
3149
    t++;\
3174
   };\
3150
   };\
3175
  };\
3151
  };\
3176
  if( typeof userdraw_text != 'undefined' ){\
3152
  if( typeof userdraw_text != 'undefined' ){\
3177
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply + \"\\n\"+userdraw_text;\
3153
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply + \"\\n\"+userdraw_text;\
3178
  }\
3154
  }\
3179
  else\
3155
  else\
3180
  {\
3156
  {\
3181
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply;\
3157
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+input_reply;\
3182
  }\
3158
  }\
3183
 }\
3159
 }\
Line 3195... Line 3171...
3195
this.read_canvas = read_canvas;\n\
3171
this.read_canvas = read_canvas;\n\
3196
<!-- end function 1 read_canvas() -->");
3172
<!-- end function 1 read_canvas() -->");
3197
    break;
3173
    break;
3198
    case 2: fprintf(js_include_file,"\
3174
    case 2: fprintf(js_include_file,"\
3199
\n<!-- begin function 2 read_canvas() -->\n\
3175
\n<!-- begin function 2 read_canvas() -->\n\
3200
function read_canvas(){\
3176
function read_canvas(){\
3201
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3177
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3202
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
3178
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
3203
 while(userdraw_x[p]){\
3179
 while(userdraw_x[p]){\
3204
  reply_x[p] = px2x(userdraw_x[p]);\
3180
  reply_x[p] = px2x(userdraw_x[p]);\
3205
  reply_y[p] = px2y(userdraw_y[p]);\
3181
  reply_y[p] = px2y(userdraw_y[p]);\
3206
  p++;\
3182
  p++;\
3207
 };\
3183
 };\
3208
 if(p == 0){alert(\"nothing drawn...\");return;};\
3184
 if(p == 0){alert(\"nothing drawn...\");return;};\
3209
 if( document.getElementById(\"canvas_input0\")){\
3185
 if( document.getElementById(\"canvas_input0\")){\
3210
  var p = 0;var input_reply = new Array();\
3186
  var p = 0;var input_reply = new Array();\
3211
  if( document.getElementById(\"canvas_input0\")){\
3187
  if( document.getElementById(\"canvas_input0\")){\
3212
   var t = 0;\
3188
   var t = 0;\
3213
   while(document.getElementById(\"canvas_input\"+t)){\
3189
   while(document.getElementById(\"canvas_input\"+t)){\
3214
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3190
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3215
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3191
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3216
     p++;\
3192
     p++;\
3217
    };\
3193
    };\
3218
    t++;\
3194
    t++;\
3219
   };\
3195
   };\
3220
  };\
3196
  };\
3221
  if( typeof userdraw_text != 'undefined' ){\
3197
  if( typeof userdraw_text != 'undefined' ){\
3222
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3198
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3223
  }\
3199
  }\
3224
  else\
3200
  else\
3225
  {\
3201
  {\
3226
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\
3202
   return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\
3227
  }\
3203
  }\
3228
 }\
3204
 }\
3229
 else\
3205
 else\
3230
 {\
3206
 {\
3231
  if( typeof userdraw_text != 'undefined' ){\
3207
  if( typeof userdraw_text != 'undefined' ){\
3232
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_text;\
3208
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_text;\
3233
  }\
3209
  }\
3234
  else\
3210
  else\
3235
  {\
3211
  {\
3236
   return reply_x+\"\\n\"+reply_y;\
3212
   return reply_x+\"\\n\"+reply_y;\
3237
  };\
3213
  };\
3238
 };\
3214
 };\
Line 3260... Line 3236...
3260
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3236
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3261
  }\
3237
  }\
3262
  else\
3238
  else\
3263
  {\
3239
  {\
3264
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3240
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3265
  }\
3241
  }\
3266
 }\
3242
 }\
3267
 else\
3243
 else\
3268
 {\
3244
 {\
3269
  if( typeof userdraw_text != 'undefined' ){\
3245
  if( typeof userdraw_text != 'undefined' ){\
3270
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+userdrawW_text;\
3246
   return userdraw_x+\"\\n\"+userdraw_y+\"\\n\"+userdraw_radius+\"\\n\"+userdrawW_text;\
Line 3283... Line 3259...
3283
function read_canvas(){\
3259
function read_canvas(){\
3284
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
3260
 var reply_x = new Array();var reply_y = new Array();var p = 0;\
3285
 while(userdraw_x[p]){\
3261
 while(userdraw_x[p]){\
3286
  reply_x[p] = px2x(userdraw_x[p]);\
3262
  reply_x[p] = px2x(userdraw_x[p]);\
3287
  reply_y[p] = px2y(userdraw_y[p]);\
3263
  reply_y[p] = px2y(userdraw_y[p]);\
3288
  p++;\
3264
  p++;\
3289
 };\
3265
 };\
3290
 if(p == 0){alert(\"nothing drawn...\");return;};\
3266
 if(p == 0){alert(\"nothing drawn...\");return;};\
3291
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3267
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3292
  var p = 0;var input_reply = new Array();\
3268
  var p = 0;var input_reply = new Array();\
3293
  if( document.getElementById(\"canvas_input0\")){\
3269
  if( document.getElementById(\"canvas_input0\")){\
3294
   var t = 0;\
3270
   var t = 0;\
3295
   while(document.getElementById(\"canvas_input\"+t)){\
3271
   while(document.getElementById(\"canvas_input\"+t)){\
3296
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3272
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3297
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3273
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3298
     p++;\
3274
     p++;\
3299
    };\
3275
    };\
3300
    t++;\
3276
    t++;\
3301
   };\
3277
   };\
3302
  };\
3278
  };\
3303
  if( typeof userdraw_text != 'undefined' ){\
3279
  if( typeof userdraw_text != 'undefined' ){\
3304
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3280
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3305
  }\
3281
  }\
3306
  else\
3282
  else\
3307
  {\
3283
  {\
3308
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3284
   return reply_x+\"\\n\"+reply_y +\"\\n\"+userdraw_radius+\"\\n\"+input_reply;\
3309
  }\
3285
  }\
3310
 }\
3286
 }\
3311
 else\
3287
 else\
3312
 {\
3288
 {\
3313
  if( typeof userdraw_text != 'undefined' ){\
3289
  if( typeof userdraw_text != 'undefined' ){\
3314
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius+\"\\n\"+userdraw_text;\
3290
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius+\"\\n\"+userdraw_text;\
3315
  }\
3291
  }\
3316
  else\
3292
  else\
3317
  {\
3293
  {\
3318
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius;\
3294
   return reply_x+\"\\n\"+reply_y+\"\\n\"+userdraw_radius;\
3319
  }\
3295
  }\
3320
 };\
3296
 };\
3321
};\
3297
};\
3322
this.read_canvas = read_canvas;\n\
3298
this.read_canvas = read_canvas;\n\
3323
<!-- end function 4 read_canvas() -->");
3299
<!-- end function 4 read_canvas() -->");
3324
    break;
3300
    break;
3325
    /*
3301
    /*
3326
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3302
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3327
        used for userdraw multiple paths
3303
        used for userdraw multiple paths
3328
    */
3304
    */
3329
    case 5: fprintf(js_include_file,"\
3305
    case 5: fprintf(js_include_file,"\
3330
\n<!-- begin function 5 read_canvas() -->\n\
3306
\n<!-- begin function 5 read_canvas() -->\n\
3331
function read_canvas(){\
3307
function read_canvas(){\
3332
 var p = 0;\
3308
 var p = 0;\
Line 3350... Line 3326...
3350
    t++;\
3326
    t++;\
3351
   };\
3327
   };\
3352
  };\
3328
  };\
3353
  if( typeof userdraw_text != 'undefined' ){\
3329
  if( typeof userdraw_text != 'undefined' ){\
3354
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3330
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3355
  }\
3331
  }\
3356
  else\
3332
  else\
3357
  {\
3333
  {\
3358
   return reply +\"\\n\"+input_reply;\
3334
   return reply +\"\\n\"+input_reply;\
3359
  }\
3335
  }\
3360
 }\
3336
 }\
3361
 else\
3337
 else\
Line 3370... Line 3346...
3370
 };\
3346
 };\
3371
};\
3347
};\
3372
this.read_canvas = rdad_canvas;\n\
3348
this.read_canvas = rdad_canvas;\n\
3373
<!-- end function 5 read_canvas() -->");
3349
<!-- end function 5 read_canvas() -->");
3374
    break;
3350
    break;
3375
    /*
3351
    /*
3376
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3352
        attention: we reset userdraw_x / userdraw_y  : because  userdraw_x = [][] userdraw_y = [][]
3377
        used for userdraw multiple paths
3353
        used for userdraw multiple paths
3378
    */
3354
    */
3379
    case 6: fprintf(js_include_file,"\
3355
    case 6: fprintf(js_include_file,"\
3380
\n<!-- begin function 6 read_canvas() -->\n\
3356
\n<!-- begin function 6 read_canvas() -->\n\
3381
function read_canvas(){\
3357
function read_canvas(){\
3382
 var p = 0;\
3358
 var p = 0;\
3383
 var reply = \"\";\
3359
 var reply = \"\";\
3384
 var tmp_x = new Array();\
3360
 var tmp_x = new Array();\
3385
 var tmp_y = new Array();\
3361
 var tmp_y = new Array();\
3386
 for(p = 0 ; p < userdraw_x.length; p++){\
3362
 for(p = 0 ; p < userdraw_x.length; p++){\
3387
  tmp_x = userdraw_x[p];\
3363
  tmp_x = userdraw_x[p];\
Line 3394... Line 3370...
3394
   reply = reply + tmp_x + \"\\n\" + tmp_y +\"\\n\";\
3370
   reply = reply + tmp_x + \"\\n\" + tmp_y +\"\\n\";\
3395
  };\
3371
  };\
3396
 };\
3372
 };\
3397
 if(p == 0){alert(\"nothing drawn...\");return;};\
3373
 if(p == 0){alert(\"nothing drawn...\");return;};\
3398
 userdraw_x = [];userdraw_y = [];\
3374
 userdraw_x = [];userdraw_y = [];\
3399
 if( document.getElementById(\"canvas_input0\") ){\
3375
 if( document.getElementById(\"canvas_input0\") ){\
3400
  var p = 0;var input_reply = new Array();\
3376
  var p = 0;var input_reply = new Array();\
3401
  if( document.getElementById(\"canvas_input0\")){\
3377
  if( document.getElementById(\"canvas_input0\")){\
3402
   var t = 0;\
3378
   var t = 0;\
3403
   while(document.getElementById(\"canvas_input\"+t)){\
3379
   while(document.getElementById(\"canvas_input\"+t)){\
3404
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3380
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3405
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3381
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3406
     p++;\
3382
     p++;\
3407
    };\
3383
    };\
3408
    t++;\
3384
    t++;\
3409
   };\
3385
   };\
3410
  };\
3386
  };\
3411
  if( typeof userdraw_text != 'undefined' ){\
3387
  if( typeof userdraw_text != 'undefined' ){\
3412
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3388
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3413
  }\
3389
  }\
3414
  else\
3390
  else\
3415
  {\
3391
  {\
3416
   return reply +\"\\n\"+input_reply;\
3392
   return reply +\"\\n\"+input_reply;\
3417
  }\
3393
  }\
3418
 }\
3394
 }\
3419
 else\
3395
 else\
3420
 {\
3396
 {\
3421
  if( typeof userdraw_text != 'undefined' ){\
3397
  if( typeof userdraw_text != 'undefined' ){\
3422
   return reply +\"\\n\"+userdraw_text;\
3398
   return reply +\"\\n\"+userdraw_text;\
3423
  }\
3399
  }\
3424
  else\
3400
  else\
3425
  {\
3401
  {\
3426
   return reply;\
3402
   return reply;\
3427
  }\
3403
  }\
3428
 };\
3404
 };\
Line 3462... Line 3438...
3462
 };\
3438
 };\
3463
 else\
3439
 else\
3464
 {\
3440
 {\
3465
  if( typeof userdraw_text != 'undefined' ){\
3441
  if( typeof userdraw_text != 'undefined' ){\
3466
   return reply+\"\\n\"+userdraw_text;\
3442
   return reply+\"\\n\"+userdraw_text;\
3467
  }\
3443
  }\
3468
  else\
3444
  else\
3469
  {\
3445
  {\
3470
   return reply;\
3446
   return reply;\
3471
  }\
3447
  }\
3472
 };\
3448
 };\
3473
};\
3449
};\
3474
this.read_canvas = read_canvas;\n\
3450
this.read_canvas = read_canvas;\n\
3475
<!-- end function 7 read_canvas() -->");
3451
<!-- end function 7 read_canvas() -->");
3476
    break;
3452
    break;
3477
    case 8: fprintf(js_include_file,"\
3453
    case 8: fprintf(js_include_file,"\
3478
\n<!-- begin function 8 read_canvas() -->\n\
3454
\n<!-- begin function 8 read_canvas() -->\n\
3479
function read_canvas(){\
3455
function read_canvas(){\
3480
 var reply = new Array();\
3456
 var reply = new Array();\
3481
 var p = 0;\
3457
 var p = 0;\
3482
 while(userdraw_x[p]){\
3458
 while(userdraw_x[p]){\
3483
  reply[p] = px2x(userdraw_x[p]) +\":\" + px2y(userdraw_y[p]);\
3459
  reply[p] = px2x(userdraw_x[p]) +\":\" + px2y(userdraw_y[p]);\
3484
  p++;\
3460
  p++;\
3485
 };\
3461
 };\
3486
 if(p == 0){alert(\"nothing drawn...\");return;};\
3462
 if(p == 0){alert(\"nothing drawn...\");return;};\
3487
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3463
 if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\
3488
  var p = 0;var input_reply = new Array();\
3464
  var p = 0;var input_reply = new Array();\
3489
  if( document.getElementById(\"canvas_input0\")){\
3465
  if( document.getElementById(\"canvas_input0\")){\
3490
   var t = 0;\
3466
   var t = 0;\
3491
   while(document.getElementById(\"canvas_input\"+t)){\
3467
   while(document.getElementById(\"canvas_input\"+t)){\
3492
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3468
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3493
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3469
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3494
     p++;\
3470
     p++;\
3495
    };\
3471
    };\
3496
    t++;\
3472
    t++;\
3497
   };\
3473
   };\
3498
  };\
3474
  };\
3499
  if( typeof userdraw_text != 'undefined' ){\
3475
  if( typeof userdraw_text != 'undefined' ){\
3500
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3476
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3501
  }\
3477
  }\
3502
  else\
3478
  else\
3503
  {\
3479
  {\
3504
   return reply +\"\\n\"+input_reply;\
3480
   return reply +\"\\n\"+input_reply;\
3505
  }\
3481
  }\
3506
 }\
3482
 }\
3507
 else\
3483
 else\
3508
 {\
3484
 {\
3509
  if( typeof userdraw_text != 'undefined' ){\
3485
  if( typeof userdraw_text != 'undefined' ){\
3510
   return reply +\"\\n\"+userdraw_text;\
3486
   return reply +\"\\n\"+userdraw_text;\
3511
  }\
3487
  }\
3512
  else\
3488
  else\
3513
  {\
3489
  {\
3514
   return reply;\
3490
   return reply;\
3515
  }\
3491
  }\
3516
 };\
3492
 };\
3517
};\
3493
};\
3518
this.read_canvas = read_canvas;\n\
3494
this.read_canvas = read_canvas;\n\
3519
<!-- end function 8 read_canvas() -->");
3495
<!-- end function 8 read_canvas() -->");
3520
    break;
3496
    break;
3521
    case 9: fprintf(js_include_file,"\
3497
    case 9: fprintf(js_include_file,"\
3522
\n<!-- begin function 9 read_canvas() -->\n\
3498
\n<!-- begin function 9 read_canvas() -->\n\
Line 3559... Line 3535...
3559
  }\
3535
  }\
3560
 };\
3536
 };\
3561
};\
3537
};\
3562
this.read_canvas = read_canvas;\n\
3538
this.read_canvas = read_canvas;\n\
3563
<!-- end function 9 read_canvas() -->");
3539
<!-- end function 9 read_canvas() -->");
3564
    break;
3540
    break;
3565
    case 10: fprintf(js_include_file,"\
3541
    case 10: fprintf(js_include_file,"\
3566
\n<!-- begin function 10 read_canvas() -->\n\
3542
\n<!-- begin function 10 read_canvas() -->\n\
3567
function read_canvas(){\
3543
function read_canvas(){\
3568
 var reply = new Array();\
3544
 var reply = new Array();\
3569
 var p = 0;\
3545
 var p = 0;\
Line 3744... Line 3720...
3744
function read_canvas(){\
3720
function read_canvas(){\
3745
 var reply = new Array();\
3721
 var reply = new Array();\
3746
 var p = 0;var i = 0;\
3722
 var p = 0;var i = 0;\
3747
 while(userdraw_x[p]){\
3723
 while(userdraw_x[p]){\
3748
  reply[i] = userdraw_x[p] +\":\" + userdraw_y[p] +\":\" + userdraw_x[p+1] +\":\" + userdraw_y[p+1];\
3724
  reply[i] = userdraw_x[p] +\":\" + userdraw_y[p] +\":\" + userdraw_x[p+1] +\":\" + userdraw_y[p+1];\
3749
  p = p+2;i++;\
3725
  p = p+2;i++;\
3750
 };\
3726
 };\
3751
 if(p == 0){alert(\"nothing drawn...\");return;};\
3727
 if(p == 0){alert(\"nothing drawn...\");return;};\
3752
 if( document.getElementById(\"canvas_input0\") ){\
3728
 if( document.getElementById(\"canvas_input0\") ){\
3753
  var p = 0;var input_reply = new Array();\
3729
  var p = 0;var input_reply = new Array();\
3754
  if( document.getElementById(\"canvas_input0\")){\
3730
  if( document.getElementById(\"canvas_input0\")){\
3755
   var t = 0;\
3731
   var t = 0;\
3756
   while(document.getElementById(\"canvas_input\"+t)){\
3732
   while(document.getElementById(\"canvas_input\"+t)){\
3757
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3733
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3758
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3734
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3759
     p++;\
3735
     p++;\
Line 3761... Line 3737...
3761
    t++;\
3737
    t++;\
3762
   };\
3738
   };\
3763
  };\
3739
  };\
3764
  if( typeof userdraw_text != 'undefined' ){\
3740
  if( typeof userdraw_text != 'undefined' ){\
3765
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3741
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3766
  }\
3742
  }\
3767
  else\
3743
  else\
3768
  {\
3744
  {\
3769
   return reply +\"\\n\"+input_reply;\
3745
   return reply +\"\\n\"+input_reply;\
3770
  }\
3746
  }\
3771
 }\
3747
 }\
Line 3785... Line 3761...
3785
    break;
3761
    break;
3786
    case 15: fprintf(js_include_file,"\
3762
    case 15: fprintf(js_include_file,"\
3787
\n<!-- begin function 15  read_canvas() -->\n\
3763
\n<!-- begin function 15  read_canvas() -->\n\
3788
function read_canvas(){\
3764
function read_canvas(){\
3789
 var input_reply = new Array();\
3765
 var input_reply = new Array();\
3790
 var p = 0;\
3766
 var p = 0;\
3791
 if( document.getElementById(\"canvas_input0\")){\
3767
 if( document.getElementById(\"canvas_input0\")){\
3792
  var t = 0;\
3768
  var t = 0;\
3793
  while(document.getElementById(\"canvas_input\"+t)){\
3769
  while(document.getElementById(\"canvas_input\"+t)){\
3794
   if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3770
   if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3795
    input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3771
    input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
Line 3844... Line 3820...
3844
 while(t){\
3820
 while(t){\
3845
  try{ name = eval('clocks'+p);\
3821
  try{ name = eval('clocks'+p);\
3846
  reply[p] = parseInt((name.H+name.M/60+name.S/3600)%%12)+\":\"+parseInt((name.M + name.S/60)%%60)+\":\"+(name.S)%%60;p++}catch(e){t=false;};\
3822
  reply[p] = parseInt((name.H+name.M/60+name.S/3600)%%12)+\":\"+parseInt((name.M + name.S/60)%%60)+\":\"+(name.S)%%60;p++}catch(e){t=false;};\
3847
 };\
3823
 };\
3848
 if( p == 0){alert(\"clock(s) not modified...\");return;}\
3824
 if( p == 0){alert(\"clock(s) not modified...\");return;}\
3849
 return reply;\
3825
 return reply;\
3850
};\
3826
};\
3851
this.read_canvas = read_canvas;\n\
3827
this.read_canvas = read_canvas;\n\
3852
<!-- end function 18 read_canvas() -->");
3828
<!-- end function 18 read_canvas() -->");
3853
    break;
3829
    break;
3854
    case 19: fprintf(js_include_file,"\
3830
    case 19: fprintf(js_include_file,"\
3855
\n<!-- begin function 19 read_canvas() -->\n\
3831
\n<!-- begin function 19 read_canvas() -->\n\
3856
function read_canvas(){\
3832
function read_canvas(){\
3857
 return reply[0];\
3833
 return reply[0];\
3858
};\
3834
};\
3859
this.read_canvas = read_canvas;\n\
3835
this.read_canvas = read_canvas;\n\
3860
<!-- end function 19 read_canvas() -->");
3836
<!-- end function 19 read_canvas() -->");
3861
    case 20: fprintf(js_include_file,"\
3837
    case 20: fprintf(js_include_file,"\
3862
\n<!-- begin function 20 read_canvas() -->\n\
3838
\n<!-- begin function 20 read_canvas() -->\n\
3863
function read_canvas(){\
3839
function read_canvas(){\
3864
 var len  = ext_drag_images.length;\
3840
 var len  = ext_drag_images.length;\
3865
 var reply = new Array(len);\
3841
 var reply = new Array(len);\
3866
 for(var p = 0 ; p < len ; p++){\
3842
 for(var p = 0 ; p < len ; p++){\
3867
    var img = ext_drag_images[p];\
3843
    var img = ext_drag_images[p];\
3868
    reply[p] = px2x(img[6])+\":\"+px2y(img[7]);\
3844
    reply[p] = px2x(img[6])+\":\"+px2y(img[7]);\
3869
 };\
3845
 };\
3870
 return reply;\
3846
 return reply;\
3871
};\
3847
};\
3872
this.read_canvas = read_canvas;\n\
3848
this.read_canvas = read_canvas;\n\
3873
<!-- end function 20 read_canvas() -->");
3849
<!-- end function 20 read_canvas() -->");
3874
    break;
3850
    break;
3875
    case 21: fprintf(js_include_file,"\
3851
    case 21: fprintf(js_include_file,"\
3876
\n<!-- begin function 21 read_canvas() -->\n\
3852
\n<!-- begin function 21 read_canvas() -->\n\
3877
function read_canvas(){\
3853
function read_canvas(){\
3878
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3854
 if( userdraw_x.length == 0){alert(\"nothing drawn...\");return;}\
3879
 var reply_coord = new Array();var p = 0;\
3855
 var reply_coord = new Array();var p = 0;\
3880
 while(userdraw_x[p]){\
3856
 while(userdraw_x[p]){\
3881
  reply_coord[p] = \"(\"+px2x(userdraw_x[p])+\":\"+px2y(userdraw_y[p])+\")\";\
3857
  reply_coord[p] = \"(\"+px2x(userdraw_x[p])+\":\"+px2y(userdraw_y[p])+\")\";\
3882
  p++;\
3858
  p++;\
3883
 };\
3859
 };\
3884
 if(p == 0){alert(\"nothing drawn...\");return;};\
3860
 if(p == 0){alert(\"nothing drawn...\");return;};\
3885
 if( document.getElementById(\"canvas_input0\") ){\
3861
 if( document.getElementById(\"canvas_input0\") ){\
3886
  var p = 0;var input_reply = new Array();\
3862
  var p = 0;var input_reply = new Array();\
3887
  if( document.getElementById(\"canvas_input0\")){\
3863
  if( document.getElementById(\"canvas_input0\")){\
3888
   var t = 0;\
3864
   var t = 0;\
3889
   while(document.getElementById(\"canvas_input\"+t)){\
3865
   while(document.getElementById(\"canvas_input\"+t)){\
3890
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3866
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3891
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3867
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3892
     p++;\
3868
     p++;\
3893
    };\
3869
    };\
3894
    t++;\
3870
    t++;\
3895
   };\
3871
   };\
3896
  };\
3872
  };\
3897
  if( typeof userdraw_text != 'undefined' ){\
3873
  if( typeof userdraw_text != 'undefined' ){\
3898
   return reply_coord+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3874
   return reply_coord+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3899
  }\
3875
  }\
3900
  else\
3876
  else\
3901
  {\
3877
  {\
3902
   return reply_coord+\"\\n\"+input_reply;\
3878
   return reply_coord+\"\\n\"+input_reply;\
3903
  }\
3879
  }\
3904
 }\
3880
 }\
3905
 else\
3881
 else\
3906
 {\
3882
 {\
Line 3928... Line 3904...
3928
  reply[idx] = px2y(userdraw_y[p]);\
3904
  reply[idx] = px2y(userdraw_y[p]);\
3929
  idx++;p++;\
3905
  idx++;p++;\
3930
 };\
3906
 };\
3931
 if(p == 0){alert(\"nothing drawn...\");return;};\
3907
 if(p == 0){alert(\"nothing drawn...\");return;};\
3932
 if( document.getElementById(\"canvas_input0\") ){\
3908
 if( document.getElementById(\"canvas_input0\") ){\
3933
  var p = 0;var input_reply = new Array();\
3909
  var p = 0;var input_reply = new Array();\
3934
  if( document.getElementById(\"canvas_input0\")){\
3910
  if( document.getElementById(\"canvas_input0\")){\
3935
   var t = 0;\
3911
   var t = 0;\
3936
   while(document.getElementById(\"canvas_input\"+t)){\
3912
   while(document.getElementById(\"canvas_input\"+t)){\
3937
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3913
    if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\
3938
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3914
     input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\
3939
     p++;\
3915
     p++;\
3940
    };\
3916
    };\
3941
    t++;\
3917
    t++;\
3942
   };\
3918
   };\
3943
  };\
3919
  };\
3944
  if( typeof userdraw_text != 'undefined' ){\
3920
  if( typeof userdraw_text != 'undefined' ){\
3945
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3921
   return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\
3946
  }\
3922
  }\
3947
  else\
3923
  else\
3948
  {\
3924
  {\
3949
   return reply +\"\\n\"+input_reply;\
3925
   return reply +\"\\n\"+input_reply;\
3950
  }\
3926
  }\
3951
 }\
3927
 }\
3952
 else\
3928
 else\
3953
 {\
3929
 {\
3954
  if( typeof userdraw_text != 'undefined' ){\
3930
  if( typeof userdraw_text != 'undefined' ){\
3955
   return reply +\"\\n\"+userdraw_text;\
3931
   return reply +\"\\n\"+userdraw_text;\
3956
  }\
3932
  }\
3957
  else\
3933
  else\
3958
  {\
3934
  {\
3959
   return reply;\
3935
   return reply;\
Line 4020... Line 3996...
4020
}
3996
}
4021
 return;
3997
 return;
4022
}
3998
}
4023
 
3999
 
4024
 
4000
 
4025
/*
4001
/*
4026
 add drawfunction :
4002
 add drawfunction :
4027
 - functions used by userdraw_primitives (circle,rect,path,triangle...)
4003
 - functions used by userdraw_primitives (circle,rect,path,triangle...)
4028
 - things not covered by the drag&drop library (static objects like parallel, lattice ,gridfill , imagefill)
4004
 - things not covered by the drag&drop library (static objects like parallel, lattice ,gridfill , imagefill)
4029
 - grid / mathml
4005
 - grid / mathml
4030
 - will not scale or zoom in
4006
 - will not scale or zoom in
4031
 - will not be filled via pixel operations like fill / floodfill / filltoborder / clickfill
4007
 - will not be filled via pixel operations like fill / floodfill / filltoborder / clickfill
4032
 - is printed directly into 'js_include_file'
4008
 - is printed directly into 'js_include_file'
4033
*/
4009
*/
4034
 
4010
 
4035
void add_javascript_functions(int js_functions[],int canvas_root_id){
4011
void add_javascript_functions(int js_functions[],int canvas_root_id){
4036
int i;
4012
int i;
4037
for(i = 0 ; i < MAX_JS_FUNCTIONS; i++){
4013
for(i = 0 ; i < MAX_JS_FUNCTIONS; i++){
Line 4131... Line 4107...
4131
  canvas_bg_div.style.backgroundPosition= \"left \"+ml+\"px top \"+mh+\"px\";\
4107
  canvas_bg_div.style.backgroundPosition= \"left \"+ml+\"px top \"+mh+\"px\";\
4132
  canvas_bg_div.style.backgroundSize = width+\"px \"+height+\"px\";\
4108
  canvas_bg_div.style.backgroundSize = width+\"px \"+height+\"px\";\
4133
  canvas_bg_div.style.backgroundRepeat = \"no-repeat\";\
4109
  canvas_bg_div.style.backgroundRepeat = \"no-repeat\";\
4134
  canvas_bg_div.style.backgroundPosition= sx+\"px \"+sy+\"px\";\
4110
  canvas_bg_div.style.backgroundPosition= sx+\"px \"+sy+\"px\";\
4135
  canvas_bg_div.style.backgroundImage = \"url(\" + URL + \")\";\
4111
  canvas_bg_div.style.backgroundImage = \"url(\" + URL + \")\";\
4136
 };\
4112
 };\
4137
};",canvas_root_id);
4113
};",canvas_root_id);    
4138
    break;
4114
    break;
4139
 
4115
   
4140
    case DRAW_ZOOM_BUTTONS: /* 6 rectangles 15x15 px  forbidden zone for drawing : y < ysize - 15*/
4116
    case DRAW_ZOOM_BUTTONS: /* 6 rectangles 15x15 px  forbidden zone for drawing : y < ysize - 15*/
4141
fprintf(js_include_file,"\n<!-- draw zoom buttons -->\n\
4117
fprintf(js_include_file,"\n<!-- draw zoom buttons -->\n\
4142
draw_zoom_buttons = function(canvas_type,color,opacity){\
4118
draw_zoom_buttons = function(canvas_type,color,opacity){\
4143
 var obj;\
4119
 var obj;\
4144
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4120
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4145
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4121
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4146
 }\
4122
 }\
4147
 else\
4123
 else\
4148
 {\
4124
 {\
4149
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4125
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4150
 };\
4126
 };\
4151
 var ctx = obj.getContext(\"2d\");\
4127
 var ctx = obj.getContext(\"2d\");\
4152
 ctx.font =\"18px Ariel\";\
4128
 ctx.font =\"18px Ariel\";\
4153
 ctx.textAlign = \"right\";\
4129
 ctx.textAlign = \"right\";\
4154
 ctx.fillStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4130
 ctx.fillStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4155
 ctx.fillText(\"+\",xsize,ysize);\
4131
 ctx.fillText(\"+\",xsize,ysize);\
4156
 ctx.fillText(\"\\u2212\",xsize - 15,ysize);\
4132
 ctx.fillText(\"\\u2212\",xsize - 15,ysize);\
4157
 ctx.fillText(\"\\u2192\",xsize - 30,ysize-2);\
4133
 ctx.fillText(\"\\u2192\",xsize - 30,ysize-2);\
4158
 ctx.fillText(\"\\u2190\",xsize - 45,ysize-2);\
4134
 ctx.fillText(\"\\u2190\",xsize - 45,ysize-2);\
4159
 ctx.fillText(\"\\u2191\",xsize - 60,ysize-2);\
4135
 ctx.fillText(\"\\u2191\",xsize - 60,ysize-2);\
4160
 ctx.fillText(\"\\u2193\",xsize - 75,ysize-2);\
4136
 ctx.fillText(\"\\u2193\",xsize - 75,ysize-2);\
4161
 ctx.fillText(\"\\u00D7\",xsize - 90,ysize-2);\
4137
 ctx.fillText(\"\\u00D7\",xsize - 90,ysize-2);\
4162
 ctx.stroke();\
4138
 ctx.stroke();\
4163
};",canvas_root_id,canvas_root_id,canvas_root_id);
4139
};",canvas_root_id,canvas_root_id,canvas_root_id);
4164
 
4140
   
4165
    break;
4141
    break;
4166
    case DRAW_GRIDFILL:/* not used for userdraw */
4142
    case DRAW_GRIDFILL:/* not used for userdraw */
4167
fprintf(js_include_file,"\n<!-- draw gridfill -->\n\
4143
fprintf(js_include_file,"\n<!-- draw gridfill -->\n\
4168
draw_gridfill = function(canvas_type,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize){\
4144
draw_gridfill = function(canvas_type,x0,y0,dx,dy,linewidth,color,opacity,xsize,ysize){\
4169
 var obj;\
4145
 var obj;\
4170
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4146
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4171
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4147
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4172
 }\
4148
 }\
4173
 else\
4149
 else\
4174
 {\
4150
 {\
4175
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4151
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4176
 };\
4152
 };\
4177
 var ctx = obj.getContext(\"2d\");\
4153
 var ctx = obj.getContext(\"2d\");\
4178
 var x,y;\
4154
 var x,y;\
4179
 ctx.save();\
4155
 ctx.save();\
4180
 ctx.strokeStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4156
 ctx.strokeStyle=\"rgba(\"+color+\",\"+opacity+\")\";\
4181
 snap_x = dx;snap_y = dy;\
4157
 snap_x = dx;snap_y = dy;\
Line 4189... Line 4165...
4189
 };\
4165
 };\
4190
 ctx.stroke();\
4166
 ctx.stroke();\
4191
 ctx.restore();\
4167
 ctx.restore();\
4192
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4168
 return;};",canvas_root_id,canvas_root_id,canvas_root_id);
4193
    break;
4169
    break;
4194
 
4170
   
4195
    case DRAW_IMAGEFILL:/* not  used for userdraw */
4171
    case DRAW_IMAGEFILL:/* not  used for userdraw */
4196
fprintf(js_include_file,"\n<!-- draw imagefill -->\n\
4172
fprintf(js_include_file,"\n<!-- draw imagefill -->\n\
4197
draw_imagefill = function(canvas_type,x0,y0,URL,xsize,ysize){\
4173
draw_imagefill = function(canvas_type,x0,y0,URL,xsize,ysize){\
4198
 var obj;\
4174
 var obj;\
4199
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4175
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
Line 4231... Line 4207...
4231
 };\
4207
 };\
4232
 ctx.restore();\
4208
 ctx.restore();\
4233
 return;\
4209
 return;\
4234
};",canvas_root_id,canvas_root_id,canvas_root_id);
4210
};",canvas_root_id,canvas_root_id,canvas_root_id);
4235
    break;
4211
    break;
4236
 
4212
   
4237
    case DRAW_DOTFILL:/* not  used for userdraw */
4213
    case DRAW_DOTFILL:/* not  used for userdraw */
4238
fprintf(js_include_file,"\n<!-- draw dotfill -->\n\
4214
fprintf(js_include_file,"\n<!-- draw dotfill -->\n\
4239
draw_dotfill = function(canvas_type,x0,y0,dx,dy,radius,color,opacity,xsize,ysize){\
4215
draw_dotfill = function(canvas_type,x0,y0,dx,dy,radius,color,opacity,xsize,ysize){\
4240
 var obj;\
4216
 var obj;\
4241
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4217
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
Line 4306... Line 4282...
4306
 ctx.stroke();\
4282
 ctx.stroke();\
4307
 ctx.restore();\
4283
 ctx.restore();\
4308
 return;\
4284
 return;\
4309
 }",canvas_root_id,canvas_root_id,canvas_root_id);
4285
 }",canvas_root_id,canvas_root_id,canvas_root_id);
4310
    break;
4286
    break;
4311
 
4287
   
4312
    case DRAW_HATCHFILL:/* not used for userdraw */
4288
    case DRAW_HATCHFILL:/* not used for userdraw */
4313
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4289
fprintf(js_include_file,"\n<!-- draw hatch fill -->\n\
4314
draw_hatchfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4290
draw_hatchfill = function(canvas_type,x0,y0,dx,dy,linewidth,stroke_color,stroke_opacity,xsize,ysize){\
4315
  var obj;\
4291
  var obj;\
4316
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4292
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
4317
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4293
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
4318
 }\
4294
 }\
4319
 else\
4295
 else\
4320
 {\
4296
 {\
4321
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4297
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4322
 };\
4298
 };\
4323
 var ctx = obj.getContext(\"2d\");\
4299
 var ctx = obj.getContext(\"2d\");\
4324
 var x;\
4300
 var x;\
4325
 var y;\
4301
 var y;\
4326
 ctx.save();\
4302
 ctx.save();\
4327
 ctx.lineWidth = linewidth;\
4303
 ctx.lineWidth = linewidth;\
Line 4329... Line 4305...
4329
 y = ysize;\
4305
 y = ysize;\
4330
 for( x = x0 ; x < xsize ; x = x + dx ){\
4306
 for( x = x0 ; x < xsize ; x = x + dx ){\
4331
  ctx.moveTo(x,y0);\
4307
  ctx.moveTo(x,y0);\
4332
  ctx.lineTo(xsize,y);\
4308
  ctx.lineTo(xsize,y);\
4333
  y = y - dy;\
4309
  y = y - dy;\
4334
 };\
4310
 };\
4335
 y = y0;\
4311
 y = y0;\
4336
 for( x = xsize ; x >= dx ; x = x - dx){\
4312
 for( x = xsize ; x >= dx ; x = x - dx){\
4337
  ctx.moveTo(x,ysize);\
4313
  ctx.moveTo(x,ysize);\
4338
  ctx.lineTo(x0,y);\
4314
  ctx.lineTo(x0,y);\
4339
  y = y + dy;\
4315
  y = y + dy;\
Line 4364... Line 4340...
4364
};");
4340
};");
4365
    break;
4341
    break;
4366
    case DRAW_POLYLINE:/* user for userdraw : draw lines through points */
4342
    case DRAW_POLYLINE:/* user for userdraw : draw lines through points */
4367
fprintf(js_include_file,"\n<!-- draw polyline -->\n\
4343
fprintf(js_include_file,"\n<!-- draw polyline -->\n\
4368
draw_polyline = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4344
draw_polyline = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4369
 ctx.save();\
4345
 ctx.save();\
4370
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4346
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4371
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4347
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4372
 ctx.lineWidth = line_width;\
4348
 ctx.lineWidth = line_width;\
4373
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4349
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4374
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4350
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4375
 ctx.clearRect(0,0,xsize,ysize);\
4351
 ctx.clearRect(0,0,xsize,ysize);\
Line 4388... Line 4364...
4388
 };\
4364
 };\
4389
 ctx.restore();\
4365
 ctx.restore();\
4390
 return;\
4366
 return;\
4391
};");
4367
};");
4392
    break;
4368
    break;
4393
 
4369
   
4394
    case DRAW_SEGMENTS:/*  used for userdraw */
4370
    case DRAW_SEGMENTS:/*  used for userdraw */
4395
fprintf(js_include_file,"\n<!-- draw segments -->\n\
4371
fprintf(js_include_file,"\n<!-- draw segments -->\n\
4396
draw_segments = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4372
draw_segments = function(ctx,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,use_rotate,angle,use_translate,vector){\
4397
 ctx.save();\
4373
 ctx.save();\
4398
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4374
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
Line 4402... Line 4378...
4402
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4378
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4403
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4379
 for(var p = 0 ; p < x_points.length ; p = p+2 ){\
4404
  ctx.beginPath();\
4380
  ctx.beginPath();\
4405
  ctx.moveTo(x_points[p],y_points[p]);\
4381
  ctx.moveTo(x_points[p],y_points[p]);\
4406
  ctx.lineTo(x_points[p+1],y_points[p+1]);\
4382
  ctx.lineTo(x_points[p+1],y_points[p+1]);\
4407
  ctx.closePath();\
4383
  ctx.closePath();\
4408
  ctx.stroke();\
4384
  ctx.stroke();\
4409
  }\
4385
  }\
4410
  ctx.restore();\
4386
  ctx.restore();\
4411
  return;\
4387
  return;\
4412
 };");
4388
 };");
4413
    break;
4389
    break;
4414
 
4390
   
4415
    case DRAW_LINES:/*  used for userdraw */
4391
    case DRAW_LINES:/*  used for userdraw */
4416
fprintf(js_include_file,"\n<!-- draw lines -->\n\
4392
fprintf(js_include_file,"\n<!-- draw lines -->\n\
4417
function calc_line(x1,x2,y1,y2){\
4393
function calc_line(x1,x2,y1,y2){\
4418
 var marge = 2;\
4394
 var marge = 2;\
4419
 if(x1 < x2+marge && x1>x2-marge){\
4395
 if(x1 < x2+marge && x1>x2-marge){\
Line 4521... Line 4497...
4521
  if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();};\
4497
  if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();};\
4522
  ctx.stroke();\
4498
  ctx.stroke();\
4523
 }\
4499
 }\
4524
 ctx.restore();\
4500
 ctx.restore();\
4525
};");
4501
};");
4526
    break;
4502
    break;
4527
 
4503
 
4528
    case DRAW_ELLIPSES:/* not  used for userdraw */
4504
    case DRAW_ELLIPSES:/* not  used for userdraw */
4529
fprintf(js_include_file,"\n<!-- draw ellipses -->\n\
4505
fprintf(js_include_file,"\n<!-- draw ellipses -->\n\
4530
draw_ellipses = function(canvas_type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
4506
draw_ellipses = function(canvas_type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
4531
 var obj;\
4507
 var obj;\
Line 4535... Line 4511...
4535
 else\
4511
 else\
4536
 {\
4512
 {\
4537
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4513
  obj = create_canvas%d(canvas_type,xsize,ysize);\
4538
 };\
4514
 };\
4539
 var ctx = obj.getContext(\"2d\");\
4515
 var ctx = obj.getContext(\"2d\");\
4540
 ctx.save();\
4516
 ctx.save();\
4541
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4517
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4542
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4518
 if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
4543
 var cx,cy,ry,rx;\
4519
 var cx,cy,ry,rx;\
4544
 ctx.lineWidth = line_width;\
4520
 ctx.lineWidth = line_width;\
4545
 if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";};\
4521
 if( use_filled == 1 ){ctx.fillStyle =\"rgba(\"+fill_color+\",\"+fill_opacity+\")\";};\
4546
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4522
 if(use_dashed == 1){if(ctx.setLineDash){ctx.setLineDash([dashtype0,dashtype1]);}else{ctx.mozDash = [dashtype0,dashtype1];};};\
4547
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4523
 ctx.strokeStyle=\"rgba(\"+stroke_color+\",\"+stroke_opacity+\")\";\
4548
 for(var p=0;p< x_points.length;p = p+2){\
4524
 for(var p=0;p< x_points.length;p = p+2){\
4549
  ctx.beginPath();\
4525
  ctx.beginPath();\
4550
  cx = x_points[p];cy = y_points[p];rx = 0.25*x_points[p+1];ry = 0.25*y_points[p+1];\
4526
  cx = x_points[p];cy = y_points[p];rx = 0.25*x_points[p+1];ry = 0.25*y_points[p+1];\
4551
  ctx.translate(cx - rx, cy - ry);\
4527
  ctx.translate(cx - rx, cy - ry);\
Line 4555... Line 4531...
4555
  ctx.stroke();\
4531
  ctx.stroke();\
4556
 };\
4532
 };\
4557
 ctx.restore();\
4533
 ctx.restore();\
4558
};",canvas_root_id,canvas_root_id,canvas_root_id);
4534
};",canvas_root_id,canvas_root_id,canvas_root_id);
4559
    break;
4535
    break;
4560
 
4536
 
4561
    case DRAW_PATHS: /*  used for userdraw */
4537
    case DRAW_PATHS: /*  used for userdraw */
4562
fprintf(js_include_file,"\n<!-- draw paths -->\n\
4538
fprintf(js_include_file,"\n<!-- draw paths -->\n\
4563
draw_paths = function(ctx,x_points,y_points,line_width,closed_path,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
4539
draw_paths = function(ctx,x_points,y_points,line_width,closed_path,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
4564
 ctx.save();\
4540
 ctx.save();\
4565
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
4541
 if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
Line 4575... Line 4551...
4575
 if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4551
 if(use_filled == 1){ctx.fillStyle = \"rgba(\"+fill_color+\",\"+fill_opacity+\")\";ctx.fill();}\
4576
 ctx.stroke();\
4552
 ctx.stroke();\
4577
 ctx.restore();\
4553
 ctx.restore();\
4578
 return;\
4554
 return;\
4579
};");
4555
};");
4580
 
4556
   
4581
    break;
4557
    break;
4582
    case DRAW_ARROWS:/*  used for userdraw */
4558
    case DRAW_ARROWS:/*  used for userdraw */
4583
fprintf(js_include_file,"\n<!-- draw arrows -->\n\
4559
fprintf(js_include_file,"\n<!-- draw arrows -->\n\
4584
draw_arrows = function(ctx,x_points,y_points,arrow_head,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,type,use_rotate,angle,use_translate,vector){\
4560
draw_arrows = function(ctx,x_points,y_points,arrow_head,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,dashtype1,type,use_rotate,angle,use_translate,vector){\
4585
 ctx.save();\
4561
 ctx.save();\
Line 4650... Line 4626...
4650
 src.type = \"video/mp4\";\
4626
 src.type = \"video/mp4\";\
4651
 src.src = URL;\
4627
 src.src = URL;\
4652
 video.appendChild(src);\
4628
 video.appendChild(src);\
4653
 video.load();\
4629
 video.load();\
4654
 return;\
4630
 return;\
4655
};");
4631
};");    
4656
    break;
4632
    break;
4657
 
4633
   
4658
    case DRAW_AUDIO:/* not used for userdraw */
4634
    case DRAW_AUDIO:/* not used for userdraw */
4659
fprintf(js_include_file,"\n<!-- draw audio -->\n\
4635
fprintf(js_include_file,"\n<!-- draw audio -->\n\
4660
draw_audio = function(canvas_root_id,x,y,w,h,loop,visible,URL1,URL2){\
4636
draw_audio = function(canvas_root_id,x,y,w,h,loop,visible,URL1,URL2){\
4661
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4637
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4662
 var audio_div = document.createElement(\"div\");\
4638
 var audio_div = document.createElement(\"div\");\
Line 4679... Line 4655...
4679
 var src2 = document.createElement(\"source\");\
4655
 var src2 = document.createElement(\"source\");\
4680
 src2.type = \"audio/mpeg\";\
4656
 src2.type = \"audio/mpeg\";\
4681
 src2.src = URL2;\
4657
 src2.src = URL2;\
4682
 audio.appendChild(src2);\
4658
 audio.appendChild(src2);\
4683
 audio.load();\
4659
 audio.load();\
4684
 return;\
4660
 return;\
4685
};");
4661
};");
4686
    break;
4662
    break;
4687
 
4663
   
4688
    case DRAW_HTTP:/* not  used for userdraw */
4664
    case DRAW_HTTP:/* not  used for userdraw */
4689
fprintf(js_include_file,"\n<!-- draw http -->\n\
4665
fprintf(js_include_file,"\n<!-- draw http -->\n\
4690
draw_http = function(canvas_root_id,x,y,w,h,URL){\
4666
draw_http = function(canvas_root_id,x,y,w,h,URL){\
4691
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4667
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4692
 var http_div = document.createElement(\"div\");\
4668
 var http_div = document.createElement(\"div\");\
Line 4697... Line 4673...
4697
 iframe.setAttribute(\"width\",w);\
4673
 iframe.setAttribute(\"width\",w);\
4698
 iframe.setAttribute(\"height\",h);\
4674
 iframe.setAttribute(\"height\",h);\
4699
 return;\
4675
 return;\
4700
};");
4676
};");
4701
    break;
4677
    break;
4702
 
4678
   
4703
    case DRAW_XML:
4679
    case DRAW_XML:
4704
fprintf(js_include_file,"\n<!-- draw xml -->\n\
4680
fprintf(js_include_file,"\n<!-- draw xml -->\n\
4705
draw_xml = function(canvas_root_id,x,y,w,h,mathml,onclick){\
4681
draw_xml = function(canvas_root_id,x,y,w,h,mathml,onclick){\
4706
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4682
 var canvas_div = document.getElementById(\"canvas_div\"+canvas_root_id);\
4707
 var xml_div = document.createElement(\"div\");\
4683
 var xml_div = document.createElement(\"div\");\
Line 4721... Line 4697...
4721
 return;\
4697
 return;\
4722
};"
4698
};"
4723
);
4699
);
4724
    break;
4700
    break;
4725
    case DRAW_SGRAPH:
4701
    case DRAW_SGRAPH:
4726
/*
4702
/*
4727
 xstart = given
4703
 xstart = given
4728
 ystart = given
4704
 ystart = given
4729
 sgraph(canvas_type,precision,xmajor,ymajor,xminor,yminor,majorcolor,minorcolor,fontfamily)
4705
 sgraph(canvas_type,precision,xmajor,ymajor,xminor,yminor,majorcolor,minorcolor,fontfamily)
4730
*/
4706
*/
4731
fprintf(js_include_file,"\n<!-- draw sgraph -->\n\
4707
fprintf(js_include_file,"\n<!-- draw sgraph -->\n\
Line 4915... Line 4891...
4915
   ctx.fillStyle = \'#000000\';\
4891
   ctx.fillStyle = \'#000000\';\
4916
   var txt_size = ctx.measureText(xaxislabel).width + 4 ;\
4892
   var txt_size = ctx.measureText(xaxislabel).width + 4 ;\
4917
   ctx.fillText(xaxislabel,xsize - txt_size, zero_y - 7);\
4893
   ctx.fillText(xaxislabel,xsize - txt_size, zero_y - 7);\
4918
 };\
4894
 };\
4919
 if( typeof yaxislabel !== 'undefined'){\
4895
 if( typeof yaxislabel !== 'undefined'){\
4920
   ctx.save();\
4896
   ctx.save();\
4921
   ctx.fillStyle = \'#000000\';\
4897
   ctx.fillStyle = \'#000000\';\
4922
   var txt_size = ctx.measureText(yaxislabel).width;\
4898
   var txt_size = ctx.measureText(yaxislabel).width;\
4923
   ctx.translate(zero_x+8 + font_size,txt_size+font_size);\
4899
   ctx.translate(zero_x+8 + font_size,txt_size+font_size);\
4924
   ctx.rotate(-0.5*Math.PI);\
4900
   ctx.rotate(-0.5*Math.PI);\
4925
   ctx.fillText(yaxislabel,0,0);\
4901
   ctx.fillText(yaxislabel,0,0);\
Line 5114... Line 5090...
5114
    var y_text = y_strings[p+1];\
5090
    var y_text = y_strings[p+1];\
5115
    var f = 1.4;\
5091
    var f = 1.4;\
5116
    corr = 2 + tics_length + ctx.measureText(y_text).width;\
5092
    corr = 2 + tics_length + ctx.measureText(y_text).width;\
5117
    if( corr > zero_x){corr = parseInt(zero_x+2); }\
5093
    if( corr > zero_x){corr = parseInt(zero_x+2); }\
5118
    ctx.fillText(y_text,zero_x - corr,y_nums);\
5094
    ctx.fillText(y_text,zero_x - corr,y_nums);\
5119
   };\
5095
   };\
5120
  }\
5096
  }\
5121
  else\
5097
  else\
5122
  {\
5098
  {\
5123
   corr = 0;cnt = px2y(zero_y);skip = 1;\
5099
   corr = 0;cnt = px2y(zero_y);skip = 1;\
5124
   for( var p = zero_y ; p < ysize ; p = p+ystep){\
5100
   for( var p = zero_y ; p < ysize ; p = p+ystep){\
5125
    if(skip == 0 ){\
5101
    if(skip == 0 ){\
5126
     skip = parseInt(1.4*font_size/ystep);\
5102
     skip = parseInt(1.4*font_size/ystep);\
5127
     disp_cnt = cnt.toFixed(prec);\
5103
     disp_cnt = cnt.toFixed(prec);\
5128
     if(f_y == 1){corr = 2 + tics_length + ctx.measureText(disp_cnt).width;}\
5104
     if(f_y == 1){corr = 2 + tics_length + ctx.measureText(disp_cnt).width;}\
5129
     ctx.fillText(disp_cnt,parseInt(zero_x - corr),parseInt(p+(0.4*font_size)));\
5105
     ctx.fillText(disp_cnt,parseInt(zero_x - corr),parseInt(p+(0.4*font_size)));\
5130
    }\
5106
    }\
5131
    else\
5107
    else\
5132
    {\
5108
    {\
5133
     skip--;\
5109
     skip--;\
5134
    };\
5110
    };\
5135
    cnt = cnt - ymajor;\
5111
    cnt = cnt - ymajor;\
5136
   }\
5112
   }\
Line 5216... Line 5192...
5216
 for( var p = 0; p < idx ; p++ ){\
5192
 for( var p = 0; p < idx ; p++ ){\
5217
  ctx.beginPath();\
5193
  ctx.beginPath();\
5218
  ctx.strokeStyle = barcolor[p];\
5194
  ctx.strokeStyle = barcolor[p];\
5219
  ctx.fillStyle = barcolor[p];\
5195
  ctx.fillStyle = barcolor[p];\
5220
  ctx.rect(bar_x[p]-0.5*dx,bar_y[p],dx,zero_y - bar_y[p]);\
5196
  ctx.rect(bar_x[p]-0.5*dx,bar_y[p],dx,zero_y - bar_y[p]);\
5221
  ctx.fill();\
5197
  ctx.fill();\
5222
  ctx.stroke();\
5198
  ctx.stroke();\
5223
  ctx.closePath();\
5199
  ctx.closePath();\
5224
 };\
5200
 };\
5225
};\
5201
};\
5226
if( typeof legend%d  !== 'undefined' ){\
5202
if( typeof legend%d  !== 'undefined' ){\
5227
 ctx.globalAlpha = 1.0;\
5203
 ctx.globalAlpha = 1.0;\
5228
 ctx.font = \"bold \"+font_size+\"px Ariel\";\
5204
 ctx.font = \"bold \"+font_size+\"px Ariel\";\
Line 5251... Line 5227...
5251
};\
5227
};\
5252
ctx.restore();\
5228
ctx.restore();\
5253
return;\
5229
return;\
5254
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5230
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5255
    break;
5231
    break;
5256
 
5232
   
5257
    case DRAW_PIECHART:
5233
    case DRAW_PIECHART:
5258
fprintf(js_include_file,"\n<!-- draw piechars -->\n\
5234
fprintf(js_include_file,"\n<!-- draw piechars -->\n\
5259
function draw_piechart(canvas_type,x_center,y_center,radius, data_color_list,fill_opacity,font_size,font_family){\
5235
function draw_piechart(canvas_type,x_center,y_center,radius, data_color_list,fill_opacity,font_size,font_family){\
5260
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5236
 if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5261
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
5237
  obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
Line 5307... Line 5283...
5307
   y_offset = parseInt(y_offset + 1.5*font_size);\
5283
   y_offset = parseInt(y_offset + 1.5*font_size);\
5308
  };\
5284
  };\
5309
 };\
5285
 };\
5310
 ctx.restore();\
5286
 ctx.restore();\
5311
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5287
};",canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id,canvas_root_id);
5312
 
5288
   
5313
    break;
5289
    break;
5314
    case DRAW_ARCS:
5290
    case DRAW_ARCS:
5315
fprintf(js_include_file,"\n<!-- draw arcs -->\n\
5291
fprintf(js_include_file,"\n<!-- draw arcs -->\n\
5316
draw_arc = function(canvas_type,xc,yc,r,start,end,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5292
draw_arc = function(canvas_type,xc,yc,r,start,end,line_width,stroke_color,stroke_opacity,use_filled,fill_color,fill_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5317
 var obj;\
5293
 var obj;\
Line 5356... Line 5332...
5356
    ctx.stroke();\
5332
    ctx.stroke();\
5357
    ctx.closePath();\
5333
    ctx.closePath();\
5358
 }\
5334
 }\
5359
 ctx.restore();\
5335
 ctx.restore();\
5360
};",canvas_root_id,canvas_root_id,canvas_root_id);
5336
};",canvas_root_id,canvas_root_id,canvas_root_id);
5361
 
5337
   
5362
    break;
5338
    break;
5363
    case DRAW_TEXTS:
5339
    case DRAW_TEXTS:
5364
fprintf(js_include_file,"\n<!-- draw text -->\n\
5340
fprintf(js_include_file,"\n<!-- draw text -->\n\
5365
draw_text = function(canvas_type,x,y,font_size,font_family,stroke_color,stroke_opacity,angle2,text,use_rotate,angle,use_translate,vector){\
5341
draw_text = function(canvas_type,x,y,font_size,font_family,stroke_color,stroke_opacity,angle2,text,use_rotate,angle,use_translate,vector){\
5366
  var obj;\
5342
  var obj;\
5367
  if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5343
  if( document.getElementById(\"wims_canvas%d\"+canvas_type) ){\
5368
   obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
5344
   obj = document.getElementById(\"wims_canvas%d\"+canvas_type);\
5369
  }\
5345
  }\
5370
  else\
5346
  else\
5371
  {\
5347
  {\
5372
   obj = create_canvas%d(canvas_type,xsize,ysize);\
5348
   obj = create_canvas%d(canvas_type,xsize,ysize);\
5373
  };\
5349
  };\
5374
  var ctx = obj.getContext(\"2d\");\
5350
  var ctx = obj.getContext(\"2d\");\
5375
  if(angle2 == 0 && angle != 0){\
5351
  if(angle2 == 0 && angle != 0){\
5376
   ctx.save();\
5352
   ctx.save();\
5377
   if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
5353
   if(use_translate == 1 ){ctx.translate(vector[0],vector[1]);}\
5378
   if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
5354
   if(use_rotate == 1 ){ctx.rotate(angle*Math.PI/180);}\
5379
  };\
5355
  };\
5380
  if( font_family.indexOf('px') != null ){\
5356
  if( font_family.indexOf('px') != null ){\
5381
   ctx.font = font_family;\
5357
   ctx.font = font_family;\
5382
  }\
5358
  }\
5383
  else\
5359
  else\
5384
  {\
5360
  {\
Line 5393... Line 5369...
5393
   ctx.restore();\
5369
   ctx.restore();\
5394
  }else{ctx.fillText(text,x,y);};\
5370
  }else{ctx.fillText(text,x,y);};\
5395
 ctx.restore();\
5371
 ctx.restore();\
5396
 return;\
5372
 return;\
5397
 };",canvas_root_id,canvas_root_id,canvas_root_id);
5373
 };",canvas_root_id,canvas_root_id,canvas_root_id);
5398
 
5374
   
5399
    break;
5375
    break;
5400
    case DRAW_CURVE:
5376
    case DRAW_CURVE:
5401
fprintf(js_include_file,"\n<!-- draw curve -->\n\
5377
fprintf(js_include_file,"\n<!-- draw curve -->\n\
5402
draw_curve = function(canvas_type,type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5378
draw_curve = function(canvas_type,type,x_points,y_points,line_width,stroke_color,stroke_opacity,use_dashed,dashtype0,use_rotate,angle,use_translate,vector){\
5403
 var obj;\
5379
 var obj;\
Line 5430... Line 5406...
5430
 };\
5406
 };\
5431
 ctx.stroke();\
5407
 ctx.stroke();\
5432
 ctx.restore();\
5408
 ctx.restore();\
5433
};",canvas_root_id,canvas_root_id,canvas_root_id);
5409
};",canvas_root_id,canvas_root_id,canvas_root_id);
5434
    break;
5410
    break;
5435
 
5411
   
5436
    case DRAW_INPUTS:
5412
    case DRAW_INPUTS:
5437
fprintf(js_include_file,"\n<!-- draw input fields -->\n\
5413
fprintf(js_include_file,"\n<!-- draw input fields -->\n\
5438
draw_inputs = function(root_id,input_cnt,x,y,size,readonly,style,value){\
5414
draw_inputs = function(root_id,input_cnt,x,y,size,readonly,style,value){\
5439
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5415
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5440
var input = document.createElement(\"input\");\
5416
var input = document.createElement(\"input\");\
Line 5442... Line 5418...
5442
input.setAttribute(\"style\",\"position:absolute;left:\"+x+\"px;top:\"+y+\"px;\"+style);\
5418
input.setAttribute(\"style\",\"position:absolute;left:\"+x+\"px;top:\"+y+\"px;\"+style);\
5443
input.setAttribute(\"size\",size);\
5419
input.setAttribute(\"size\",size);\
5444
input.setAttribute(\"value\",value);\
5420
input.setAttribute(\"value\",value);\
5445
if( readonly == 0 ){ input.setAttribute(\"readonly\",\"readonly\");};\
5421
if( readonly == 0 ){ input.setAttribute(\"readonly\",\"readonly\");};\
5446
canvas_div.appendChild(input);};");
5422
canvas_div.appendChild(input);};");
5447
    break;
5423
    break;
5448
 
5424
   
5449
    case DRAW_TEXTAREAS:
5425
    case DRAW_TEXTAREAS:
5450
fprintf(js_include_file,"\n<!-- draw text area inputfields -->\n\
5426
fprintf(js_include_file,"\n<!-- draw text area inputfields -->\n\
5451
draw_textareas = function(root_id,input_cnt,x,y,cols,rows,readonly,style,value){\
5427
draw_textareas = function(root_id,input_cnt,x,y,cols,rows,readonly,style,value){\
5452
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5428
var canvas_div = document.getElementById(\"canvas_div\"+root_id);\
5453
var textarea = document.createElement(\"textarea\");\
5429
var textarea = document.createElement(\"textarea\");\
Line 5456... Line 5432...
5456
textarea.setAttribute(\"cols\",cols);\
5432
textarea.setAttribute(\"cols\",cols);\
5457
textarea.setAttribute(\"rows\",rows);\
5433
textarea.setAttribute(\"rows\",rows);\
5458
textarea.innerHTML = value;\
5434
textarea.innerHTML = value;\
5459
canvas_div.appendChild(textarea);};");
5435
canvas_div.appendChild(textarea);};");
5460
    break;
5436
    break;
5461
 
5437
   
5462
case DRAW_PIXELS:
5438
case DRAW_PIXELS:
5463
fprintf(js_include_file,"\n<!-- draw pixel -->\n\
5439
fprintf(js_include_file,"\n<!-- draw pixel -->\n\
5464
draw_setpixel = function(x,y,color,opacity,pixelsize){\
5440
draw_setpixel = function(x,y,color,opacity,pixelsize){\
5465
 var canvas = create_canvas%d(10,xsize,ysize);\
5441
 var canvas = create_canvas%d(10,xsize,ysize);\
5466
 var d = 0.5*pixelsize;\
5442
 var d = 0.5*pixelsize;\
Line 5938... Line 5914...
5938
void check_string_length(int L){
5914
void check_string_length(int L){
5939
 if(L<1 || L > MAX_BUFFER-1){
5915
 if(L<1 || L > MAX_BUFFER-1){
5940
  canvas_error("problem with your arguments to command...");
5916
  canvas_error("problem with your arguments to command...");
5941
 }
5917
 }
5942
 return;
5918
 return;
5943
}
5919
}
5944
 
5920
 
5945
 
5921
 
5946
int get_token(FILE *infile){
5922
int get_token(FILE *infile){
5947
        int     c,i=0;
5923
        int     c,i=0;
5948
        char    temp[MAX_INT], *input_type;
5924
        char    temp[MAX_INT], *input_type;
5949
        char    *line="line",
5925
        char    *line="line",
Line 6143... Line 6119...
6143
        temp[i]='\0';
6119
        temp[i]='\0';
6144
        input_type=(char*)my_newmem(strlen(temp));
6120
        input_type=(char*)my_newmem(strlen(temp));
6145
        snprintf(input_type,sizeof(temp),"%s",temp);
6121
        snprintf(input_type,sizeof(temp),"%s",temp);
6146
 
6122
 
6147
        if( strcmp(input_type, size) == 0 ){
6123
        if( strcmp(input_type, size) == 0 ){
6148
        free(input_type);
6124
        free(input_type);
6149
        return SIZE;
6125
        return SIZE;
6150
        }
6126
        }
6151
        if( strcmp(input_type, xrange) == 0 ){
6127
        if( strcmp(input_type, xrange) == 0 ){
6152
        free(input_type);
6128
        free(input_type);
6153
        return XRANGE;
6129
        return XRANGE;
Line 6449... Line 6425...
6449
        use_dashed = TRUE;
6425
        use_dashed = TRUE;
6450
        free(input_type);
6426
        free(input_type);
6451
        return HLINE;
6427
        return HLINE;
6452
        }
6428
        }
6453
        if( strcmp(input_type, frect) == 0 || strcmp(input_type, frectangle) == 0 ){
6429
        if( strcmp(input_type, frect) == 0 || strcmp(input_type, frectangle) == 0 ){
6454
        use_filled = TRUE;
6430
        use_filled = TRUE;
6455
        free(input_type);
6431
        free(input_type);
6456
        return RECT;
6432
        return RECT;
6457
        }
6433
        }
6458
        if( strcmp(input_type, fcircle) == 0  ||  strcmp(input_type, disk) == 0 ){
6434
        if( strcmp(input_type, fcircle) == 0  ||  strcmp(input_type, disk) == 0 ){
6459
        use_filled = TRUE;
6435
        use_filled = TRUE;
Line 6513... Line 6489...
6513
        if( strcmp(input_type, comment) == 0){
6489
        if( strcmp(input_type, comment) == 0){
6514
        free(input_type);
6490
        free(input_type);
6515
        return COMMENT;
6491
        return COMMENT;
6516
        }
6492
        }
6517
        if( strcmp(input_type, end) == 0){
6493
        if( strcmp(input_type, end) == 0){
6518
        free(input_type);
6494
        free(input_type);
6519
        return END;
6495
        return END;
6520
        }
6496
        }
6521
        if( strcmp(input_type, fellipse) == 0){
6497
        if( strcmp(input_type, fellipse) == 0){
6522
        free(input_type);
6498
        free(input_type);
6523
        use_filled = TRUE;
6499
        use_filled = TRUE;
6524
        return ELLIPSE;
6500
        return ELLIPSE;
6525
        }
6501
        }      
6526
        if( strcmp(input_type, blink) == 0 ){
6502
        if( strcmp(input_type, blink) == 0 ){
6527
        free(input_type);
6503
        free(input_type);
6528
        return BLINK;
6504
        return BLINK;
6529
        }
6505
        }
6530
        if( strcmp(input_type, button) == 0){
6506
        if( strcmp(input_type, button) == 0){
Line 6540... Line 6516...
6540
        return KILLTRANSLATION;
6516
        return KILLTRANSLATION;
6541
        }
6517
        }
6542
        if( strcmp(input_type, rotate) == 0){
6518
        if( strcmp(input_type, rotate) == 0){
6543
        free(input_type);
6519
        free(input_type);
6544
        return ROTATE;
6520
        return ROTATE;
6545
        }
6521
        }
6546
        if( strcmp(input_type, affine) == 0){
6522
        if( strcmp(input_type, affine) == 0){
6547
        free(input_type);
6523
        free(input_type);
6548
        return AFFINE;
6524
        return AFFINE;
6549
        }
6525
        }
6550
        if( strcmp(input_type, killaffine) == 0){
6526
        if( strcmp(input_type, killaffine) == 0){
6551
        free(input_type);
6527
        free(input_type);
6552
        return KILLAFFINE;
6528
        return KILLAFFINE;
6553
        }
6529
        }
6554
        if( strcmp(input_type, audio) == 0 ){
6530
        if( strcmp(input_type, audio) == 0 ){
6555
        free(input_type);
6531
        free(input_type);
6556
        return AUDIO;
6532
        return AUDIO;
6557
        }
6533
        }
6558
        if( strcmp(input_type, audioobject) == 0 ){
6534
        if( strcmp(input_type, audioobject) == 0 ){
6559
        free(input_type);
6535
        free(input_type);
6560
        return AUDIOOBJECT;
6536
        return AUDIOOBJECT;
6561
        }
6537
        }
6562
        if( strcmp(input_type, slider) == 0 ){
6538
        if( strcmp(input_type, slider) == 0 ){
6563
        free(input_type);
6539
        free(input_type);
6564
        return SLIDER;
6540
        return SLIDER;
6565
        }
6541
        }
6566
        if( strcmp(input_type, copy) == 0 ){
6542
        if( strcmp(input_type, copy) == 0 ){
6567
        free(input_type);
6543
        free(input_type);
6568
        return COPY;
6544
        return COPY;
6569
        }
6545
        }
6570
        if( strcmp(input_type, copyresized) == 0 ){
6546
        if( strcmp(input_type, copyresized) == 0 ){
6571
        free(input_type);
6547
        free(input_type);
6572
        return COPYRESIZED;
6548
        return COPYRESIZED;
6573
        }
6549
        }
6574
        if( strcmp(input_type, patternfill) == 0 ){
6550
        if( strcmp(input_type, patternfill) == 0 ){
Line 6586... Line 6562...
6586
        if( strcmp(input_type, dotfill) == 0 ){
6562
        if( strcmp(input_type, dotfill) == 0 ){
6587
        free(input_type);
6563
        free(input_type);
6588
        return DOTFILL;
6564
        return DOTFILL;
6589
        }
6565
        }
6590
        if( strcmp(input_type, gridfill) == 0 ){
6566
        if( strcmp(input_type, gridfill) == 0 ){
6591
        free(input_type);
6567
        free(input_type);
6592
        return GRIDFILL;
6568
        return GRIDFILL;
6593
        }
6569
        }
6594
        if( strcmp(input_type, imagefill) == 0 ){
6570
        if( strcmp(input_type, imagefill) == 0 ){
6595
        free(input_type);
6571
        free(input_type);
6596
        return IMAGEFILL;
6572
        return IMAGEFILL;
Line 6604... Line 6580...
6604
        return CLICKTILE;
6580
        return CLICKTILE;
6605
        }
6581
        }
6606
        if( strcmp(input_type, xlogscale) == 0 ){
6582
        if( strcmp(input_type, xlogscale) == 0 ){
6607
        free(input_type);
6583
        free(input_type);
6608
        return XLOGSCALE;
6584
        return XLOGSCALE;
6609
        }
6585
        }
6610
        if( strcmp(input_type, ylogscale) == 0 ){
6586
        if( strcmp(input_type, ylogscale) == 0 ){
6611
        free(input_type);
6587
        free(input_type);
6612
        return YLOGSCALE;
6588
        return YLOGSCALE;
6613
        }
6589
        }
6614
        if( strcmp(input_type, xylogscale) == 0 ){
6590
        if( strcmp(input_type, xylogscale) == 0 ){
6615
        free(input_type);
6591
        free(input_type);
6616
        return XYLOGSCALE;
6592
        return XYLOGSCALE;
6617
        }
6593
        }
6618
        if( strcmp(input_type, ylogscale) == 0 ){
6594
        if( strcmp(input_type, ylogscale) == 0 ){
Line 6630... Line 6606...
6630
        if( strcmp(input_type, intooltip) == 0 ){
6606
        if( strcmp(input_type, intooltip) == 0 ){
6631
        free(input_type);
6607
        free(input_type);
6632
        return INTOOLTIP;
6608
        return INTOOLTIP;
6633
        }
6609
        }
6634
        if( strcmp(input_type,video) == 0 ){
6610
        if( strcmp(input_type,video) == 0 ){
6635
        free(input_type);
6611
        free(input_type);
6636
        return VIDEO;
6612
        return VIDEO;
6637
        }
6613
        }
6638
        if( strcmp(input_type,floodfill) == 0 || strcmp(input_type,fill) == 0 ){
6614
        if( strcmp(input_type,floodfill) == 0 || strcmp(input_type,fill) == 0 ){
6639
        free(input_type);
6615
        free(input_type);
6640
        return FLOODFILL;
6616
        return FLOODFILL;
6641
        }
6617
        }      
6642
        if( strcmp(input_type,filltoborder) == 0 ){
6618
        if( strcmp(input_type,filltoborder) == 0 ){
6643
        free(input_type);
6619
        free(input_type);
6644
        return FILLTOBORDER;
6620
        return FILLTOBORDER;
6645
        }
6621
        }      
6646
        if( strcmp(input_type,clickfill) == 0 ){
6622
        if( strcmp(input_type,clickfill) == 0 ){
6647
        free(input_type);
6623
        free(input_type);
6648
        return CLICKFILL;
6624
        return CLICKFILL;
6649
        }
6625
        }      
6650
        if( strcmp(input_type, replyformat) == 0 ){
6626
        if( strcmp(input_type, replyformat) == 0 ){
6651
        free(input_type);
6627
        free(input_type);
6652
        return REPLYFORMAT;
6628
        return REPLYFORMAT;
6653
        }
6629
        }
6654
        if( strcmp(input_type, pixelsize) == 0 ){
6630
        if( strcmp(input_type, pixelsize) == 0 ){
Line 6758... Line 6734...
6758
        }
6734
        }
6759
        free(input_type);
6735
        free(input_type);
6760
        ungetc(c,infile);
6736
        ungetc(c,infile);
6761
        return 0;
6737
        return 0;
6762
}
6738
}
-
 
6739
 
-
 
6740