Subversion Repositories wimsdev

Rev

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

Rev 16882 Rev 16892
Line 2026... Line 2026...
2026
                    reset();
2026
                    reset();
2027
                    break;
2027
                    break;
2028
                    default:break;
2028
                    default:break;
2029
                }
2029
                }
2030
            }
2030
            }
-
 
2031
        break;
-
 
2032
 
-
 
2033
        case GROUP:
-
 
2034
        /*
-
 
2035
         @ group
-
 
2036
         @ keyword
-
 
2037
         @ work in 'progress'
-
 
2038
         @ all objects(*) after the command and until <a href="#kill">kill group</a> or <a href="#killslider">killslider</a> may be moved together with mouse moverments<br /> (*) for now all real canvas objects and latex / xml ; but no images (work in progress)
-
 
2039
         @ may be combined with slider driven movements or drag & drop
-
 
2040
         @%group%%size 400,400%xrange -10,10%yrange -10,10%axis%axisnumbering%precision 1%grid 2,2,grey,2,2,5,grey%precision 100%linewidth 4%rotationcenter 0,0%slider -2*pi,2*pi,300,40,angle active,rotate%snaptogrid%ftriangle 0,-4,-2,-2,4,--5,blue%fillcolor red%fcircle -4.4,4.4,40,blue%kill slider%slider -20,20,300,40,x active,x-slide%ftriangle -2,0,0,4,2,0,green%fcircle 4.4,4.5,40,red%kill slider%slider -20,20,300,40,y active,y-slide%fcircle 4,-4,40,green%linewidth 4%fcircle -4,-4,40,orange%kill slider%group%fcircle -4.4,4.5,10,blue%fcircle -5.4,4.5,10,blue%fcircle -6.4,4.5,10,blue%fcircle -4.4,8,16,green%fcircle -5.4,8,16,green%fcircle -6.4,8,16,green%mouse red,22%zoom red
-
 
2041
        */
-
 
2042
            use_slider++;
-
 
2043
            add_slider(2);
-
 
2044
            no_reset = TRUE;
-
 
2045
            int c = 0;
-
 
2046
            for(i=last_slider;i<=use_slider;i++){ int_data[c] = i; c++; }
-
 
2047
            my_sliders = data2js_array(int_data,use_slider - last_slider+1);
-
 
2048
            if( precision == 0 ){precision = 100;}
-
 
2049
            onclick = 5;
-
 
2050
            use_dragstuff = 2;
-
 
2051
            drag_type = 0;
-
 
2052
            js_function[INTERACTIVE] = 1;
-
 
2053
            fprintf(js_include_file,"var slider%d;dragdrop_precision = %d;use_dragdrop_reply = true;",use_slider,precision);
-
 
2054
            string_length = 1 + snprintf(NULL,0,"slider%d = new move_group(%d);\n",use_slider);
-
 
2055
            check_string_length(string_length);tmp_buffer = my_newmem(string_length);
-
 
2056
            snprintf(tmp_buffer,string_length  ,"slider%d = new move_group(%d);\n",use_slider,use_slider);
-
 
2057
            add_to_buffer(tmp_buffer);
2031
        break;
2058
        break;
2032
 
2059
 
2033
        case HALFLINE:
2060
        case HALFLINE:
2034
        /*
2061
        /*
2035
        @ demiline x1,y1,x2,y2,color
2062
        @ demiline x1,y1,x2,y2,color
Line 2108... Line 2135...
2108
        @ draws halflines starting in (x1:y1) and through (x2:y2) in color 'color' (colorname or hex) etc
2135
        @ draws halflines starting in (x1:y1) and through (x2:y2) in color 'color' (colorname or hex) etc
2109
        @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> indiviually
2136
        @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> indiviually
2110
        @%halflines%size 400,400%xrange -10,10%yrange -10,10%halflines red,-5,5,0,0,-5,-5,0,0
2137
        @%halflines%size 400,400%xrange -10,10%yrange -10,10%halflines red,-5,5,0,0,-5,-5,0,0
2111
        */
2138
        */
2112
            stroke_color=get_color(infile,0);
2139
            stroke_color=get_color(infile,0);
2113
            fill_color = stroke_color;
2140
            fill_color = stroke_color;
2114
            i=0;
2141
            i=0;
2115
            while( ! done ){     /* get next item until EOL*/
2142
            while( ! done ){     /* get next item until EOL*/
2116
                if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
2143
                if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
2117
                if(i%2 == 0 ){
2144
                if(i%2 == 0 ){
2118
                    double_data[i] = get_real(infile,0); /* x */
2145
                    double_data[i] = get_real(infile,0); /* x */
Line 2185... Line 2212...
2185
        */
2212
        */
2186
            js_function[DRAW_HATCHFILL] = 1;
2213
            js_function[DRAW_HATCHFILL] = 1;
2187
            if(js_function[DRAW_FILLTOBORDER] != 1 ){/* use only once */
2214
            if(js_function[DRAW_FILLTOBORDER] != 1 ){/* use only once */
2188
             js_function[DRAW_FILLTOBORDER] = 1;
2215
             js_function[DRAW_FILLTOBORDER] = 1;
2189
             add_js_filltoborder(canvas_type);
2216
             add_js_filltoborder(canvas_type);
2190
            }
2217
            }
2191
            decimals = find_number_of_digits(precision);
2218
            decimals = find_number_of_digits(precision);
2192
            for(i=0;i<5;i++){
2219
            for(i=0;i<5;i++){
2193
                switch(i){
2220
                switch(i){
2194
                    case 0: double_data[0] = get_real(infile,0); break; /* x */
2221
                    case 0: double_data[0] = get_real(infile,0); break; /* x */
2195
                    case 1: double_data[1] = get_real(infile,0); break; /* y  */
2222
                    case 1: double_data[1] = get_real(infile,0); break; /* y  */
2196
                    case 2: int_data[0] = (int) (get_real(infile,0)); break; /* dx pixel */
2223
                    case 2: int_data[0] = (int) (get_real(infile,0)); break; /* dx pixel */
2197
                    case 3: int_data[1] = (int) (get_real(infile,0)); break; /* dy pixel*/
2224
                    case 3: int_data[1] = (int) (get_real(infile,0)); break; /* dy pixel*/
2198
                    case 4: stroke_color = get_color(infile,1);
2225
                    case 4: stroke_color = get_color(infile,1);
Line 2348... Line 2375...
2348
            }
2375
            }
2349
            reset();
2376
            reset();
2350
            break;
2377
            break;
2351
 
2378
 
2352
        case IMAGEFILL:
2379
        case IMAGEFILL:
2353
        /*
2380
        /*
2354
        @ imagefill x,y,scaling to xsize &times; ysize?,image_url
2381
        @ imagefill x,y,scaling to xsize &times; ysize?,image_url
2355
        @ The next suitable <b>filled object</b> will be filled with "image_url" tiled
2382
        @ The next suitable <b>filled object</b> will be filled with "image_url" tiled
2356
        @ scaling to xsize &times; ysize ? ... 1 = yes 0 = no
2383
        @ scaling to xsize &times; ysize ? ... 1 = yes 0 = no
2357
        @ After pattern filling, the fill-color should be reset !
2384
        @ After pattern filling, the fill-color should be reset !
2358
        @ wims getins / image from class directory: imagefill 80,80,my_image.gif
2385
        @ wims getins / image from class directory: imagefill 80,80,my_image.gif
Line 2990... Line 3017...
2990
            js_function[INTERACTIVE] = 1;
3017
            js_function[INTERACTIVE] = 1;
2991
            break;
3018
            break;
2992
 
3019
 
2993
 
3020
 
2994
        case MOUSE_DEGREE:
3021
        case MOUSE_DEGREE:
2995
        /*
3022
        /*
2996
         @ mouse_degree color,fontsize
3023
         @ mouse_degree color,fontsize
2997
         @ will display the angle in degrees between x-axis, (0:0) and the cursor (x:y) in 'color' and 'font size'<br /> using a fontfamily Arial
3024
         @ will display the angle in degrees between x-axis, (0:0) and the cursor (x:y) in 'color' and 'font size'<br /> using a fontfamily Arial
2998
         @ The angle is positive in QI and QIII and the angle value is negative in QII and QIV
3025
         @ The angle is positive in QI and QIII and the angle value is negative in QII and QIV
2999
         @ note: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
3026
         @ note: use command 'mouse' at the end of your script code (the same is true for command 'zoom')
3000
         @%mouse_degree%size 400,400%xrange -10,10%yrange -10,10%userdraw arc,blue%precision 100000%mouse_degree red,22
3027
         @%mouse_degree%size 400,400%xrange -10,10%yrange -10,10%userdraw arc,blue%precision 100000%mouse_degree red,22
Line 3953... Line 3980...
3953
         @ may be set draggable or onclick (every individual ray)
3980
         @ may be set draggable or onclick (every individual ray)
3954
         @%rays_onclick%size 400,400%xrange -10,10%yrange -10,10%onclick%rays blue,0,0,3,9,-3,5,-4,0,4,-9,7,9,-8,1,-1,-9
3981
         @%rays_onclick%size 400,400%xrange -10,10%yrange -10,10%onclick%rays blue,0,0,3,9,-3,5,-4,0,4,-9,7,9,-8,1,-1,-9
3955
         @%rays_drag_xy%size 400,400%xrange -10,10%yrange -10,10%drag xy%rays blue,0,0,3,9,-3,5,-4,0,4,-9,7,9,-8,1,-1,-9
3982
         @%rays_drag_xy%size 400,400%xrange -10,10%yrange -10,10%drag xy%rays blue,0,0,3,9,-3,5,-4,0,4,-9,7,9,-8,1,-1,-9
3956
        */
3983
        */
3957
            stroke_color=get_color(infile,0);
3984
            stroke_color=get_color(infile,0);
3958
            fill_color = stroke_color;
3985
            fill_color = stroke_color;
3959
            double_data[0] = get_real(infile,0);/* xc */
3986
            double_data[0] = get_real(infile,0);/* xc */
3960
            double_data[1] = get_real(infile,0);/* yc */
3987
            double_data[1] = get_real(infile,0);/* yc */
3961
            i=2;
3988
            i=2;
3962
            while( ! done ){     /* get next item until EOL*/
3989
            while( ! done ){     /* get next item until EOL*/
3963
                if(i > MAX_INT - 1){canvas_error("in command rays too many points / rays in argument: repeat command multiple times to fit");}
3990
                if(i > MAX_INT - 1){canvas_error("in command rays too many points / rays in argument: repeat command multiple times to fit");}
Line 4569... Line 4596...
4569
             int_data[c] = i; c++;
4596
             int_data[c] = i; c++;
4570
            }
4597
            }
4571
            my_sliders = data2js_array(int_data,use_slider - last_slider+1);
4598
            my_sliders = data2js_array(int_data,use_slider - last_slider+1);
4572
        break;
4599
        break;
4573
 
4600
 
4574
        case GROUP:
-
 
4575
            use_slider++;
-
 
4576
            add_slider(2);
-
 
4577
            no_reset = TRUE;
-
 
4578
            int c = 0;
-
 
4579
            for(i=last_slider;i<=use_slider;i++){ int_data[c] = i; c++; }
-
 
4580
            my_sliders = data2js_array(int_data,use_slider - last_slider+1);
-
 
4581
            if( precision == 0 ){precision = 100;}
-
 
4582
            onclick = 5;
-
 
4583
            use_dragstuff = 2;
-
 
4584
            drag_type = 0;
-
 
4585
            js_function[INTERACTIVE] = 1;
-
 
4586
            fprintf(js_include_file,"var slider%d;dragdrop_precision = %d;use_dragdrop_reply = true;",use_slider,precision);
-
 
4587
            string_length = 1 + snprintf(NULL,0,"slider%d = new move_group(%d);\n",use_slider);
-
 
4588
            check_string_length(string_length);tmp_buffer = my_newmem(string_length);
-
 
4589
            snprintf(tmp_buffer,string_length  ,"slider%d = new move_group(%d);\n",use_slider,use_slider);
-
 
4590
            add_to_buffer(tmp_buffer);
-
 
4591
 
-
 
4592
        /*
-
 
4593
         @ group
-
 
4594
         @ keyword
-
 
4595
         @ work in 'progress'
-
 
4596
         @ all objects(*) after the command and until <a href="#kill">kill group</a> or <a href="#killslider">killslider</a> may be moved together with mouse moverments<br /> (*) for now all real canvas objects and latex / xml ; but no images (work in progress)
-
 
4597
         @ may be combined with slider driven movements or drag & drop
-
 
4598
         @%group%%size 400,400%xrange -10,10%yrange -10,10%axis%axisnumbering%precision 1%grid 2,2,grey,2,2,5,grey%precision 100%linewidth 4%rotationcenter 0,0%slider -2*pi,2*pi,300,40,angle active,rotate%snaptogrid%ftriangle 0,-4,-2,-2,4,--5,blue%fillcolor red%fcircle -4.4,4.4,40,blue%kill slider%slider -20,20,300,40,x active,x-slide%ftriangle -2,0,0,4,2,0,green%fcircle 4.4,4.5,40,red%kill slider%slider -20,20,300,40,y active,y-slide%fcircle 4,-4,40,green%linewidth 4%fcircle -4,-4,40,orange%kill slider%group%fcircle -4.4,4.5,10,blue%fcircle -5.4,4.5,10,blue%fcircle -6.4,4.5,10,blue%fcircle -4.4,8,16,green%fcircle -5.4,8,16,green%fcircle -6.4,8,16,green%mouse red,22%zoom red
-
 
4599
        */
-
 
4600
        break;
-
 
4601
        case SGRAPH:
4601
        case SGRAPH:
4602
        /*
4602
        /*
4603
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
4603
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
4604
         @ primitive implementation of a ''broken scale`` graph...
4604
         @ primitive implementation of a ''broken scale`` graph...
4605
         @ not very versatile: only usable in combination with userdraw <br />eg no other objects will obey this "coordinate system"<br />if you want to place an object into this coordinate system, be aware that 10% or 20% of xsize and/or ysize is ''lost``.<br />Use these "formulas" to recalculate the virtual coordinates:<br />factor=0.8 in case xstart != xmin (or ystart != ymin)<br />factor=0.9 in case xstart = xmin (or ystart = ymin)<br />px_x_point = ((factor*xsize)/(xmax - xstart))*(x_point - xmax)+xsize<br />x_recalculated = px*(xmax - xmin)/xsize + $xmin<br />px_y_point = -1*factor*y_point*ysize/(ymax - ystart) + ymax*factor*ysize/(ymax - ystart)<br />y_recalculated = ymax - py*(ymax - ymin)/ysize<br />
4605
         @ not very versatile: only usable in combination with userdraw <br />eg no other objects will obey this "coordinate system"<br />if you want to place an object into this coordinate system, be aware that 10% or 20% of xsize and/or ysize is ''lost``.<br />Use these "formulas" to recalculate the virtual coordinates:<br />factor=0.8 in case xstart != xmin (or ystart != ymin)<br />factor=0.9 in case xstart = xmin (or ystart = ymin)<br />px_x_point = ((factor*xsize)/(xmax - xstart))*(x_point - xmax)+xsize<br />x_recalculated = px*(xmax - xmin)/xsize + $xmin<br />px_y_point = -1*factor*y_point*ysize/(ymax - ystart) + ymax*factor*ysize/(ymax - ystart)<br />y_recalculated = ymax - py*(ymax - ymin)/ysize<br />