-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpencil.js
50 lines (40 loc) · 1.42 KB
/
pencil.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Generated by CoffeeScript 1.6.2
(function() {
var _ref,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
drawbone.tools.Pencil = (function(_super) {
__extends(Pencil, _super);
function Pencil() {
_ref = Pencil.__super__.constructor.apply(this, arguments);
return _ref;
}
Pencil.prototype.initialize = function(options) {
this.canvas = options.canvas;
this.context = this.canvas.getContext('2d');
return this.started = false;
};
Pencil.prototype.render = function() {
return this;
};
Pencil.prototype.mousedown = function(event) {
this.context.beginPath();
this.context.moveTo(event._x, event._y);
return this.started = true;
};
Pencil.prototype.mousemove = function(event) {
if (this.started) {
this.context.lineTo(event._x, event._y);
return this.context.stroke();
}
};
Pencil.prototype.mouseup = function(event) {
if (this.started) {
this.mousemove(event);
this.started = false;
return this.trigger('toolDidCompleteDrawing');
}
};
return Pencil;
})(Backbone.View);
}).call(this);