added drawFunc property to layer so that layers can easily draw non-node background graphics

This commit is contained in:
Eric Rowell
2012-05-09 18:53:20 -07:00
parent a27741ce03
commit 16c251bb97
6 changed files with 103 additions and 21 deletions

View File

@@ -18,6 +18,7 @@ Kinetic.Layer = function(config) {
this.lastDrawTime = 0;
this.beforeDrawFunc = undefined;
this.afterDrawFunc = undefined;
this.drawFunc = undefined;
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext('2d');
@@ -142,6 +143,12 @@ Kinetic.Layer.prototype = {
this.clear();
if(this.attrs.visible) {
// draw custom func
if (this.drawFunc !== undefined) {
this.drawFunc();
}
// draw children
this._drawChildren();
}

View File

@@ -23,7 +23,7 @@ Kinetic.Shape = function(config) {
lineJoin: undefined,
detectionType: 'path',
shadowColor: undefined,
shadowBlur: undefined,
shadowBlur: 5,
shadowOffset: {
x: 0,
y: 0
@@ -139,7 +139,8 @@ Kinetic.Shape.prototype = {
}
},
/**
* apply shadow helper method
* apply shadow based on shadowColor, shadowBlur,
* and shadowOffset properties
*/
applyShadow: function() {
var context = this.getContext();