refactored fillStroke() method

This commit is contained in:
Eric Rowell
2012-04-14 21:53:00 -07:00
parent 47b8a8e0d6
commit c698005adc
4 changed files with 16 additions and 12 deletions

View File

@@ -67,9 +67,12 @@ Kinetic.Shape.prototype = {
context.fill();
}
if(this.attrs.stroke !== undefined || this.attrs.strokeWidth !== undefined) {
var stroke = this.attrs.stroke !== undefined ? this.attrs.stroke : 'black';
var strokeWidth = this.attrs.strokeWidth !== undefined ? this.attrs.strokeWidth : 2;
var hasStroke = this.attrs.stroke !== undefined;
var hasStrokeWidth = this.attrs.strokeWidth !== undefined && this.attrs.strokeWidth !== 0;
if(hasStroke || hasStrokeWidth) {
var stroke = hasStroke ? this.attrs.stroke : 'black';
var strokeWidth = hasStrokeWidth ? this.attrs.strokeWidth : 2;
context.lineWidth = strokeWidth;
context.strokeStyle = stroke;