Browse files

The line tool starts a line and tracks the cursor.

  • Loading branch information...
1 parent 766d949 commit 7fd6a30104acd02c2575541baae83733aa333520 Alastair McGowan-Douglas committed Sep 16, 2010
Showing with 12 additions and 4 deletions.
  1. +12 −4 js/drawing.js
View
16 js/drawing.js
@@ -1,12 +1,20 @@
var Canvas = new (function(){
var self = this;
- this.mode = function(mode) {
+ var mousePos = {};
+
+ self.mode = function(mode) {
self.clickZone.click(function(e) {
- debugger;
+ self.beginLine(e.offsetX, e.offsetY);
});
};
- this.beginLine = function(x,y) {
-
+ self.beginLine = function(x,y) {
+ var l = self.paper.path("M" + x + " " + y + "L" + x + " " + y)
+ .attr({ stroke: "rgb(0,0,0)", "stroke-width": 1 });
+
+ self.clickZone.mousemove(function(e) {
+ l.attr({ path: "M" + x + " " + y + "L" + e.offsetX + " " +
+ e.offsetY });
+ });
};
})();

0 comments on commit 7fd6a30

Please sign in to comment.