javascript - Canvas KineticJS - re-draw something when click button -
i using kineticjs library. created line (http://jsfiddle.net/zp364/)
var redline = new kinetic.line({ points: [973, 570, 340, 423, 450, 60, 500, 20], stroke: 'red', strokewidth: 15, linecap: 'round', linejoin: 'round', draggable: true }); when click change button want line has change this. thanks
document.getelementbyid('change').addeventlistener('click', function() { redline.point = [600, 400, 300, 100, 700, 80, 200, 30]; // want re-draw line redline.stroke = 'blue'; // , change color layer.draw(); }, false);
not redline.point...use redline.setpoints(newpointsarray)
redline.setpoints([600, 400, 300, 100, 700, 80, 200, 30]); check here kineticjs tutorials: http://www.html5canvastutorials.com/kineticjs/html5-canvas-events-tutorials-introduction-with-kineticjs/
and check here kineticjs documentation: http://kineticjs.com/docs/symbols/kinetic.line.php#setpoints
Comments
Post a Comment