How to manipulate Canvas elements: Difference between revisions

Jump to navigation Jump to search
Line 130: Line 130:
var root = myCanvas.createGroup();
var root = myCanvas.createGroup();
var myGroup = root.createChild("group");
var myGroup = root.createChild("group");
var (red,blue,green) = ['#ee0000', [0,0,1], [0,0.8,0] ];
var (red,blue,green,orange) = ['#ee0000', [0,0,1], [0,0.8,0], '#ea9a32' ];
canvas.plot2D.polyline(myGroup,[150,181,194,157,199],[52,20,64,28,36]);
canvas.plot2D.polyline(myGroup,[150,181,194,157,199],[52,20,64,28,36]);
   ## 3 vertices with default values:
   ## 3 vertices with default values:
canvas.plot2D.polyline(myGroup,[20,30,70],[15,55,65]);
canvas.plot2D.polyline(myGroup,[20,30,70],[15,55,65]);
canvas.plot2D.text(myGroup,'defaults',[75,25]);
   ## 3 vertices with symmetrical = 'x':
   ## 3 vertices with symmetrical = 'x':
canvas.plot2D.polyline(myGroup,[20,30,70],[130,170,180],blue,"x");
canvas.plot2D.polyline(myGroup,[20,30,70],[130,170,180],blue,"x");
canvas.plot2D.text(myGroup,'Symmetrical="x"',[20,195],,blue);
   ## 3 vertices with symmetrical = 'y':
   ## 3 vertices with symmetrical = 'y':
canvas.plot2D.polyline(myGroup,[150,160,200],[90,130,140],red,"y");
canvas.plot2D.polyline(myGroup,[150,160,200],[90,130,140],red,"y");
canvas.plot2D.text(myGroup,'Symmetrical="y"',[198,180],,red,'right-baseline');
   ## 3 vertices with symmetrical = 'xy':
   ## 3 vertices with symmetrical = 'xy':
canvas.plot2D.polyline(myGroup,[50,60,100],[100,140,150],green,"xy");
canvas.plot2D.polyline(myGroup,[50,60,100],[100,140,150],green,"xy");
canvas.plot2D.text(myGroup,'Symmetrical="xy"',[55,75],,green);
   ## 3 vertices with symmetrical = 'yx':
   ## 3 vertices with symmetrical = 'yx':
canvas.plot2D.polyline(myGroup,[100,110,150],[50,90,100],'#0',"yx");
canvas.plot2D.polyline(myGroup,[100,110,150],[50,90,100],orange,"yx");
canvas.plot2D.text(myGroup,'Symmetrical="yx"',[12,125],,orange);
</syntaxhighlight>
</syntaxhighlight>
|| [[File:Plot2D.rectangle and grid.png|thumb]]
[[File:Plot2D.polyline.png|thumb|plot2D.polyline example]]
|}
|}
229

edits

Navigation menu