mirror of
https://github.com/konvajs/konva.git
synced 2026-01-09 11:34:38 +08:00
component attrs are now the source of truth again
This commit is contained in:
@@ -296,7 +296,7 @@
|
||||
Kinetic.Container.prototype.get = Kinetic.Container.prototype.find;
|
||||
|
||||
// add getters setters
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Container, 'clip');
|
||||
Kinetic.Factory.addBoxGetterSetter(Kinetic.Container, 'clip');
|
||||
|
||||
/**
|
||||
* set clip
|
||||
@@ -322,7 +322,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Container, 'clipX', 0);
|
||||
/**
|
||||
* set clip x
|
||||
* @method
|
||||
@@ -339,7 +339,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Container, 'clipY', 0);
|
||||
/**
|
||||
* set clip y
|
||||
* @name setClipY
|
||||
@@ -356,7 +356,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'width', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Container, 'clipWidth', 0);
|
||||
/**
|
||||
* set clip width
|
||||
* @name setClipWidth
|
||||
@@ -373,7 +373,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'height', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Container, 'clipHeight', 0);
|
||||
/**
|
||||
* set clip height
|
||||
* @name setClipHeight
|
||||
|
||||
255
src/Factory.js
255
src/Factory.js
@@ -42,90 +42,94 @@
|
||||
Y = 'y';
|
||||
|
||||
Kinetic.Factory = {
|
||||
addGetterSetter: function(constructor, baseAttr, def) {
|
||||
this.addGetter(constructor, baseAttr, def);
|
||||
this.addSetter(constructor, baseAttr);
|
||||
addGetterSetter: function(constructor, attr, def) {
|
||||
this.addGetter(constructor, attr, def);
|
||||
this.addSetter(constructor, attr);
|
||||
},
|
||||
addComponentGetterSetter: function(constructor, baseAttr, component, def) {
|
||||
this.addComponentGetter(constructor, baseAttr, component, def);
|
||||
this.addComponentSetter(constructor, baseAttr, component);
|
||||
},
|
||||
addGetter: function(constructor, baseAttr, def) {
|
||||
var method = GET + Kinetic.Util._capitalize(baseAttr);
|
||||
// if default function is not defined, create a default default function
|
||||
if (!def) {
|
||||
def = function(){};
|
||||
}
|
||||
addGetter: function(constructor, attr, def) {
|
||||
var method = GET + Kinetic.Util._capitalize(attr);
|
||||
|
||||
constructor.prototype[method] = function() {
|
||||
var val = this.attrs[baseAttr];
|
||||
return val === undefined ? def() : val;
|
||||
};
|
||||
},
|
||||
addSetter: function(constructor, baseAttr) {
|
||||
var method = SET + Kinetic.Util._capitalize(baseAttr);
|
||||
|
||||
constructor.prototype[method] = function(val) {
|
||||
this._setAttr(baseAttr, val);
|
||||
return this;
|
||||
};
|
||||
},
|
||||
addComponentGetter: function(constructor, baseAttr, component, def) {
|
||||
var method = GET + Kinetic.Util._capitalize(baseAttr) + Kinetic.Util._capitalize(component);
|
||||
|
||||
constructor.prototype[method] = function() {
|
||||
var base = this.attrs[baseAttr],
|
||||
val = base && base[component];
|
||||
var val = this.attrs[attr];
|
||||
return val === undefined ? def : val;
|
||||
};
|
||||
},
|
||||
addComponentSetter: function(constructor, baseAttr, component) {
|
||||
var method = SET + Kinetic.Util._capitalize(baseAttr) + Kinetic.Util._capitalize(component);
|
||||
addSetter: function(constructor, attr) {
|
||||
var method = SET + Kinetic.Util._capitalize(attr);
|
||||
|
||||
constructor.prototype[method] = function(val) {
|
||||
this._setComponentAttr(baseAttr, component, val);
|
||||
this._setAttr(attr, val);
|
||||
return this;
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------- old methods to be deprecated -----------------------------------
|
||||
|
||||
|
||||
|
||||
addPointGetterSetter: function(constructor, attr, def) {
|
||||
this.addPointGetter(constructor, attr, def);
|
||||
// point
|
||||
addPointGetterSetter: function(constructor, attr) {
|
||||
this.addPointGetter(constructor, attr);
|
||||
this.addPointSetter(constructor, attr);
|
||||
|
||||
// add invdividual component getters and setters
|
||||
this.addGetter(constructor, attr + UPPER_X, def);
|
||||
this.addGetter(constructor, attr + UPPER_Y, def);
|
||||
this.addSetter(constructor, attr + UPPER_X);
|
||||
this.addSetter(constructor, attr + UPPER_Y);
|
||||
},
|
||||
addBoxGetterSetter: function(constructor, attr, def) {
|
||||
this.addBoxGetter(constructor, attr, def);
|
||||
this.addBoxSetter(constructor, attr);
|
||||
addPointGetter: function(constructor, attr) {
|
||||
var method = GET + Kinetic.Util._capitalize(attr),
|
||||
getX = method + UPPER_X,
|
||||
getY = method + UPPER_Y;
|
||||
|
||||
// add invdividual component getters and setters
|
||||
this.addGetter(constructor, attr + UPPER_X, def);
|
||||
this.addGetter(constructor, attr + UPPER_Y, def);
|
||||
this.addGetter(constructor, attr + UPPER_WIDTH, def);
|
||||
this.addGetter(constructor, attr + UPPER_HEIGHT, def);
|
||||
constructor.prototype[method] = function() {
|
||||
return {
|
||||
x: this[getX](),
|
||||
y: this[getY]()
|
||||
};
|
||||
};
|
||||
},
|
||||
addPointSetter: function(constructor, attr) {
|
||||
var method = SET + Kinetic.Util._capitalize(attr),
|
||||
setX = method + UPPER_X,
|
||||
setY = method + UPPER_Y;
|
||||
|
||||
this.addSetter(constructor, attr + UPPER_X);
|
||||
this.addSetter(constructor, attr + UPPER_Y);
|
||||
this.addSetter(constructor, attr + UPPER_WIDTH);
|
||||
this.addSetter(constructor, attr + UPPER_HEIGHT);
|
||||
constructor.prototype[method] = function(val) {
|
||||
this[setX](val.x);
|
||||
this[setY](val.y);
|
||||
return this;
|
||||
};
|
||||
},
|
||||
addPointsGetterSetter: function(constructor, attr) {
|
||||
this.addPointsGetter(constructor, attr);
|
||||
this.addPointsSetter(constructor, attr);
|
||||
this.addPointAdder(constructor, attr);
|
||||
|
||||
// box
|
||||
addBoxGetterSetter: function(constructor, attr) {
|
||||
this.addPointGetter(constructor, attr);
|
||||
this.addPointSetter(constructor, attr);
|
||||
},
|
||||
addBoxGetter: function(constructor, attr) {
|
||||
var method = GET + Kinetic.Util._capitalize(attr),
|
||||
getX = method + UPPER_X,
|
||||
getY = method + UPPER_Y,
|
||||
getWidth = method + UPPER_WIDTH,
|
||||
getHeight = method + UPPER_HEIGHT;
|
||||
|
||||
constructor.prototype[method] = function() {
|
||||
return {
|
||||
x: this[getX](),
|
||||
y: this[getY](),
|
||||
width: this[getWidth](),
|
||||
height: this[getHeight]()
|
||||
};
|
||||
};
|
||||
},
|
||||
addBoxSetter: function(constructor, attr) {
|
||||
var method = SET + Kinetic.Util._capitalize(attr),
|
||||
setX = SET + method + UPPER_X,
|
||||
setY = SET + method + UPPER_Y,
|
||||
setWidth = SET + method + UPPER_WIDTH,
|
||||
setHeight = SET + method + UPPER_HEIGHT;
|
||||
|
||||
constructor.prototype[method] = function(val) {
|
||||
this[setX](val.x);
|
||||
this[setY](val.y);
|
||||
this[setWidth](val.width);
|
||||
this[setHeight](val.height);
|
||||
return this;
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
addRotationGetterSetter: function(constructor, attr, def) {
|
||||
this.addRotationGetter(constructor, attr, def);
|
||||
this.addRotationSetter(constructor, attr);
|
||||
@@ -162,42 +166,7 @@
|
||||
return this[prefix + RGB]()[c];
|
||||
};
|
||||
},
|
||||
addPointsGetter: function(constructor, attr) {
|
||||
var that = this,
|
||||
method = GET + Kinetic.Util._capitalize(attr);
|
||||
|
||||
constructor.prototype[method] = function() {
|
||||
var val = this.attrs[attr];
|
||||
return val === undefined ? [] : val;
|
||||
};
|
||||
},
|
||||
|
||||
addPointGetter: function(constructor, attr) {
|
||||
var that = this,
|
||||
baseMethod = GET + Kinetic.Util._capitalize(attr);
|
||||
|
||||
constructor.prototype[baseMethod] = function() {
|
||||
var that = this;
|
||||
return {
|
||||
x: that[baseMethod + UPPER_X](),
|
||||
y: that[baseMethod + UPPER_Y]()
|
||||
};
|
||||
};
|
||||
},
|
||||
addBoxGetter: function(constructor, attr) {
|
||||
var that = this,
|
||||
baseMethod = GET + Kinetic.Util._capitalize(attr);
|
||||
|
||||
constructor.prototype[baseMethod] = function() {
|
||||
var that = this;
|
||||
return {
|
||||
x: that[baseMethod + UPPER_X](),
|
||||
y: that[baseMethod + UPPER_Y](),
|
||||
width: that[baseMethod + UPPER_WIDTH](),
|
||||
height: that[baseMethod + UPPER_HEIGHT]()
|
||||
};
|
||||
};
|
||||
},
|
||||
addRotationGetter: function(constructor, attr, def) {
|
||||
var that = this,
|
||||
method = GET + Kinetic.Util._capitalize(attr);
|
||||
@@ -242,74 +211,7 @@
|
||||
this[prefix + RGB](obj);
|
||||
};
|
||||
},
|
||||
addPointsSetter: function(constructor, attr) {
|
||||
var method = SET + Kinetic.Util._capitalize(attr);
|
||||
constructor.prototype[method] = function(val) {
|
||||
var points = Kinetic.Util._getPoints(val);
|
||||
this._setAttr('points', points);
|
||||
};
|
||||
},
|
||||
|
||||
addPointSetter: function(constructor, attr) {
|
||||
var that = this,
|
||||
baseMethod = SET + Kinetic.Util._capitalize(attr);
|
||||
|
||||
constructor.prototype[baseMethod] = function() {
|
||||
var pos = Kinetic.Util._getXY([].slice.call(arguments)),
|
||||
oldVal = this.attrs[attr],
|
||||
x = 0,
|
||||
y = 0;
|
||||
|
||||
if (pos) {
|
||||
x = pos.x;
|
||||
y = pos.y;
|
||||
|
||||
this._fireBeforeChangeEvent(attr, oldVal, pos);
|
||||
if (x !== undefined) {
|
||||
this[baseMethod + UPPER_X](x);
|
||||
}
|
||||
if (y !== undefined) {
|
||||
this[baseMethod + UPPER_Y](y);
|
||||
}
|
||||
this._fireChangeEvent(attr, oldVal, pos);
|
||||
}
|
||||
};
|
||||
},
|
||||
addBoxSetter: function(constructor, attr) {
|
||||
var that = this,
|
||||
baseMethod = SET + Kinetic.Util._capitalize(attr);
|
||||
|
||||
constructor.prototype[baseMethod] = function() {
|
||||
var config = [].slice.call(arguments),
|
||||
pos = Kinetic.Util._getXY(config),
|
||||
size = Kinetic.Util._getSize(config),
|
||||
both = Kinetic.Util._merge(pos, size),
|
||||
oldVal = this.attrs[attr],
|
||||
x, y, width, height;
|
||||
|
||||
if (both) {
|
||||
x = both.x;
|
||||
y = both.y;
|
||||
width = both.width;
|
||||
height = both.height;
|
||||
|
||||
this._fireBeforeChangeEvent(attr, oldVal, both);
|
||||
if (x !== undefined) {
|
||||
this[baseMethod + UPPER_X](x);
|
||||
}
|
||||
if (y !== undefined) {
|
||||
this[baseMethod + UPPER_Y](y);
|
||||
}
|
||||
if (width !== undefined) {
|
||||
this[baseMethod + UPPER_WIDTH](width);
|
||||
}
|
||||
if (height !== undefined) {
|
||||
this[baseMethod + UPPER_HEIGHT](height);
|
||||
}
|
||||
this._fireChangeEvent(attr, oldVal, both);
|
||||
}
|
||||
};
|
||||
},
|
||||
addRotationSetter: function(constructor, attr) {
|
||||
var that = this,
|
||||
method = SET + Kinetic.Util._capitalize(attr);
|
||||
@@ -322,23 +224,6 @@
|
||||
constructor.prototype[method + DEG] = function(deg) {
|
||||
this._setAttr(attr, Kinetic.Util._degToRad(deg));
|
||||
};
|
||||
},
|
||||
|
||||
// add adders
|
||||
addPointAdder: function(constructor, attr) {
|
||||
var that = this,
|
||||
baseMethod = ADD + Kinetic.Util._removeLastLetter(Kinetic.Util._capitalize(attr));
|
||||
|
||||
constructor.prototype[baseMethod] = function() {
|
||||
var pos = Kinetic.Util._getXY([].slice.call(arguments)),
|
||||
oldVal = this.attrs[attr];
|
||||
|
||||
if (pos) {
|
||||
this._fireBeforeChangeEvent(attr, oldVal, pos);
|
||||
this.attrs[attr].push(pos);
|
||||
this._fireChangeEvent(attr, oldVal, pos);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
})();
|
||||
52
src/Node.js
52
src/Node.js
@@ -1296,9 +1296,7 @@
|
||||
};
|
||||
// add getters setters
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'x', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'x', 0);
|
||||
|
||||
/**
|
||||
* set x position
|
||||
@@ -1315,9 +1313,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'y', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'y', 0);
|
||||
|
||||
/**
|
||||
* set y position
|
||||
@@ -1334,9 +1330,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'opacity', function() {
|
||||
return 1;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'opacity', 1);
|
||||
|
||||
/**
|
||||
* set opacity. Opacity values range from 0 to 1.
|
||||
@@ -1405,9 +1399,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'scale', function() {
|
||||
return {x: 1, y: 1};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Node, 'scale');
|
||||
|
||||
/**
|
||||
* set scale
|
||||
@@ -1432,7 +1424,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Node, 'scale', 'x', 1);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'scaleX', 1);
|
||||
/**
|
||||
* set scale x
|
||||
* @name setScaleX
|
||||
@@ -1448,7 +1440,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Node, 'scale', 'y', 1);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'scaleY', 1);
|
||||
/**
|
||||
* set scale y
|
||||
* @name setScaleY
|
||||
@@ -1464,9 +1456,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'skew', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Node, 'skew');
|
||||
|
||||
/**
|
||||
* set skew
|
||||
@@ -1492,7 +1482,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Node, 'skew', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'skewX', 0);
|
||||
/**
|
||||
* set skew x
|
||||
* @name setSkewX
|
||||
@@ -1509,7 +1499,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Node, 'skew', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'skewY', 0);
|
||||
/**
|
||||
* set skew y
|
||||
* @name setSkewY
|
||||
@@ -1526,9 +1516,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'offset', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Node, 'offset');
|
||||
|
||||
/**
|
||||
* set offset. A node's offset defines the position and rotation point
|
||||
@@ -1553,7 +1541,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Node, 'offset', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'offsetX', 0);
|
||||
/**
|
||||
* set offset x
|
||||
* @name setOffsetX
|
||||
@@ -1570,7 +1558,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Node, 'offset', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'offsetY', 0);
|
||||
/**
|
||||
* set offset y
|
||||
* @name setOffsetY
|
||||
@@ -1587,9 +1575,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addSetter(Kinetic.Node, 'width', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addSetter(Kinetic.Node, 'width', 0);
|
||||
|
||||
/**
|
||||
* set width
|
||||
@@ -1599,9 +1585,7 @@
|
||||
* @param {Number} width
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addSetter(Kinetic.Node, 'height', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addSetter(Kinetic.Node, 'height', 0);
|
||||
|
||||
/**
|
||||
* set height
|
||||
@@ -1611,9 +1595,7 @@
|
||||
* @param {Number} height
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'listening', function() {
|
||||
return true;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'listening', true);
|
||||
|
||||
/**
|
||||
* listen or don't listen to events
|
||||
@@ -1630,9 +1612,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'visible', function() {
|
||||
return true;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'visible', true);
|
||||
|
||||
/**
|
||||
* set visible
|
||||
|
||||
116
src/Shape.js
116
src/Shape.js
@@ -710,7 +710,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternX');
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternX', 0);
|
||||
|
||||
/**
|
||||
* set fill pattern x
|
||||
@@ -727,7 +727,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternY');
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternY', 0);
|
||||
|
||||
/**
|
||||
* set fill pattern y
|
||||
@@ -830,9 +830,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillEnabled', function() {
|
||||
return true;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillEnabled', true);
|
||||
|
||||
/**
|
||||
* set fill enabled
|
||||
@@ -849,9 +847,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'strokeEnabled', function() {
|
||||
return true;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'strokeEnabled', true);
|
||||
|
||||
/**
|
||||
* set stroke enabled
|
||||
@@ -868,9 +864,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowEnabled', function() {
|
||||
return true;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowEnabled', true);
|
||||
|
||||
/**
|
||||
* set shadow enabled
|
||||
@@ -887,9 +881,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'dashArrayEnabled', function() {
|
||||
return true;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'dashArrayEnabled', true);
|
||||
|
||||
/**
|
||||
* set dash array enabled
|
||||
@@ -906,9 +898,24 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPriority', function() {
|
||||
return 'color';
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'strokeScaleEnabled', true);
|
||||
|
||||
/**
|
||||
* set stroke scale enabled
|
||||
* @name setStrokeScaleEnabled
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Boolean} enabled
|
||||
*/
|
||||
|
||||
/**
|
||||
* get stroke scale enabled
|
||||
* @name getStrokeScaleEnabled
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPriority', 'color');
|
||||
|
||||
/**
|
||||
* set fill priority
|
||||
@@ -926,28 +933,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'strokeScaleEnabled', function() {
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* set stroke scale enabled
|
||||
* @name setStrokeScaleEnabled
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Boolean} enabled
|
||||
*/
|
||||
|
||||
/**
|
||||
* get stroke scale enabled
|
||||
* @name getStrokeScaleEnabled
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternOffset', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'fillPatternOffset');
|
||||
|
||||
/**
|
||||
* set fill pattern offset
|
||||
@@ -973,7 +959,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillPatternOffset', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternOffsetX', 0);
|
||||
/**
|
||||
* set fill pattern offset x
|
||||
* @name setFillPatternOffsetX
|
||||
@@ -989,7 +975,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillPatternOffset', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternOffsetY', 0);
|
||||
/**
|
||||
* set fill pattern offset y
|
||||
* @name setFillPatternOffsetY
|
||||
@@ -1005,9 +991,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternScale', function() {
|
||||
return {x: 1, y: 1};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'fillPatternScale');
|
||||
|
||||
/**
|
||||
* set fill pattern scale
|
||||
@@ -1033,7 +1017,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillPatternScale', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternScaleX', 0);
|
||||
/**
|
||||
* set fill pattern scale x
|
||||
* @name setFillPatternScaleX
|
||||
@@ -1050,7 +1034,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillPatternScale', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternScaleY', 0);
|
||||
/**
|
||||
* set fill pattern scale y
|
||||
* @name setFillPatternScaleY
|
||||
@@ -1067,9 +1051,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillLinearGradientStartPoint', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'fillLinearGradientStartPoint');
|
||||
|
||||
/**
|
||||
* set fill linear gradient start point
|
||||
@@ -1095,7 +1077,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillLinearGradientStartPoint', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillLinearGradientStartPointX', 0);
|
||||
/**
|
||||
* set fill linear gradient start point x
|
||||
* @name setFillLinearGradientStartPointX
|
||||
@@ -1112,7 +1094,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillLinearGradientStartPoint', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillLinearGradientStartPointY', 0);
|
||||
/**
|
||||
* set fill linear gradient start point y
|
||||
* @name setFillLinearGradientStartPointY
|
||||
@@ -1129,9 +1111,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillLinearGradientEndPoint', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'fillLinearGradientEndPoint');
|
||||
|
||||
/**
|
||||
* set fill linear gradient end point
|
||||
@@ -1155,7 +1135,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillLinearGradientEndPoint', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillLinearGradientEndPointX', 0);
|
||||
|
||||
/**
|
||||
* set fill linear gradient end point x
|
||||
@@ -1173,7 +1153,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillLinearGradientEndPoint', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillLinearGradientEndPointY', 0);
|
||||
|
||||
/**
|
||||
* set fill linear gradient end point y
|
||||
@@ -1191,9 +1171,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillRadialGradientStartPoint', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillRadialGradientStartPoint', ['x', 'y']);
|
||||
|
||||
/**
|
||||
* set fill radial gradient start point
|
||||
@@ -1219,7 +1197,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillRadialGradientStartPoint', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillRadialGradientStartPointX', 0);
|
||||
/**
|
||||
* set fill radial gradient start point x
|
||||
* @name setFillRadialGradientStartPointX
|
||||
@@ -1235,7 +1213,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillRadialGradientStartPoint', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillRadialGradientStartPointY', 0);
|
||||
/**
|
||||
* set fill radial gradient start point y
|
||||
* @name setFillRadialGradientStartPointY
|
||||
@@ -1251,9 +1229,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillRadialGradientEndPoint', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'fillRadialGradientEndPoint');
|
||||
|
||||
/**
|
||||
* set fill radial gradient end point
|
||||
@@ -1279,7 +1255,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillRadialGradientEndPoint', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillRadialGradientEndPointX', 0);
|
||||
/**
|
||||
* set fill radial gradient end point x
|
||||
* @name setFillRadialGradientEndPointX
|
||||
@@ -1295,7 +1271,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'fillRadialGradientEndPoint', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillRadialGradientEndPointY', 0);
|
||||
/**
|
||||
* set fill radial gradient end point y
|
||||
* @name setFillRadialGradientEndPointY
|
||||
@@ -1311,9 +1287,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowOffset', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'shadowOffset');
|
||||
|
||||
/**
|
||||
* set shadow offset
|
||||
@@ -1339,7 +1313,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'shadowOffset', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowOffsetX', 0);
|
||||
|
||||
/**
|
||||
* set shadow offset x
|
||||
@@ -1356,7 +1330,7 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Shape, 'shadowOffset', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowOffsetY', 0);
|
||||
|
||||
/**
|
||||
* set shadow offset y
|
||||
|
||||
@@ -315,7 +315,7 @@
|
||||
Kinetic.Util.extend(Kinetic.TextPath, Kinetic.Shape);
|
||||
|
||||
// add setters and getters
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.TextPath, 'fontFamily', CALIBRI);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.TextPath, 'fontFamily', 'Arial');
|
||||
|
||||
/**
|
||||
* set font family
|
||||
|
||||
@@ -69,9 +69,7 @@
|
||||
Kinetic.Util.extend(Kinetic.Circle, Kinetic.Shape);
|
||||
|
||||
// add getters setters
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Circle, 'radius', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Circle, 'radius', 0);
|
||||
|
||||
/**
|
||||
* set radius
|
||||
|
||||
@@ -61,9 +61,7 @@
|
||||
Kinetic.Util.extend(Kinetic.Ellipse, Kinetic.Shape);
|
||||
|
||||
// add getters setters
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Ellipse, 'radius', function() {
|
||||
return {x: 0, y: 0};
|
||||
});
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Ellipse, 'radius');
|
||||
|
||||
/**
|
||||
* set radius
|
||||
@@ -82,7 +80,7 @@
|
||||
* @memberof Kinetic.Ellipse.prototype
|
||||
* @returns {Object}
|
||||
*/
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Ellipse, 'radius', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Ellipse, 'radiusX', 0);
|
||||
|
||||
/**
|
||||
* set radius x
|
||||
@@ -100,7 +98,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Ellipse, 'radius', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Ellipse, 'radiusY', 0);
|
||||
|
||||
/**
|
||||
* set radius y
|
||||
|
||||
@@ -271,7 +271,7 @@
|
||||
* @returns {ImageObject}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Image, 'crop');
|
||||
Kinetic.Factory.addBoxGetterSetter(Kinetic.Image, 'crop');
|
||||
/**
|
||||
* set crop
|
||||
* @method
|
||||
@@ -296,7 +296,7 @@
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Image, 'crop', 'x', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Image, 'cropX', 0);
|
||||
/**
|
||||
* set crop x
|
||||
* @method
|
||||
@@ -313,7 +313,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Image, 'crop', 'y', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Image, 'cropY', 0);
|
||||
/**
|
||||
* set crop y
|
||||
* @name setCropY
|
||||
@@ -330,7 +330,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Image, 'crop', 'width', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Image, 'cropWidth', 0);
|
||||
/**
|
||||
* set cropWidth
|
||||
* @name setCropWidth
|
||||
@@ -347,7 +347,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Image, 'crop', 'height', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Image, 'cropHheight', 0);
|
||||
/**
|
||||
* set cropHeight
|
||||
* @name setCropHeight
|
||||
|
||||
@@ -139,9 +139,7 @@
|
||||
Kinetic.Util.extend(Kinetic.Line, Kinetic.Shape);
|
||||
|
||||
// add getters setters
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Line, 'closed', function() {
|
||||
return false;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Line, 'closed', false);
|
||||
|
||||
/**
|
||||
* get closed
|
||||
@@ -159,9 +157,7 @@
|
||||
* @param {Boolean} closed
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Line, 'tension', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Line, 'tension', 0);
|
||||
|
||||
/**
|
||||
* get tension
|
||||
|
||||
@@ -57,9 +57,7 @@
|
||||
|
||||
Kinetic.Util.extend(Kinetic.Rect, Kinetic.Shape);
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Rect, 'cornerRadius', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Rect, 'cornerRadius', 0);
|
||||
|
||||
/**
|
||||
* set corner radius
|
||||
|
||||
@@ -227,9 +227,7 @@
|
||||
* @returns {ImageObject}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'index', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'index', 0);
|
||||
|
||||
/**
|
||||
* set animation frame index
|
||||
@@ -247,9 +245,7 @@
|
||||
* @returns {Integer}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'frameRate', function() {
|
||||
return 17;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'frameRate', 17);
|
||||
|
||||
/**
|
||||
* set frame rate in frames / second. Default is 17 frames per second. Increase this number to make the sprite
|
||||
|
||||
@@ -314,9 +314,7 @@
|
||||
Kinetic.Util.extend(Kinetic.Text, Kinetic.Shape);
|
||||
|
||||
// add getters setters
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontFamily', function() {
|
||||
return 'Arial';
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontFamily', 'Arial');
|
||||
|
||||
/**
|
||||
* set font family
|
||||
@@ -334,9 +332,7 @@
|
||||
* @returns {String}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontSize', function() {
|
||||
return 12;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontSize', 12);
|
||||
|
||||
/**
|
||||
* set font size in pixels
|
||||
@@ -354,9 +350,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontStyle', function() {
|
||||
return NORMAL;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontStyle', NORMAL);
|
||||
|
||||
/**
|
||||
* set font style. Can be 'normal', 'italic', or 'bold'. 'normal' is the default.
|
||||
@@ -374,9 +368,7 @@
|
||||
* @returns {String}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'padding', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'padding', 0);
|
||||
|
||||
/**
|
||||
* set padding
|
||||
@@ -394,9 +386,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'align', function() {
|
||||
return LEFT;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'align', LEFT);
|
||||
|
||||
/**
|
||||
* set horizontal align of text
|
||||
@@ -414,9 +404,7 @@
|
||||
* @returns {String}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'lineHeight', function() {
|
||||
return 1;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'lineHeight', 1);
|
||||
|
||||
/**
|
||||
* set line height
|
||||
@@ -434,9 +422,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'wrap', function() {
|
||||
return WORD;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'wrap', WORD);
|
||||
|
||||
/**
|
||||
* set wrap
|
||||
@@ -454,9 +440,7 @@
|
||||
* @returns {String}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetter(Kinetic.Text, TEXT, function() {
|
||||
return EMPTY_STRING;
|
||||
});
|
||||
Kinetic.Factory.addGetter(Kinetic.Text, TEXT, EMPTY_STRING);
|
||||
|
||||
/**
|
||||
* get text
|
||||
|
||||
@@ -62,9 +62,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addRotationGetterSetter(Kinetic.Wedge, 'angle', function() {
|
||||
return 0;
|
||||
});
|
||||
Kinetic.Factory.addRotationGetterSetter(Kinetic.Wedge, 'angle', 0);
|
||||
|
||||
/**
|
||||
* set angle
|
||||
@@ -98,9 +96,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Wedge, 'clockwise', function() {
|
||||
return false;
|
||||
});
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Wedge, 'clockwise', false);
|
||||
|
||||
/**
|
||||
* set clockwise draw direction. If set to true, the wedge will be drawn clockwise
|
||||
|
||||
Reference in New Issue
Block a user