Kinetic.Shape=function(a){this._initShape(a)},Kinetic.Shape.prototype={_initShape:function(a){this.nodeType="Shape",this.appliedShadow=!1;var b=Kinetic.Global.shapes,c;for(;;){c=Kinetic.Type._getRandomColorKey();if(c&&!(c in b))break}this.colorKey=c,b[c]=this,Kinetic.Node.call(this,a)},getContext:function(){return this.getLayer().getContext()},getCanvas:function(){return this.getLayer().getCanvas()},stroke:function(a){var b=this.getStrokeWidth(),c=this.getStroke();if(c||b){var d=Kinetic.Global,e=!1;a.save(),this.attrs.shadow&&!this.appliedShadow&&(e=this._applyShadow(a)),a.lineWidth=b||2,a.strokeStyle=c||"black",a.stroke(a),a.restore(),e&&this.stroke(a)}},_getFillType:function(a){return a?Kinetic.Type._isString(a)?"COLOR":a.image?"PATTERN":a.start&&a.end&&!a.start.radius&&!a.end.radius?"LINEAR_GRADIENT":a.start&&a.end&&Kinetic.Type._isNumber(a.start.radius)&&Kinetic.Type._isNumber(a.end.radius)?"RADIAL_GRADIENT":"UNKNOWN":undefined},fill:function(a){var b=!1,c=this.getFill(),d=this._getFillType(c);if(c){a.save(),this.attrs.shadow&&!this.appliedShadow&&(b=this._applyShadow(a));var e=c.start,f=c.end;switch(d){case"COLOR":a.fillStyle=c,a.fill(a);break;case"PATTERN":var g=c.repeat?c.repeat:"repeat";c.scale&&a.scale(c.scale.x,c.scale.y),c.offset&&a.translate(c.offset.x,c.offset.y),a.fillStyle=a.createPattern(c.image,g),a.fill(a);break;case"LINEAR_GRADIENT":var h=a.createLinearGradient(e.x,e.y,f.x,f.y),i=c.colorStops;for(var j=0;j0},remove:function(){Kinetic.Node.prototype.remove.call(this),delete Kinetic.Global.shapes[this.colorKey]},draw:function(a){if(this.attrs.drawFunc&&Kinetic.Node.prototype._shouldDraw.call(this,a)){var b=this.getStage(),c=a.getContext(),d=[],e=this.parent;d.unshift(this);while(e)d.unshift(e),e=e.parent;c.save();for(var f=0;f