added new Line Shape

This commit is contained in:
Eric Rowell
2012-04-28 21:12:01 -07:00
parent ffd9924511
commit 1dbe93a232
7 changed files with 203 additions and 20 deletions

View File

@@ -50,6 +50,21 @@ Kinetic.Shape.prototype = {
getCanvas: function() {
return this.tempLayer.getCanvas();
},
/**
* helper method to stroke shape
*/
stroke: function() {
var context = this.getContext();
if(!!this.attrs.stroke || !!this.attrs.strokeWidth) {
var stroke = !!this.attrs.stroke ? this.attrs.stroke : 'black';
var strokeWidth = !!this.attrs.strokeWidth ? this.attrs.strokeWidth : 2;
context.lineWidth = strokeWidth;
context.strokeStyle = stroke;
context.stroke();
}
},
/**
* helper method to fill and stroke a shape
* based on its fill, stroke, and strokeWidth, properties
@@ -66,14 +81,7 @@ Kinetic.Shape.prototype = {
context.fill();
}
if(!!this.attrs.stroke || !!this.attrs.strokeWidth) {
var stroke = !!this.attrs.stroke ? this.attrs.stroke : 'black';
var strokeWidth = !!this.attrs.strokeWidth ? this.attrs.strokeWidth : 2;
context.lineWidth = strokeWidth;
context.strokeStyle = stroke;
context.stroke();
}
this.stroke();
},
/**
* helper method to set the line join of a shape