Link to a script showing what I was working on:
http://jsfiddle.net/robtown/SGQq7/22/
This is a set of drawing tools using KineticJS and Sketch.js
You need to select “sketch” to draw by hand, and then “copy sketch to kinetics” to copy the sketch into the kinetic scene. Select Make Rectangle to create a rectangle.
I need to enable the code in order to publish it, so here is the code when you select the Make Rectangle button:
$ ('# makeRect'). click (function (e) {
followRect = new Kinetic.Rect({ width: 120, height: 40, x: -200, y:-200, stroke: 'red', strokeWidth: 3 }); drawLayer.setVisible(true); drawLayer.add(followRect); drawLayer.draw(); makeRect = true; drawLayer.on("mousemove", function (e) { if (makeRect) { followRect.setX(e.x+5); followRect.setY(e.y+5); drawLayer.draw(); } });
This creates a rectangle that follows the mouse until you click on the canvas, then it places the rectangle in the Redlines layer of the scene:
drawLayer.on ("mousedown", function (e) {
//for (var f = 0 ; f < 1; f++) { //alert(e.length); if (makeRect) { addToRedlineLayer(ex, ey); } //} followRect.setX(-200); drawLayer.setVisible(false); return; });
robtown
source share