1 var Pencil, ToolWithStroke, createShape,
2 extend = 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; },
3 hasProp = {}.hasOwnProperty;
5 ToolWithStroke = require('./base').ToolWithStroke;
7 createShape = require('../core/shapes').createShape;
9 module.exports = Pencil = (function(superClass) {
10 extend(Pencil, superClass);
13 return Pencil.__super__.constructor.apply(this, arguments);
16 Pencil.prototype.name = 'Pencil';
18 Pencil.prototype.iconName = 'pencil';
20 Pencil.prototype.eventTimeThreshold = 10;
22 Pencil.prototype.begin = function(x, y, lc) {
23 this.color = lc.getColor('primary');
24 this.currentShape = this.makeShape();
25 this.currentShape.addPoint(this.makePoint(x, y, lc));
26 return this.lastEventTime = Date.now();
29 Pencil.prototype["continue"] = function(x, y, lc) {
31 timeDiff = Date.now() - this.lastEventTime;
32 if (timeDiff > this.eventTimeThreshold) {
33 this.lastEventTime += timeDiff;
34 this.currentShape.addPoint(this.makePoint(x, y, lc));
35 return lc.drawShapeInProgress(this.currentShape);
39 Pencil.prototype.end = function(x, y, lc) {
40 lc.saveShape(this.currentShape);
41 return this.currentShape = void 0;
44 Pencil.prototype.makePoint = function(x, y, lc) {
45 return createShape('Point', {
48 size: this.strokeWidth,
53 Pencil.prototype.makeShape = function() {
54 return createShape('LinePath');