mirror of
https://github.com/konvajs/konva.git
synced 2025-09-20 03:18:00 +08:00
Merge branch 'customextend'
This commit is contained in:
2
Thorfile
2
Thorfile
@@ -6,7 +6,7 @@ class Build < Thor
|
|||||||
"license.js", "src/Global.js", "src/Transition.js", "src/filters/Grayscale.js",
|
"license.js", "src/Global.js", "src/Transition.js", "src/filters/Grayscale.js",
|
||||||
"src/util/Type.js", "src/util/Canvas.js", "src/util/Class.js", "src/util/Tween.js", "src/util/Transform.js",
|
"src/util/Type.js", "src/util/Canvas.js", "src/util/Class.js", "src/util/Tween.js", "src/util/Transform.js",
|
||||||
"src/Animation.js", "src/Node.js", "src/Container.js", "src/Stage.js", "src/Layer.js", "src/Group.js", "src/Shape.js",
|
"src/Animation.js", "src/Node.js", "src/Container.js", "src/Stage.js", "src/Layer.js", "src/Group.js", "src/Shape.js",
|
||||||
"src/shapes/Rect.js", "src/shapes/Ellipse.js", "src/shapes/Image.js", "src/shapes/Polygon.js", "src/shapes/Text.js", "src/shapes/Line.js", "src/shapes/Sprite.js", "src/shapes/Star.js", "src/shapes/RegularPolygon.js", "src/shapes/Path.js", "src/shapes/TextPath.js"
|
"src/shapes/Rect.js" #, "src/shapes/Ellipse.js", "src/shapes/Image.js", "src/shapes/Polygon.js", "src/shapes/Text.js", "src/shapes/Line.js", "src/shapes/Sprite.js", "src/shapes/Star.js", "src/shapes/RegularPolygon.js", "src/shapes/Path.js", "src/shapes/TextPath.js"
|
||||||
]
|
]
|
||||||
|
|
||||||
desc "dev", "Concatenate all the js files into /dist/kinetic-VERSION.js."
|
desc "dev", "Concatenate all the js files into /dist/kinetic-VERSION.js."
|
||||||
|
2209
dist/kinetic-core.js
vendored
2209
dist/kinetic-core.js
vendored
File diff suppressed because it is too large
Load Diff
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -30,10 +30,14 @@
|
|||||||
* @param {Number} [config.dragBounds.bottom]
|
* @param {Number} [config.dragBounds.bottom]
|
||||||
* @param {Number} [config.dragBounds.left]
|
* @param {Number} [config.dragBounds.left]
|
||||||
*/
|
*/
|
||||||
Kinetic.Container = Kinetic.Node.extend({
|
Kinetic.Container = function(config) {
|
||||||
init: function(config) {
|
this._containerInit(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Kinetic.Container.prototype = {
|
||||||
|
_containerInit: function(config) {
|
||||||
this.children = [];
|
this.children = [];
|
||||||
this._super(config);
|
Kinetic.Node.call(this, config);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get children
|
* get children
|
||||||
@@ -234,4 +238,5 @@ Kinetic.Container = Kinetic.Node.extend({
|
|||||||
this.children[n].index = n;
|
this.children[n].index = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
Kinetic.Global.extend(Kinetic.Container, Kinetic.Node);
|
||||||
|
@@ -31,6 +31,13 @@ Kinetic.Global = {
|
|||||||
console.warn('Kinetic warning: ' + str);
|
console.warn('Kinetic warning: ' + str);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
extend: function(c1, c2) {
|
||||||
|
for(var key in c2.prototype) {
|
||||||
|
if(!( key in c1.prototype)) {
|
||||||
|
c1.prototype[key] = c2.prototype[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
_pullNodes: function(stage) {
|
_pullNodes: function(stage) {
|
||||||
var tempNodes = this.tempNodes;
|
var tempNodes = this.tempNodes;
|
||||||
for(var key in tempNodes) {
|
for(var key in tempNodes) {
|
||||||
|
13
src/Group.js
13
src/Group.js
@@ -30,11 +30,16 @@
|
|||||||
* @param {Number} [config.dragBounds.bottom]
|
* @param {Number} [config.dragBounds.bottom]
|
||||||
* @param {Number} [config.dragBounds.left]
|
* @param {Number} [config.dragBounds.left]
|
||||||
*/
|
*/
|
||||||
Kinetic.Group = Kinetic.Container.extend({
|
Kinetic.Group = function(config) {
|
||||||
init: function(config) {
|
this._groupInit(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Kinetic.Group.prototype = {
|
||||||
|
_groupInit: function(config) {
|
||||||
this.nodeType = 'Group';
|
this.nodeType = 'Group';
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
this._super(config);
|
Kinetic.Container.call(this, config);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
Kinetic.Global.extend(Kinetic.Group, Kinetic.Container);
|
||||||
|
13
src/Layer.js
13
src/Layer.js
@@ -33,8 +33,12 @@
|
|||||||
* @param {Number} [config.dragBounds.bottom]
|
* @param {Number} [config.dragBounds.bottom]
|
||||||
* @param {Number} [config.dragBounds.left]
|
* @param {Number} [config.dragBounds.left]
|
||||||
*/
|
*/
|
||||||
Kinetic.Layer = Kinetic.Container.extend({
|
Kinetic.Layer = function(config) {
|
||||||
init: function(config) {
|
this._layerInit(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Kinetic.Layer.prototype = {
|
||||||
|
_layerInit: function(config) {
|
||||||
this.setDefaultAttrs({
|
this.setDefaultAttrs({
|
||||||
clearBeforeDraw: true
|
clearBeforeDraw: true
|
||||||
});
|
});
|
||||||
@@ -48,7 +52,7 @@ Kinetic.Layer = Kinetic.Container.extend({
|
|||||||
this.bufferCanvas.name = 'buffer';
|
this.bufferCanvas.name = 'buffer';
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
this._super(config);
|
Kinetic.Container.call(this, config);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* draw children nodes. this includes any groups
|
* draw children nodes. this includes any groups
|
||||||
@@ -171,7 +175,8 @@ Kinetic.Layer = Kinetic.Container.extend({
|
|||||||
canvas.clear();
|
canvas.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
Kinetic.Global.extend(Kinetic.Layer, Kinetic.Container);
|
||||||
|
|
||||||
// add getters and setters
|
// add getters and setters
|
||||||
Kinetic.Node.addGettersSetters(Kinetic.Layer, ['clearBeforeDraw']);
|
Kinetic.Node.addGettersSetters(Kinetic.Layer, ['clearBeforeDraw']);
|
||||||
|
10
src/Node.js
10
src/Node.js
@@ -31,8 +31,12 @@
|
|||||||
* @param {Number} [config.dragBounds.bottom]
|
* @param {Number} [config.dragBounds.bottom]
|
||||||
* @param {Number} [config.dragBounds.left]
|
* @param {Number} [config.dragBounds.left]
|
||||||
*/
|
*/
|
||||||
Kinetic.Node = Kinetic.Class.extend({
|
Kinetic.Node = function(config) {
|
||||||
init: function(config) {
|
this._nodeInit(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Kinetic.Node.prototype = {
|
||||||
|
_nodeInit: function(config) {
|
||||||
this.defaultNodeAttrs = {
|
this.defaultNodeAttrs = {
|
||||||
visible: true,
|
visible: true,
|
||||||
listening: true,
|
listening: true,
|
||||||
@@ -1003,7 +1007,7 @@ Kinetic.Node = Kinetic.Class.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
// add getter and setter methods
|
// add getter and setter methods
|
||||||
Kinetic.Node.addSetters = function(constructor, arr) {
|
Kinetic.Node.addSetters = function(constructor, arr) {
|
||||||
|
13
src/Shape.js
13
src/Shape.js
@@ -59,8 +59,12 @@
|
|||||||
* @param {Number} [config.dragBounds.bottom]
|
* @param {Number} [config.dragBounds.bottom]
|
||||||
* @param {Number} [config.dragBounds.left]
|
* @param {Number} [config.dragBounds.left]
|
||||||
*/
|
*/
|
||||||
Kinetic.Shape = Kinetic.Node.extend({
|
Kinetic.Shape = function(config) {
|
||||||
init: function(config) {
|
this._shapeInit(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Kinetic.Shape.prototype = {
|
||||||
|
_shapeInit: function(config) {
|
||||||
this.nodeType = 'Shape';
|
this.nodeType = 'Shape';
|
||||||
this.appliedShadow = false;
|
this.appliedShadow = false;
|
||||||
|
|
||||||
@@ -77,7 +81,7 @@ Kinetic.Shape = Kinetic.Node.extend({
|
|||||||
shapes[key] = this;
|
shapes[key] = this;
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
this._super(config);
|
Kinetic.Node.call(this, config);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get canvas context tied to the layer
|
* get canvas context tied to the layer
|
||||||
@@ -415,7 +419,8 @@ Kinetic.Shape = Kinetic.Node.extend({
|
|||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
Kinetic.Global.extend(Kinetic.Shape, Kinetic.Node);
|
||||||
|
|
||||||
// add getters and setters
|
// add getters and setters
|
||||||
Kinetic.Node.addGettersSetters(Kinetic.Shape, ['fill', 'stroke', 'lineJoin', 'strokeWidth', 'shadow', 'drawFunc', 'filter']);
|
Kinetic.Node.addGettersSetters(Kinetic.Shape, ['fill', 'stroke', 'lineJoin', 'strokeWidth', 'shadow', 'drawFunc', 'filter']);
|
||||||
|
13
src/Stage.js
13
src/Stage.js
@@ -33,8 +33,12 @@
|
|||||||
* @param {Number} [config.dragBounds.bottom]
|
* @param {Number} [config.dragBounds.bottom]
|
||||||
* @param {Number} [config.dragBounds.left]
|
* @param {Number} [config.dragBounds.left]
|
||||||
*/
|
*/
|
||||||
Kinetic.Stage = Kinetic.Container.extend({
|
Kinetic.Stage = function(config) {
|
||||||
init: function(config) {
|
this._stageInit(config);
|
||||||
|
};
|
||||||
|
|
||||||
|
Kinetic.Stage.prototype = {
|
||||||
|
_stageInit: function(config) {
|
||||||
this.setDefaultAttrs({
|
this.setDefaultAttrs({
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 200
|
height: 200
|
||||||
@@ -49,7 +53,7 @@ Kinetic.Stage = Kinetic.Container.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
this._super(config);
|
Kinetic.Container.call(this, config);
|
||||||
|
|
||||||
this._setStageDefaultProperties();
|
this._setStageDefaultProperties();
|
||||||
this._id = Kinetic.Global.idCounter++;
|
this._id = Kinetic.Global.idCounter++;
|
||||||
@@ -812,7 +816,8 @@ Kinetic.Stage = Kinetic.Container.extend({
|
|||||||
this.names = {};
|
this.names = {};
|
||||||
this.dragAnim = new Kinetic.Animation();
|
this.dragAnim = new Kinetic.Animation();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
Kinetic.Global.extend(Kinetic.Stage, Kinetic.Container);
|
||||||
|
|
||||||
// add getters and setters
|
// add getters and setters
|
||||||
Kinetic.Node.addGettersSetters(Kinetic.Stage, ['width', 'height']);
|
Kinetic.Node.addGettersSetters(Kinetic.Stage, ['width', 'height']);
|
||||||
|
@@ -7,8 +7,11 @@
|
|||||||
* @augments Kinetic.Shape
|
* @augments Kinetic.Shape
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
*/
|
*/
|
||||||
Kinetic.Rect = Kinetic.Shape.extend({
|
Kinetic.Rect = function(config) {
|
||||||
init: function(config) {
|
this._rectInit(config);
|
||||||
|
}
|
||||||
|
Kinetic.Rect.prototype = {
|
||||||
|
_rectInit: function(config) {
|
||||||
this.setDefaultAttrs({
|
this.setDefaultAttrs({
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
@@ -16,8 +19,8 @@ Kinetic.Rect = Kinetic.Shape.extend({
|
|||||||
});
|
});
|
||||||
this.shapeType = "Rect";
|
this.shapeType = "Rect";
|
||||||
config.drawFunc = this.drawFunc;
|
config.drawFunc = this.drawFunc;
|
||||||
// call super constructor
|
|
||||||
this._super(config);
|
Kinetic.Shape.call(this, config);
|
||||||
},
|
},
|
||||||
drawFunc: function(context) {
|
drawFunc: function(context) {
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
@@ -62,7 +65,8 @@ Kinetic.Rect = Kinetic.Shape.extend({
|
|||||||
height: this.attrs.height
|
height: this.attrs.height
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
Kinetic.Global.extend(Kinetic.Rect, Kinetic.Shape);
|
||||||
|
|
||||||
// add getters setters
|
// add getters setters
|
||||||
Kinetic.Node.addGettersSetters(Kinetic.Rect, ['width', 'height', 'cornerRadius']);
|
Kinetic.Node.addGettersSetters(Kinetic.Rect, ['width', 'height', 'cornerRadius']);
|
||||||
|
Reference in New Issue
Block a user