Rev 8349 | Rev 8357 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8349 | Rev 8351 | ||
---|---|---|---|
Line 422... | Line 422... | ||
422 | reset(); |
422 | reset(); |
423 | break; |
423 | break; |
424 | case SEGMENTS: |
424 | case SEGMENTS: |
425 | /* |
425 | /* |
426 | @ segments color,x1,y1,x2,y2,...,x_n,y_n |
426 | @ segments color,x1,y1,x2,y2,...,x_n,y_n |
427 | @ draw multiple segments |
427 | @ draw multiple segments between points (x1:y1)--(x2:y2).....and... (x_n-1:y_n-1)--(x_n:y_n) in color 'color' |
428 | @ use command 'linewidth int' to adust size |
428 | @ use command 'linewidth int' to adust size |
429 | @ may be set draggable / onclick individually (!) |
429 | @ may be set draggable / onclick individually (!) |
430 | */ |
430 | */ |
431 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
431 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
432 | fill_color = stroke_color; |
432 | fill_color = stroke_color; |
Line 517... | Line 517... | ||
517 | fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[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,slider,slider_cnt); |
517 | fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[0],decimals,double_data[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,slider,slider_cnt); |
518 | click_cnt++;reset(); |
518 | click_cnt++;reset(); |
519 | break; |
519 | break; |
520 | } |
520 | } |
521 | } |
521 | } |
- | 522 | break; |
|
- | 523 | case LINES: |
|
- | 524 | /* |
|
- | 525 | @ lines color,x1,y1,x2,y2...x_n-1,y_n-1,x_n,y_n |
|
- | 526 | @ draw multiple lines through points (x1:y1)--(x2:y2) ...(x_n-1:y_n-1)--(x_n:y_n) in color 'color' |
|
- | 527 | @ or use multiple commands 'curve color,formula' or "jscurve color,formule" to draw the line <br />(uses more points to draw the line; is however better draggable) |
|
- | 528 | @ may be set draggable / onclick |
|
- | 529 | @ <b>Attention</b>: the flydraw command "lines" is equivalent to canvasdraw command "polyline" |
|
- | 530 | */ |
|
- | 531 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
|
- | 532 | fill_color = stroke_color; |
|
- | 533 | i=0; |
|
- | 534 | while( ! done ){ /* get next item until EOL*/ |
|
- | 535 | if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");} |
|
- | 536 | if(i%2 == 0 ){ |
|
- | 537 | double_data[i] = get_real(infile,0); /* x */ |
|
- | 538 | } |
|
- | 539 | else |
|
- | 540 | { |
|
- | 541 | double_data[i] = get_real(infile,1); /* y */ |
|
- | 542 | } |
|
- | 543 | i++; |
|
- | 544 | } |
|
- | 545 | decimals = find_number_of_digits(precision); |
|
- | 546 | for(c = 0 ; c < i-1 ; c = c+4){ |
|
- | 547 | if( double_data[c] == double_data[c+2] ){ /* vertical line*/ |
|
- | 548 | double_data[c+1] = xmin; |
|
- | 549 | double_data[c+3] = ymax; |
|
- | 550 | double_data[c+2] = double_data[c]; |
|
- | 551 | } |
|
- | 552 | else |
|
- | 553 | { |
|
- | 554 | if( double_data[c+1] == double_data[c+3] ){ /* horizontal line */ |
|
- | 555 | double_data[c+3] = double_data[c+1]; |
|
- | 556 | double_data[c] = ymin; |
|
- | 557 | double_data[c+2] = xmax; |
|
- | 558 | } |
|
- | 559 | else |
|
- | 560 | { |
|
- | 561 | /* m */ |
|
- | 562 | double m = (double_data[c+3] - double_data[c+1]) /(double_data[c+2] - double_data[c]); |
|
- | 563 | /* q */ |
|
- | 564 | double q = double_data[c+1] - ((double_data[c+3] - double_data[c+1]) /(double_data[c+2] - double_data[c]))*double_data[c]; |
|
- | 565 | /*xmin,m*xmin+q,xmax,m*xmax+q*/ |
|
- | 566 | double_data[c+1] = (m)*(xmin)+(q); |
|
- | 567 | double_data[c+3] = (m)*(xmax)+(q); |
|
- | 568 | double_data[c] = xmin; |
|
- | 569 | double_data[c+2] = xmax; |
|
- | 570 | } |
|
- | 571 | } |
|
- | 572 | fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+2],decimals,double_data[c+1],decimals,double_data[c+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,slider,slider_cnt); |
|
- | 573 | click_cnt++; |
|
- | 574 | } |
|
- | 575 | reset(); |
|
522 | break; |
576 | break; |
523 | case HALFLINE: |
577 | case HALFLINE: |
524 | /* |
578 | /* |
525 | @ demiline x1,y1,x2,y2,color |
579 | @ demiline x1,y1,x2,y2,color |
526 | @ alternative : halfline |
580 | @ alternative : halfline |
Line 694... | Line 748... | ||
694 | } |
748 | } |
695 | break; |
749 | break; |
696 | case POLYLINE: |
750 | case POLYLINE: |
697 | /* |
751 | /* |
698 | @ polyline color,x1,y1,x2,y2...x_n,y_n |
752 | @ polyline color,x1,y1,x2,y2...x_n,y_n |
- | 753 | @ alternatives:<br />polylines color,x1,y1,x2,y2...x_n,y_n<br />brokenline color,x1,y1,x2,y2...x_n,y_n<br />brokenlines color,x1,y1,x2,y2...x_n,y_n |
|
- | 754 | @ draw a broken line interconnected between all points (not closed) |
|
- | 755 | @ equivalent to flydraw command "line color,x1,y1,x2,y2...x_n,y_n" |
|
- | 756 | @ use command "segments color,x1,y1,x2,y2...x_n,y_n" for not interconnected line segments. |
|
699 | @ may be set draggable / onclick |
757 | @ may be set draggable / onclick |
700 | */ |
758 | */ |
701 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
759 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
702 | i=0; |
760 | i=0; |
703 | c=0; |
761 | c=0; |
Line 4780... | Line 4838... | ||
4780 | if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\ |
4838 | if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\ |
4781 | input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\ |
4839 | input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\ |
4782 | p++;\ |
4840 | p++;\ |
4783 | };\ |
4841 | };\ |
4784 | t++;\ |
4842 | t++;\ |
4785 | };\ |
4843 | };\ |
4786 | };\ |
4844 | };\ |
4787 | if( typeof userdraw_text != 'undefined' ){\ |
4845 | if( typeof userdraw_text != 'undefined' ){\ |
4788 | return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\ |
4846 | return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply+\"\\n\"+userdraw_text;\ |
4789 | }\ |
4847 | }\ |
4790 | else\ |
4848 | else\ |
4791 | {\ |
4849 | {\ |
4792 | return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\ |
4850 | return reply_x+\"\\n\"+reply_y+\"\\n\"+input_reply;\ |
Line 6904... | Line 6962... | ||
6904 | *xrange="xrange", |
6962 | *xrange="xrange", |
6905 | *yrange="yrange", |
6963 | *yrange="yrange", |
6906 | *rangex="rangex", |
6964 | *rangex="rangex", |
6907 | *rangey="rangey", |
6965 | *rangey="rangey", |
6908 | *polyline="polyline", |
6966 | *polyline="polyline", |
- | 6967 | *polylines="polylines", |
|
- | 6968 | *brokenline="brokenline", |
|
- | 6969 | *brokenlines="brokenlines", |
|
6909 | *lines="lines", |
6970 | *lines="lines", |
6910 | *poly="poly", |
6971 | *poly="poly", |
6911 | *polygon="polygon", |
6972 | *polygon="polygon", |
6912 | *fpolygon="fpolygon", |
6973 | *fpolygon="fpolygon", |
6913 | *fpoly="fpoly", |
6974 | *fpoly="fpoly", |
Line 7340... | Line 7401... | ||
7340 | } |
7401 | } |
7341 | if( strcmp(input_type, fontfamily) == 0 ){ |
7402 | if( strcmp(input_type, fontfamily) == 0 ){ |
7342 | free(input_type); |
7403 | free(input_type); |
7343 | return FONTFAMILY; |
7404 | return FONTFAMILY; |
7344 | } |
7405 | } |
7345 | if( strcmp(input_type, |
7406 | if( strcmp(input_type, polyline) == 0 || strcmp(input_type, polylines) == 0 || strcmp(input_type, brokenline) == 0 || strcmp(input_type, brokenlines) == 0 ){ |
7346 | free(input_type); |
7407 | free(input_type); |
7347 | return POLYLINE; |
7408 | return POLYLINE; |
- | 7409 | } |
|
- | 7410 | if( strcmp(input_type, lines) == 0 ){ |
|
- | 7411 | free(input_type); |
|
- | 7412 | return LINES; |
|
7348 | } |
7413 | } |
7349 | if( strcmp(input_type, rect) == 0 || strcmp(input_type, rectangle) == 0 ){ |
7414 | if( strcmp(input_type, rect) == 0 || strcmp(input_type, rectangle) == 0 ){ |
7350 | free(input_type); |
7415 | free(input_type); |
7351 | return RECT; |
7416 | return RECT; |
7352 | } |
7417 | } |