How to reference an SVG drawing primitive with Keith Woods SVG Plugin
Hi folks,
here's a code snippet that will generate a nice Lissajous figure using Keith Wood's SVG plugin. I can't figure out how I can change the points in the polyline primitive once it has been instantiated. I would think that I need to change line 12 to something like var mypolyline = svg.polyline(myarray, .....); and then later change the point array with svg.change(mypolyline, {points: newarray}); but this is bombing out.
What am I doing wrong?
Pug McThug
- $(function() {$('#svgintro').svg({onLoad: drawIntro})});
-
- canvas = {width: 700, height: 700} ;
- first = 7 ;
- second = 9 ;
-
- function drawIntro(svg) {
- var myarray = new Array(1000) ;
- for (i=0; i<myarray.length; i++) {
- myarray[i] = [(Math.sin(first*i)*canvas.width/2)+canvas.width/2,(Math.sin(second*i)*canvas.height/2)+canvas.height/2];
- }
- svg.polyline(myarray, {fill: 'none', stroke: 'black', strokeWidth: 1});
- }