Subversion Repositories wimsdev

Rev

Rev 18655 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18655 Rev 18656
Line 2246... Line 2246...
2246
              case 4: decimals = find_number_of_digits(precision);
2246
              case 4: decimals = find_number_of_digits(precision);
2247
                if(use_affine == TRUE ){ transform(2,2);}/* needs double_data[] */
2247
                if(use_affine == TRUE ){ transform(2,2);}/* needs double_data[] */
2248
                if( use_offset != 0 || drag_type != -1 ){int_data[2] = 1;}else{int_data[2] = 0;} /* only centered or not-centered */
2248
                if( use_offset != 0 || drag_type != -1 ){int_data[2] = 1;}else{int_data[2] = 0;} /* only centered or not-centered */
2249
                int_data[0] = x2px(double_data[0]);/* needs px */
2249
                int_data[0] = x2px(double_data[0]);/* needs px */
2250
                int_data[1] = y2px(double_data[1]);
2250
                int_data[1] = y2px(double_data[1]);
2251
                if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */
2251
                if( use_slider != -1 && onclick == 0){ onclick = 5; }/* no drag&onclick but slideable */
2252
                if( use_slider != -1 && drag_type != -1){ onclick = 5; }
2252
                if( use_slider != -1 && drag_type != -1){ onclick = 5; }
2253
                temp = get_string(infile,1);
2253
                temp = get_string(infile,1);
2254
                if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","\\\""); }
2254
                if( strstr(temp,"\"") != 0 ){ temp = str_replace(temp,"\"","\\\""); }
2255
                if( strstr(temp,"<img ")!= 0){URL="image";}else{URL="html";}
2255
                if( strstr(temp,"<img ")!= 0){URL="image";}else{URL="html";}
2256
                tmp_buffer=my_newmem(MAX_BUFFER);
2256
                tmp_buffer=my_newmem(MAX_BUFFER);
Line 2279... Line 2279...
2279
  */
2279
  */
2280
          js_function[DRAW_IMAGEFILL] = 1;
2280
          js_function[DRAW_IMAGEFILL] = 1;
2281
          if(js_function[DRAW_FILLTOBORDER] != 1 ){/* use only once */
2281
          if(js_function[DRAW_FILLTOBORDER] != 1 ){/* use only once */
2282
            js_function[DRAW_FILLTOBORDER] = 1;
2282
            js_function[DRAW_FILLTOBORDER] = 1;
2283
            add_js_filltoborder(canvas_type);
2283
            add_js_filltoborder(canvas_type);
2284
          }
2284
          }
2285
          for(i=0 ;i < 4 ; i++){
2285
          for(i=0 ;i < 4 ; i++){
2286
            switch(i){
2286
            switch(i){
2287
              case 0:int_data[0] = (int) (get_real(infile,0));break;
2287
              case 0:int_data[0] = (int) (get_real(infile,0));break;
2288
              case 1:int_data[1] = (int) (get_real(infile,0));break;
2288
              case 1:int_data[1] = (int) (get_real(infile,0));break;
2289
              case 2:int_data[2] = (int) (get_real(infile,0));break; /* 0 | 1 */
2289
              case 2:int_data[2] = (int) (get_real(infile,0));break; /* 0 | 1 */
Line 2378... Line 2378...
2378
  @ plotting multiple js-curves on the same canvas (for example if you want to use 'userdraw clickfill,color' on <a href="#canvastype">canvastype</a> number 111, use:<br> <code>jscurve red,fun1(x),fun2(x)...fun_n(x)</code>, you must specify individual multistrokecolors &amp; multistrokeopacity &amp; multilinewidth for these multiple js-curves to use different colors. Otherwise all curves will be the same color... Use commands like: <a href="#multistrokecolors">multistrokecolors</a>, <a href="#multilinewidth">multilinewidth</a>, <a href="#multidash">multidash</a>, <a href="#multistrokeopacity">multistroke</a>, <b>color</b> given for the command <code>jscurve color,formulas(x)</code> will not be used in that case... but the color argument must still be given in any case (otherwise syntax error...)
2378
  @ plotting multiple js-curves on the same canvas (for example if you want to use 'userdraw clickfill,color' on <a href="#canvastype">canvastype</a> number 111, use:<br> <code>jscurve red,fun1(x),fun2(x)...fun_n(x)</code>, you must specify individual multistrokecolors &amp; multistrokeopacity &amp; multilinewidth for these multiple js-curves to use different colors. Otherwise all curves will be the same color... Use commands like: <a href="#multistrokecolors">multistrokecolors</a>, <a href="#multilinewidth">multilinewidth</a>, <a href="#multidash">multidash</a>, <a href="#multistrokeopacity">multistroke</a>, <b>color</b> given for the command <code>jscurve color,formulas(x)</code> will not be used in that case... but the color argument must still be given in any case (otherwise syntax error...)
2379
  @%jscurve%size 400,400%xrange -10,10%yrange -10,10%multistrokecolors red,green,blue,orange%multilinewidth 1,2,3%multistrokeopacity 0.5,0.8,1.0%jscurve red,sin(x),1/sin(x),sin(x^2)
2379
  @%jscurve%size 400,400%xrange -10,10%yrange -10,10%multistrokecolors red,green,blue,orange%multilinewidth 1,2,3%multistrokeopacity 0.5,0.8,1.0%jscurve red,sin(x),1/sin(x),sin(x^2)
2380
  */
2380
  */
2381
          jsplot_cnt++;/* -1 --> 0 */
2381
          jsplot_cnt++;/* -1 --> 0 */
2382
          stroke_color = get_color(infile,0);
2382
          stroke_color = get_color(infile,0);
2383
          js_function[JS_MATH] = 1;
2383
          js_function[JS_MATH] = 1;
2384
          js_function[JS_PLOT] = 1;
2384
          js_function[JS_PLOT] = 1;
2385
          if( tmin != 0 && tmax !=0){use_parametric = TRUE;}
2385
          if( tmin != 0 && tmax !=0){use_parametric = TRUE;}
2386
          temp = get_string(infile,1);
2386
          temp = get_string(infile,1);
2387
          temp = str_replace(temp,",","\",\"");
2387
          temp = str_replace(temp,",","\",\"");
2388
          tmp_buffer=my_newmem(MAX_BUFFER);
2388
          tmp_buffer=my_newmem(MAX_BUFFER);
Line 2511... Line 2511...
2511
              case 0: double_data[0]=get_real(infile,0);break; /* x in x/y-range coord system -> pixel width */
2511
              case 0: double_data[0]=get_real(infile,0);break; /* x in x/y-range coord system -> pixel width */
2512
              case 1: double_data[1]=get_real(infile,0);break; /* y in x/y-range coord system  -> pixel height */
2512
              case 1: double_data[1]=get_real(infile,0);break; /* y in x/y-range coord system  -> pixel height */
2513
              case 2: decimals = find_number_of_digits(precision);
2513
              case 2: decimals = find_number_of_digits(precision);
2514
                temp = get_string(infile,1);
2514
                temp = get_string(infile,1);
2515
                if(use_affine == TRUE ){ transform(2,2);}/* slider will use css-rotate transformation */
2515
                if(use_affine == TRUE ){ transform(2,2);}/* slider will use css-rotate transformation */
2516
                if( use_offset != 0 || drag_type != -1 ){int_data[2] = 1;}else{int_data[2] = 0;} /* only centered or not-centered */
2516
                if( use_offset != 0 || drag_type != -1 ){int_data[2] = 1;}else{int_data[2] = 0;} /* only centered or not-centered */
2517
                int_data[0] = x2px(double_data[0]);
2517
                int_data[0] = x2px(double_data[0]);
2518
                int_data[1] = y2px(double_data[1]);
2518
                int_data[1] = y2px(double_data[1]);
2519
                if( use_slider != -1 && onclick == 0 ){ onclick = 5;}
2519
                if( use_slider != -1 && onclick == 0 ){ onclick = 5;}
2520
                if( use_slider != -1 && drag_type != -1){ onclick = 5; }
2520
                if( use_slider != -1 && drag_type != -1){ onclick = 5; }
2521
#ifdef KATEX_INSTALLED
2521
#ifdef KATEX_INSTALLED
2522
                if( strstr(temp,"\\") != 0 ){ temp = str_replace(temp,"\\","\\\\"); }
2522
                if( strstr(temp,"\\") != 0 ){ temp = str_replace(temp,"\\","\\\\"); }
Line 3304... Line 3304...
3304
                fprintf(js_include_file,"snap_x = %f;snap_y = %f;",double_data[2] / double_data[3],double_data[5] - double_data[4] );
3304
                fprintf(js_include_file,"snap_x = %f;snap_y = %f;",double_data[2] / double_data[3],double_data[5] - double_data[4] );
3305
                tmp_buffer=my_newmem(MAX_BUFFER);
3305
                tmp_buffer=my_newmem(MAX_BUFFER);
3306
                check_string_length(snprintf(tmp_buffer,MAX_BUFFER, "\ndraw_numberline(%d,%d,%f,%f,%f,%f,%f,%f,%d,\"%s\",%f,\"%s\",\"%s\",%d);  ",NUMBERLINE_CANVAS+numberline_cnt,use_axis_numbering,double_data[0],double_data[1],double_data[2],double_data[3],double_data[4],double_data[5],line_width,stroke_color,stroke_opacity,font_family,font_color,precision));
3306
                check_string_length(snprintf(tmp_buffer,MAX_BUFFER, "\ndraw_numberline(%d,%d,%f,%f,%f,%f,%f,%f,%d,\"%s\",%f,\"%s\",\"%s\",%d);  ",NUMBERLINE_CANVAS+numberline_cnt,use_axis_numbering,double_data[0],double_data[1],double_data[2],double_data[3],double_data[4],double_data[5],line_width,stroke_color,stroke_opacity,font_family,font_color,precision));
3307
                add_to_buffer(tmp_buffer);
3307
                add_to_buffer(tmp_buffer);
3308
                numberline_cnt++;
3308
                numberline_cnt++;
3309
                break;
3309
                break;
3310
              default:break;
3310
              default:break;
3311
            }
3311
            }
3312
          }
3312
          }
3313
          reset();
3313
          reset();
3314
          break;
3314
          break;
3315
        case OBABEL:
3315
        case OBABEL:
3316
  /*
3316
  /*
3317
  @ obabel x,y,type input,molecule smiles-code or file location, extra arguments,extra arguments,...
3317
  @ obabel x,y,type input,molecule smiles-code or file location, extra arguments,extra arguments,...
3318
  @ will call the ''obabel`` program, if installed.
3318
  @ will call the ''obabel`` program, if installed.
Line 3530... Line 3530...
3530
  @%points_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%snaptogrid%linewidth 1%drag xy%points red,0,0,1,1,2,2,3,3%drag x%points blue,0,1,1,2,2,3,3,4
3530
  @%points_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%snaptogrid%linewidth 1%drag xy%points red,0,0,1,1,2,2,3,3%drag x%points blue,0,1,1,2,2,3,3,4
3531
  @%points_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%linewidth 1%onclick%points red,0,0,1,1,2,2,3,3%onclick%points blue,0,1,1,2,2,3,3,4
3531
  @%points_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,255%linewidth 1%onclick%points red,0,0,1,1,2,2,3,3%onclick%points blue,0,1,1,2,2,3,3,4
3532
  */
3532
  */
3533
          stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
3533
          stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
3534
          fill_color = stroke_color;
3534
          fill_color = stroke_color;
3535
          i=0;
3535
          i=0;
3536
          while( ! done ){     /* get next item until EOL*/
3536
          while( ! done ){     /* get next item until EOL*/
3537
            if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
3537
            if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
3538
            if(i%2 == 0 ){
3538
            if(i%2 == 0 ){
3539
              double_data[i] = get_real(infile,0); /* x */
3539
              double_data[i] = get_real(infile,0); /* x */
3540
            }
3540
            }
3541
            else {
3541
            else {
3542
              double_data[i] = get_real(infile,1); /* y */
3542
              double_data[i] = get_real(infile,1); /* y */
3543
            }
3543
            }
3544
            i++;
3544
            i++;
3545
          }
3545
          }
3546
          if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);}
3546
          if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);}
3547
          if(use_affine == TRUE ){ transform(i-1,2);}
3547
          if(use_affine == TRUE ){ transform(i-1,2);}
3548
          if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */
3548
          if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */
3549
          decimals = find_number_of_digits(precision);
3549
          decimals = find_number_of_digits(precision);
3550
          for(c = 0 ; c < i-1 ; c = c+2){
3550
          for(c = 0 ; c < i-1 ; c = c+2){
Line 3565... Line 3565...
3565
  @ draw closed polygon
3565
  @ draw closed polygon
3566
  @ use command ''fpoly`` to fill it or use keyword <a href='#filled'>filled</a>
3566
  @ use command ''fpoly`` to fill it or use keyword <a href='#filled'>filled</a>
3567
  @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a>
3567
  @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a>
3568
  @%polygon_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 2%drag xy%snaptogrid%poly blue,0,0,1,3,3,1,2,4,-1,3
3568
  @%polygon_1%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 2%drag xy%snaptogrid%poly blue,0,0,1,3,3,1,2,4,-1,3
3569
  @%polygon_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 1%onclick%poly green,0,0,1,3,3,1,2,4,-1,3
3569
  @%polygon_2%size 400,400%xrange -10,10%yrange -10,10%opacity 255,25%fillcolor orange%filled%linewidth 1%onclick%poly green,0,0,1,3,3,1,2,4,-1,3
3570
  */
3570
  */
3571
          stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
3571
          stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
3572
          i=0;
3572
          i=0;
3573
          c=0;
3573
          c=0;
3574
          while( ! done ){     /* get next item until EOL*/
3574
          while( ! done ){     /* get next item until EOL*/
3575
            if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
3575
            if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
3576
            for( c = 0 ; c < 2; c++){
3576
            for( c = 0 ; c < 2; c++){
3577
              if(c == 0 ){
3577
              if(c == 0 ){
3578
                double_data[i] = get_real(infile,0);
3578
                double_data[i] = get_real(infile,0);
3579
                i++;
3579
                i++;
3580
              }
3580
              }
3581
              else {
3581
              else {
3582
                double_data[i] = get_real(infile,1);
3582
                double_data[i] = get_real(infile,1);
3583
                i++;
3583
                i++;
3584
              }
3584
              }
Line 4351... Line 4351...
4351
              case 2: int_data[0] = (int)(get_real(infile,0));break; /* width */
4351
              case 2: int_data[0] = (int)(get_real(infile,0));break; /* width */
4352
              case 3: int_data[1] = (int)(get_real(infile,0));break; /* height */
4352
              case 3: int_data[1] = (int)(get_real(infile,0));break; /* height */
4353
              case 4: temp = get_string_argument(infile,0); /* type: x,y,angle */
4353
              case 4: temp = get_string_argument(infile,0); /* type: x,y,angle */
4354
                if( strstr(temp,"displ")!=0 ||  strstr(temp,"deg")!=0 || strstr(temp,"rad")!=0 ){int_data[5] = 1; }else{int_data[5] = 0;}
4354
                if( strstr(temp,"displ")!=0 ||  strstr(temp,"deg")!=0 || strstr(temp,"rad")!=0 ){int_data[5] = 1; }else{int_data[5] = 0;}
4355
                if(strstr(temp,"anim")!= 0){int_data[3] = 1;}else{int_data[3] = 0;}
4355
                if(strstr(temp,"anim")!= 0){int_data[3] = 1;}else{int_data[3] = 0;}
4356
                if(strstr(temp,"active")!= 0){onclick = 4;}else{onclick=0;}
-
 
4357
                if(strstr(temp,"angle")!= 0){slider_type="R";if( strstr(temp,"rad")!= 0){int_data[2] = 3;}if( strstr(temp,"deg")!= 0){int_data[2] = 4;}}
4356
                if(strstr(temp,"angle")!= 0){slider_type="R";if( strstr(temp,"rad")!= 0){int_data[2] = 3;}if( strstr(temp,"deg")!= 0){int_data[2] = 4;}}
4358
                else
4357
                else
4359
                  if(strstr(temp,"xy") != 0){slider_type = "XY";if( strstr(temp,"disp")!= 0){int_data[2] = 5;}}
4358
                  if(strstr(temp,"xy") != 0){slider_type = "XY";if( strstr(temp,"disp")!= 0){int_data[2] = 5;}}
4360
                    else
4359
                    else
4361
                      if(strstr(temp,"x") != 0){slider_type = "X";if( strstr(temp,"disp")!= 0){int_data[2] = 1;}}
4360
                      if(strstr(temp,"x") != 0){slider_type = "X";if( strstr(temp,"disp")!= 0){int_data[2] = 1;}}
Line 4372... Line 4371...
4372
          if(use_slider == -1 ){ /* add once */
4371
          if(use_slider == -1 ){ /* add once */
4373
            add_slider(int_data[3]);
4372
            add_slider(int_data[3]);
4374
            if(int_data[5] == 1 ){add_slider_display(precision,font_size,font_color,stroke_opacity);}
4373
            if(int_data[5] == 1 ){add_slider_display(precision,font_size,font_color,stroke_opacity);}
4375
          }
4374
          }
4376
          use_slider++;
4375
          use_slider++;
4377
          if(int_data[3] == 0){\
4376
          if(int_data[3] == 0){
4378
 
-
 
4379
            tmp_buffer=my_newmem(MAX_BUFFER);
4377
            tmp_buffer=my_newmem(MAX_BUFFER);
4380
            check_string_length(snprintf(tmp_buffer,MAX_BUFFER,"slider%d = new slider(\"%s\",\"%s\",%d,%d,%d,%d,\"%s\",\"%s\",[%f,%f],%f,%f,'%s',%d);\n",use_slider,slider_type,temp,use_slider,int_data[0],int_data[1],line_width,fill_color,stroke_color,fill_opacity,stroke_opacity,double_data[0],double_data[1],font_family,int_data[2]));
4378
            check_string_length(snprintf(tmp_buffer,MAX_BUFFER,"slider%d = new slider(\"%s\",\"%s\",%d,%d,%d,%d,\"%s\",\"%s\",[%f,%f],%f,%f,'%s',%d);\n",use_slider,slider_type,temp,use_slider,int_data[0],int_data[1],line_width,fill_color,stroke_color,fill_opacity,stroke_opacity,double_data[0],double_data[1],font_family,int_data[2]));
4381
          }else{
4379
          }else{
4382
 
4380
 
4383
            add_slider(int_data[3]);/* use only once !! */
4381
            add_slider(int_data[3]);/* use only once !! */
Line 4386... Line 4384...
4386
          }
4384
          }
4387
          add_to_buffer(tmp_buffer);
4385
          add_to_buffer(tmp_buffer);
4388
          fprintf(js_include_file,"var slider%d;",use_slider);
4386
          fprintf(js_include_file,"var slider%d;",use_slider);
4389
          use_dragstuff = 2;
4387
          use_dragstuff = 2;
4390
//      dragstuff[22] = 1; /* dragstuff switch no 22 is a slider...*/
4388
//      dragstuff[22] = 1; /* dragstuff switch no 22 is a slider...*/
4391
          if(onclick != 4 ){ js_function[INTERACTIVE] = 1; }/* no need to click on object to use slider... */
4389
          js_function[INTERACTIVE] = 1; /* no need to click on object to use slider... */
4392
      //js_function[JS_ROTATE_MOUSE] = 1;
4390
      //js_function[JS_ROTATE_MOUSE] = 1;
4393
          c = 0;
4391
          c = 0;
4394
          for(i=last_slider;i<=use_slider;i++){
4392
          for(i=last_slider;i<=use_slider;i++){
4395
            int_data[c] = i; c++;
4393
            int_data[c] = i; c++;
4396
          }
4394
          }