mirror of
https://github.com/konvajs/konva.git
synced 2026-03-10 00:23:32 +08:00
removed ATTRS class level variable cache from Shape. added class level variable cache to Node. Made several low level optimizations.
This commit is contained in:
2247
src/Node.js
2247
src/Node.js
File diff suppressed because it is too large
Load Diff
19
src/Shape.js
19
src/Shape.js
@@ -1,6 +1,6 @@
|
|||||||
Kinetic.Shape = (function() {
|
Kinetic.Shape = (function() {
|
||||||
// variable cache
|
// variable cache
|
||||||
var ATTRS, TYPE = Kinetic.Type;
|
var TYPE = Kinetic.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape constructor. Shapes are primitive objects such as rectangles,
|
* Shape constructor. Shapes are primitive objects such as rectangles,
|
||||||
@@ -83,7 +83,6 @@ Kinetic.Shape = (function() {
|
|||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
Kinetic.Node.call(this, config);
|
Kinetic.Node.call(this, config);
|
||||||
ATTRS = this.attrs;
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get canvas context tied to the layer
|
* get canvas context tied to the layer
|
||||||
@@ -120,7 +119,7 @@ Kinetic.Shape = (function() {
|
|||||||
var appliedShadow = false;
|
var appliedShadow = false;
|
||||||
|
|
||||||
context.save();
|
context.save();
|
||||||
if(ATTRS.shadow && !this.appliedShadow) {
|
if(this.attrs.shadow && !this.appliedShadow) {
|
||||||
appliedShadow = this._applyShadow(context);
|
appliedShadow = this._applyShadow(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +180,7 @@ Kinetic.Shape = (function() {
|
|||||||
var appliedShadow = false, fill = this.getFill(), fillType = this._getFillType(fill);
|
var appliedShadow = false, fill = this.getFill(), fillType = this._getFillType(fill);
|
||||||
if(fill) {
|
if(fill) {
|
||||||
context.save();
|
context.save();
|
||||||
if(ATTRS.shadow && !this.appliedShadow) {
|
if(this.attrs.shadow && !this.appliedShadow) {
|
||||||
appliedShadow = this._applyShadow(context);
|
appliedShadow = this._applyShadow(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +259,7 @@ Kinetic.Shape = (function() {
|
|||||||
var a = Array.prototype.slice.call(arguments);
|
var a = Array.prototype.slice.call(arguments);
|
||||||
|
|
||||||
if(a.length === 6 || a.length === 10) {
|
if(a.length === 6 || a.length === 10) {
|
||||||
if(ATTRS.shadow && !this.appliedShadow) {
|
if(this.attrs.shadow && !this.appliedShadow) {
|
||||||
appliedShadow = this._applyShadow(context);
|
appliedShadow = this._applyShadow(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,8 +290,8 @@ Kinetic.Shape = (function() {
|
|||||||
* @methodOf Kinetic.Shape.prototype
|
* @methodOf Kinetic.Shape.prototype
|
||||||
*/
|
*/
|
||||||
applyLineJoin: function(context) {
|
applyLineJoin: function(context) {
|
||||||
if(ATTRS.lineJoin) {
|
if(this.attrs.lineJoin) {
|
||||||
context.lineJoin = ATTRS.lineJoin;
|
context.lineJoin = this.attrs.lineJoin;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -302,8 +301,8 @@ Kinetic.Shape = (function() {
|
|||||||
* @methodOf Kinetic.Shape.prototype
|
* @methodOf Kinetic.Shape.prototype
|
||||||
*/
|
*/
|
||||||
applyLineCap: function(context) {
|
applyLineCap: function(context) {
|
||||||
if(ATTRS.lineCap) {
|
if(this.attrs.lineCap) {
|
||||||
context.lineCap = ATTRS.lineCap;
|
context.lineCap = this.attrs.lineCap;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -381,7 +380,7 @@ Kinetic.Shape = (function() {
|
|||||||
* and false if it was not
|
* and false if it was not
|
||||||
*/
|
*/
|
||||||
_applyShadow: function(context) {
|
_applyShadow: function(context) {
|
||||||
var s = ATTRS.shadow;
|
var s = this.attrs.shadow;
|
||||||
if(s) {
|
if(s) {
|
||||||
var aa = this.getAbsoluteOpacity();
|
var aa = this.getAbsoluteOpacity();
|
||||||
// defaults
|
// defaults
|
||||||
|
|||||||
Reference in New Issue
Block a user