mirror of
https://github.com/konvajs/konva.git
synced 2025-09-20 03:18:00 +08:00
after some more thought, I've decided to remove the Plugins namespace, but keep the plugins directory. I don't want 3rd parties putting some things in the Kinetic namespace, while others put things in the Plugin space. I really don't see a real need for the namespacing. For organizational purposes, the plugins directory still makes sense, however.
This commit is contained in:
@@ -31,7 +31,6 @@ var Kinetic = {};
|
|||||||
|
|
||||||
// namespaces without constructors
|
// namespaces without constructors
|
||||||
Kinetic.Filters = {};
|
Kinetic.Filters = {};
|
||||||
Kinetic.Plugins = {};
|
|
||||||
Kinetic.DD = {};
|
Kinetic.DD = {};
|
||||||
|
|
||||||
// global namespace
|
// global namespace
|
||||||
|
@@ -31,11 +31,11 @@
|
|||||||
* @param {Number} [config.text.lineHeight] default is 1
|
* @param {Number} [config.text.lineHeight] default is 1
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
*/
|
*/
|
||||||
Kinetic.Plugins.Label = function(config) {
|
Kinetic.Label = function(config) {
|
||||||
this._initLabel(config);
|
this._initLabel(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Plugins.Label.prototype = {
|
Kinetic.Label.prototype = {
|
||||||
_initLabel: function(config) {
|
_initLabel: function(config) {
|
||||||
var that = this,
|
var that = this,
|
||||||
text = null;
|
text = null;
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
Kinetic.Group.call(this, config);
|
Kinetic.Group.call(this, config);
|
||||||
text = new Kinetic.Text(config.text);
|
text = new Kinetic.Text(config.text);
|
||||||
this.setText(text);
|
this.setText(text);
|
||||||
this.setRect(new Kinetic.Plugins.LabelRect(config.rect));
|
this.setRect(new Kinetic.LabelRect(config.rect));
|
||||||
this.innerGroup.add(this.getRect());
|
this.innerGroup.add(this.getRect());
|
||||||
this.innerGroup.add(text);
|
this.innerGroup.add(text);
|
||||||
this.add(this.innerGroup);
|
this.add(this.innerGroup);
|
||||||
@@ -102,15 +102,15 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Global.extend(Kinetic.Plugins.Label, Kinetic.Group);
|
Kinetic.Global.extend(Kinetic.Label, Kinetic.Group);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.Label, 'text');
|
Kinetic.Node.addGetterSetter(Kinetic.Label, 'text');
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.Label, 'rect');
|
Kinetic.Node.addGetterSetter(Kinetic.Label, 'rect');
|
||||||
|
|
||||||
Kinetic.Plugins.LabelRect = function(config) {
|
Kinetic.LabelRect = function(config) {
|
||||||
this._initLabelRect(config);
|
this._initLabelRect(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Plugins.LabelRect.prototype = {
|
Kinetic.LabelRect.prototype = {
|
||||||
_initLabelRect: function(config) {
|
_initLabelRect: function(config) {
|
||||||
this.createAttrs();
|
this.createAttrs();
|
||||||
Kinetic.Shape.call(this, config);
|
Kinetic.Shape.call(this, config);
|
||||||
@@ -165,9 +165,9 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Global.extend(Kinetic.Plugins.LabelRect, Kinetic.Shape);
|
Kinetic.Global.extend(Kinetic.LabelRect, Kinetic.Shape);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.LabelRect, 'pointerDirection', NONE);
|
Kinetic.Node.addGetterSetter(Kinetic.LabelRect, 'pointerDirection', NONE);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.LabelRect, 'pointerWidth', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.LabelRect, 'pointerWidth', 0);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.LabelRect, 'pointerHeight', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.LabelRect, 'pointerHeight', 0);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.LabelRect, 'cornerRadius', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.LabelRect, 'cornerRadius', 0);
|
||||||
})();
|
})();
|
@@ -9,11 +9,11 @@
|
|||||||
* {{ShapeParams}}
|
* {{ShapeParams}}
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
*/
|
*/
|
||||||
Kinetic.Plugins.Path = function(config) {
|
Kinetic.Path = function(config) {
|
||||||
this._initPath(config);
|
this._initPath(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Plugins.Path.prototype = {
|
Kinetic.Path.prototype = {
|
||||||
_initPath: function(config) {
|
_initPath: function(config) {
|
||||||
this.dataArray = [];
|
this.dataArray = [];
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -23,9 +23,9 @@
|
|||||||
this.shapeType = 'Path';
|
this.shapeType = 'Path';
|
||||||
this._setDrawFuncs();
|
this._setDrawFuncs();
|
||||||
|
|
||||||
this.dataArray = Kinetic.Plugins.Path.parsePathData(this.attrs.data);
|
this.dataArray = Kinetic.Path.parsePathData(this.attrs.data);
|
||||||
this.on('dataChange', function() {
|
this.on('dataChange', function() {
|
||||||
that.dataArray = Kinetic.Plugins.Path.parsePathData(that.attrs.data);
|
that.dataArray = Kinetic.Path.parsePathData(that.attrs.data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
drawFunc: function(canvas) {
|
drawFunc: function(canvas) {
|
||||||
@@ -72,16 +72,16 @@
|
|||||||
canvas.fillStroke(this);
|
canvas.fillStroke(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Kinetic.Global.extend(Kinetic.Plugins.Path, Kinetic.Shape);
|
Kinetic.Global.extend(Kinetic.Path, Kinetic.Shape);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility methods written by jfollas to
|
* Utility methods written by jfollas to
|
||||||
* handle length and point measurements
|
* handle length and point measurements
|
||||||
*/
|
*/
|
||||||
Kinetic.Plugins.Path.getLineLength = function(x1, y1, x2, y2) {
|
Kinetic.Path.getLineLength = function(x1, y1, x2, y2) {
|
||||||
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||||
};
|
};
|
||||||
Kinetic.Plugins.Path.getPointOnLine = function(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
|
Kinetic.Path.getPointOnLine = function(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
|
||||||
if(fromX === undefined) {
|
if(fromX === undefined) {
|
||||||
fromX = P1x;
|
fromX = P1x;
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
return pt;
|
return pt;
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Plugins.Path.getPointOnCubicBezier = function(pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) {
|
Kinetic.Path.getPointOnCubicBezier = function(pct, P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y) {
|
||||||
function CB1(t) {
|
function CB1(t) {
|
||||||
return t * t * t;
|
return t * t * t;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
y: y
|
y: y
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Kinetic.Plugins.Path.getPointOnQuadraticBezier = function(pct, P1x, P1y, P2x, P2y, P3x, P3y) {
|
Kinetic.Path.getPointOnQuadraticBezier = function(pct, P1x, P1y, P2x, P2y, P3x, P3y) {
|
||||||
function QB1(t) {
|
function QB1(t) {
|
||||||
return t * t;
|
return t * t;
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@
|
|||||||
y: y
|
y: y
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Kinetic.Plugins.Path.getPointOnEllipticalArc = function(cx, cy, rx, ry, theta, psi) {
|
Kinetic.Path.getPointOnEllipticalArc = function(cx, cy, rx, ry, theta, psi) {
|
||||||
var cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
|
var cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
|
||||||
var pt = {
|
var pt = {
|
||||||
x: rx * Math.cos(theta),
|
x: rx * Math.cos(theta),
|
||||||
@@ -185,7 +185,7 @@
|
|||||||
* L data for the purpose of high performance Path
|
* L data for the purpose of high performance Path
|
||||||
* rendering
|
* rendering
|
||||||
*/
|
*/
|
||||||
Kinetic.Plugins.Path.parsePathData = function(data) {
|
Kinetic.Path.parsePathData = function(data) {
|
||||||
// Path Data Segment must begin with a moveTo
|
// Path Data Segment must begin with a moveTo
|
||||||
//m (x y)+ Relative moveTo (subsequent points are treated as lineTo)
|
//m (x y)+ Relative moveTo (subsequent points are treated as lineTo)
|
||||||
//M (x y)+ Absolute moveTo (subsequent points are treated as lineTo)
|
//M (x y)+ Absolute moveTo (subsequent points are treated as lineTo)
|
||||||
@@ -422,9 +422,9 @@
|
|||||||
|
|
||||||
return ca;
|
return ca;
|
||||||
};
|
};
|
||||||
Kinetic.Plugins.Path.calcLength = function(x, y, cmd, points) {
|
Kinetic.Path.calcLength = function(x, y, cmd, points) {
|
||||||
var len, p1, p2;
|
var len, p1, p2;
|
||||||
var path = Kinetic.Plugins.Path;
|
var path = Kinetic.Path;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 'L':
|
case 'L':
|
||||||
@@ -486,7 +486,7 @@
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
Kinetic.Plugins.Path.convertEndpointToCenterParameterization = function(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) {
|
Kinetic.Path.convertEndpointToCenterParameterization = function(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) {
|
||||||
// Derived from: http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
|
// Derived from: http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
|
||||||
var psi = psiDeg * (Math.PI / 180.0);
|
var psi = psiDeg * (Math.PI / 180.0);
|
||||||
var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
|
var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
|
||||||
@@ -543,7 +543,7 @@
|
|||||||
return [cx, cy, rx, ry, theta, dTheta, psi, fs];
|
return [cx, cy, rx, ry, theta, dTheta, psi, fs];
|
||||||
};
|
};
|
||||||
// add getters setters
|
// add getters setters
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.Path, 'data');
|
Kinetic.Node.addGetterSetter(Kinetic.Path, 'data');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set SVG path data string. This method
|
* set SVG path data string. This method
|
||||||
@@ -551,13 +551,13 @@
|
|||||||
* into a data array. Currently supported SVG data:
|
* into a data array. Currently supported SVG data:
|
||||||
* M, m, L, l, H, h, V, v, Q, q, T, t, C, c, S, s, A, a, Z, z
|
* M, m, L, l, H, h, V, v, Q, q, T, t, C, c, S, s, A, a, Z, z
|
||||||
* @name setData
|
* @name setData
|
||||||
* @methodOf Kinetic.Plugins.Path.prototype
|
* @methodOf Kinetic.Path.prototype
|
||||||
* @param {String} SVG path command string
|
* @param {String} SVG path command string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get SVG path data string
|
* get SVG path data string
|
||||||
* @name getData
|
* @name getData
|
||||||
* @methodOf Kinetic.Plugins.Path.prototype
|
* @methodOf Kinetic.Path.prototype
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
@@ -9,11 +9,11 @@
|
|||||||
* {{ShapeParams}}
|
* {{ShapeParams}}
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
*/
|
*/
|
||||||
Kinetic.Plugins.RegularPolygon = function(config) {
|
Kinetic.RegularPolygon = function(config) {
|
||||||
this._initRegularPolygon(config);
|
this._initRegularPolygon(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Plugins.RegularPolygon.prototype = {
|
Kinetic.RegularPolygon.prototype = {
|
||||||
_initRegularPolygon: function(config) {
|
_initRegularPolygon: function(config) {
|
||||||
this.createAttrs();
|
this.createAttrs();
|
||||||
|
|
||||||
@@ -36,35 +36,35 @@
|
|||||||
canvas.fillStroke(this);
|
canvas.fillStroke(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Kinetic.Global.extend(Kinetic.Plugins.RegularPolygon, Kinetic.Shape);
|
Kinetic.Global.extend(Kinetic.RegularPolygon, Kinetic.Shape);
|
||||||
|
|
||||||
// add getters setters
|
// add getters setters
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.RegularPolygon, 'radius', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.RegularPolygon, 'radius', 0);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.RegularPolygon, 'sides', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.RegularPolygon, 'sides', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set radius
|
* set radius
|
||||||
* @name setRadius
|
* @name setRadius
|
||||||
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
|
* @methodOf Kinetic.RegularPolygon.prototype
|
||||||
* @param {Number} radius
|
* @param {Number} radius
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set number of sides
|
* set number of sides
|
||||||
* @name setSides
|
* @name setSides
|
||||||
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
|
* @methodOf Kinetic.RegularPolygon.prototype
|
||||||
* @param {int} sides
|
* @param {int} sides
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get radius
|
* get radius
|
||||||
* @name getRadius
|
* @name getRadius
|
||||||
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
|
* @methodOf Kinetic.RegularPolygon.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get number of sides
|
* get number of sides
|
||||||
* @name getSides
|
* @name getSides
|
||||||
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
|
* @methodOf Kinetic.RegularPolygon.prototype
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
@@ -10,11 +10,11 @@
|
|||||||
* {{ShapeParams}}
|
* {{ShapeParams}}
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
*/
|
*/
|
||||||
Kinetic.Plugins.Star = function(config) {
|
Kinetic.Star = function(config) {
|
||||||
this._initStar(config);
|
this._initStar(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Plugins.Star.prototype = {
|
Kinetic.Star.prototype = {
|
||||||
_initStar: function(config) {
|
_initStar: function(config) {
|
||||||
this.createAttrs();
|
this.createAttrs();
|
||||||
|
|
||||||
@@ -40,49 +40,49 @@
|
|||||||
canvas.fillStroke(this);
|
canvas.fillStroke(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Kinetic.Global.extend(Kinetic.Plugins.Star, Kinetic.Shape);
|
Kinetic.Global.extend(Kinetic.Star, Kinetic.Shape);
|
||||||
|
|
||||||
// add getters setters
|
// add getters setters
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.Star, 'numPoints', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.Star, 'numPoints', 0);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.Star, 'innerRadius', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.Star, 'innerRadius', 0);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.Star, 'outerRadius', 0);
|
Kinetic.Node.addGetterSetter(Kinetic.Star, 'outerRadius', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set number of points
|
* set number of points
|
||||||
* @name setNumPoints
|
* @name setNumPoints
|
||||||
* @methodOf Kinetic.Plugins.Star.prototype
|
* @methodOf Kinetic.Star.prototype
|
||||||
* @param {Integer} points
|
* @param {Integer} points
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set outer radius
|
* set outer radius
|
||||||
* @name setOuterRadius
|
* @name setOuterRadius
|
||||||
* @methodOf Kinetic.Plugins.Star.prototype
|
* @methodOf Kinetic.Star.prototype
|
||||||
* @param {Number} radius
|
* @param {Number} radius
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set inner radius
|
* set inner radius
|
||||||
* @name setInnerRadius
|
* @name setInnerRadius
|
||||||
* @methodOf Kinetic.Plugins.Star.prototype
|
* @methodOf Kinetic.Star.prototype
|
||||||
* @param {Number} radius
|
* @param {Number} radius
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get number of points
|
* get number of points
|
||||||
* @name getNumPoints
|
* @name getNumPoints
|
||||||
* @methodOf Kinetic.Plugins.Star.prototype
|
* @methodOf Kinetic.Star.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get outer radius
|
* get outer radius
|
||||||
* @name getOuterRadius
|
* @name getOuterRadius
|
||||||
* @methodOf Kinetic.Plugins.Star.prototype
|
* @methodOf Kinetic.Star.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get inner radius
|
* get inner radius
|
||||||
* @name getInnerRadius
|
* @name getInnerRadius
|
||||||
* @methodOf Kinetic.Plugins.Star.prototype
|
* @methodOf Kinetic.Star.prototype
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
* {{ShapeParams}}
|
* {{ShapeParams}}
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
*/
|
*/
|
||||||
Kinetic.Plugins.TextPath = function(config) {
|
Kinetic.TextPath = function(config) {
|
||||||
this._initTextPath(config);
|
this._initTextPath(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
context.strokeText(this.partialText, 0, 0);
|
context.strokeText(this.partialText, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Kinetic.Plugins.TextPath.prototype = {
|
Kinetic.TextPath.prototype = {
|
||||||
_initTextPath: function(config) {
|
_initTextPath: function(config) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@
|
|||||||
this.shapeType = 'TextPath';
|
this.shapeType = 'TextPath';
|
||||||
this._setDrawFuncs();
|
this._setDrawFuncs();
|
||||||
|
|
||||||
this.dataArray = Kinetic.Plugins.Path.parsePathData(this.attrs.data);
|
this.dataArray = Kinetic.Path.parsePathData(this.attrs.data);
|
||||||
this.on('dataChange', function() {
|
this.on('dataChange', function() {
|
||||||
that.dataArray = Kinetic.Plugins.Path.parsePathData(this.attrs.data);
|
that.dataArray = Kinetic.Path.parsePathData(this.attrs.data);
|
||||||
});
|
});
|
||||||
// update text data for certain attr changes
|
// update text data for certain attr changes
|
||||||
var attrs = ['text', 'textStroke', 'textStrokeWidth'];
|
var attrs = ['text', 'textStroke', 'textStrokeWidth'];
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
/**
|
/**
|
||||||
* get text width in pixels
|
* get text width in pixels
|
||||||
* @name getTextWidth
|
* @name getTextWidth
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
*/
|
*/
|
||||||
getTextWidth: function() {
|
getTextWidth: function() {
|
||||||
return this.textWidth;
|
return this.textWidth;
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
/**
|
/**
|
||||||
* get text height in pixels
|
* get text height in pixels
|
||||||
* @name getTextHeight
|
* @name getTextHeight
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
*/
|
*/
|
||||||
getTextHeight: function() {
|
getTextHeight: function() {
|
||||||
return this.textHeight;
|
return this.textHeight;
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
/**
|
/**
|
||||||
* set text
|
* set text
|
||||||
* @name setText
|
* @name setText
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
* @param {String} text
|
* @param {String} text
|
||||||
*/
|
*/
|
||||||
setText: function(text) {
|
setText: function(text) {
|
||||||
@@ -201,8 +201,8 @@
|
|||||||
|
|
||||||
switch (pathCmd.command) {
|
switch (pathCmd.command) {
|
||||||
case 'L':
|
case 'L':
|
||||||
if(Kinetic.Plugins.Path.getLineLength(p0.x, p0.y, pathCmd.points[0], pathCmd.points[1]) > glyphWidth) {
|
if(Kinetic.Path.getLineLength(p0.x, p0.y, pathCmd.points[0], pathCmd.points[1]) > glyphWidth) {
|
||||||
p1 = Kinetic.Plugins.Path.getPointOnLine(glyphWidth, p0.x, p0.y, pathCmd.points[0], pathCmd.points[1], p0.x, p0.y);
|
p1 = Kinetic.Path.getPointOnLine(glyphWidth, p0.x, p0.y, pathCmd.points[0], pathCmd.points[1], p0.x, p0.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pathCmd = undefined;
|
pathCmd = undefined;
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
currentT = end;
|
currentT = end;
|
||||||
needNewSegment = true;
|
needNewSegment = true;
|
||||||
}
|
}
|
||||||
p1 = Kinetic.Plugins.Path.getPointOnEllipticalArc(pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3], currentT, pathCmd.points[6]);
|
p1 = Kinetic.Path.getPointOnEllipticalArc(pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3], currentT, pathCmd.points[6]);
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
if(currentT === 0) {
|
if(currentT === 0) {
|
||||||
@@ -245,7 +245,7 @@
|
|||||||
currentT = 1.0;
|
currentT = 1.0;
|
||||||
needNewSegment = true;
|
needNewSegment = true;
|
||||||
}
|
}
|
||||||
p1 = Kinetic.Plugins.Path.getPointOnCubicBezier(currentT, pathCmd.start.x, pathCmd.start.y, pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3], pathCmd.points[4], pathCmd.points[5]);
|
p1 = Kinetic.Path.getPointOnCubicBezier(currentT, pathCmd.start.x, pathCmd.start.y, pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3], pathCmd.points[4], pathCmd.points[5]);
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
if(currentT === 0)
|
if(currentT === 0)
|
||||||
@@ -259,13 +259,13 @@
|
|||||||
currentT = 1.0;
|
currentT = 1.0;
|
||||||
needNewSegment = true;
|
needNewSegment = true;
|
||||||
}
|
}
|
||||||
p1 = Kinetic.Plugins.Path.getPointOnQuadraticBezier(currentT, pathCmd.start.x, pathCmd.start.y, pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3]);
|
p1 = Kinetic.Path.getPointOnQuadraticBezier(currentT, pathCmd.start.x, pathCmd.start.y, pathCmd.points[0], pathCmd.points[1], pathCmd.points[2], pathCmd.points[3]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p1 !== undefined) {
|
if(p1 !== undefined) {
|
||||||
currLen = Kinetic.Plugins.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
currLen = Kinetic.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needNewSegment) {
|
if(needNewSegment) {
|
||||||
@@ -282,7 +282,7 @@
|
|||||||
if(p0 === undefined || p1 === undefined)
|
if(p0 === undefined || p1 === undefined)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
var width = Kinetic.Plugins.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
var width = Kinetic.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
|
||||||
// Note: Since glyphs are rendered one at a time, any kerning pair data built into the font will not be used.
|
// Note: Since glyphs are rendered one at a time, any kerning pair data built into the font will not be used.
|
||||||
// Can foresee having a rough pair table built in that the developer can override as needed.
|
// Can foresee having a rough pair table built in that the developer can override as needed.
|
||||||
@@ -290,7 +290,7 @@
|
|||||||
var kern = 0;
|
var kern = 0;
|
||||||
// placeholder for future implementation
|
// placeholder for future implementation
|
||||||
|
|
||||||
var midpoint = Kinetic.Plugins.Path.getPointOnLine(kern + width / 2.0, p0.x, p0.y, p1.x, p1.y);
|
var midpoint = Kinetic.Path.getPointOnLine(kern + width / 2.0, p0.x, p0.y, p1.x, p1.y);
|
||||||
|
|
||||||
var rotation = Math.atan2((p1.y - p0.y), (p1.x - p0.x));
|
var rotation = Math.atan2((p1.y - p0.y), (p1.x - p0.x));
|
||||||
this.glyphInfo.push({
|
this.glyphInfo.push({
|
||||||
@@ -307,59 +307,59 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// map TextPath methods to Text
|
// map TextPath methods to Text
|
||||||
Kinetic.Plugins.TextPath.prototype._getContextFont = Kinetic.Text.prototype._getContextFont;
|
Kinetic.TextPath.prototype._getContextFont = Kinetic.Text.prototype._getContextFont;
|
||||||
|
|
||||||
Kinetic.Global.extend(Kinetic.Plugins.TextPath, Kinetic.Shape);
|
Kinetic.Global.extend(Kinetic.TextPath, Kinetic.Shape);
|
||||||
|
|
||||||
// add setters and getters
|
// add setters and getters
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.TextPath, 'fontFamily', CALIBRI);
|
Kinetic.Node.addGetterSetter(Kinetic.TextPath, 'fontFamily', CALIBRI);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.TextPath, 'fontSize', 12);
|
Kinetic.Node.addGetterSetter(Kinetic.TextPath, 'fontSize', 12);
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Plugins.TextPath, 'fontStyle', NORMAL);
|
Kinetic.Node.addGetterSetter(Kinetic.TextPath, 'fontStyle', NORMAL);
|
||||||
|
|
||||||
Kinetic.Node.addGetter(Kinetic.Plugins.TextPath, 'text', EMPTY_STRING);
|
Kinetic.Node.addGetter(Kinetic.TextPath, 'text', EMPTY_STRING);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set font family
|
* set font family
|
||||||
* @name setFontFamily
|
* @name setFontFamily
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
* @param {String} fontFamily
|
* @param {String} fontFamily
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set font size
|
* set font size
|
||||||
* @name setFontSize
|
* @name setFontSize
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
* @param {int} fontSize
|
* @param {int} fontSize
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set font style. Can be 'normal', 'italic', or 'bold'. 'normal' is the default.
|
* set font style. Can be 'normal', 'italic', or 'bold'. 'normal' is the default.
|
||||||
* @name setFontStyle
|
* @name setFontStyle
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
* @param {String} fontStyle
|
* @param {String} fontStyle
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get font family
|
* get font family
|
||||||
* @name getFontFamily
|
* @name getFontFamily
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get font size
|
* get font size
|
||||||
* @name getFontSize
|
* @name getFontSize
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get font style
|
* get font style
|
||||||
* @name getFontStyle
|
* @name getFontStyle
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get text
|
* get text
|
||||||
* @name getText
|
* @name getText
|
||||||
* @methodOf Kinetic.Plugins.TextPath.prototype
|
* @methodOf Kinetic.TextPath.prototype
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
@@ -331,7 +331,7 @@ Test.Modules.EVENTS = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
numPoints: 10,
|
numPoints: 10,
|
||||||
@@ -404,7 +404,7 @@ Test.Modules.EVENTS = {
|
|||||||
var layer = new Kinetic.Layer({
|
var layer = new Kinetic.Layer({
|
||||||
rotationDeg: 20
|
rotationDeg: 20
|
||||||
});
|
});
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
numPoints: 10,
|
numPoints: 10,
|
||||||
@@ -788,7 +788,7 @@ Test.Modules.DRAG_AND_DROP = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
numPoints: 5,
|
numPoints: 5,
|
||||||
|
@@ -528,7 +528,7 @@ Test.Modules.PERFORMANCE = {
|
|||||||
|
|
||||||
startTimer();
|
startTimer();
|
||||||
for(var n = 0; n < 1000; n++) {
|
for(var n = 0; n < 1000; n++) {
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
innerRadius: 20,
|
innerRadius: 20,
|
||||||
outerRadius: 50,
|
outerRadius: 50,
|
||||||
fill: 'yellow',
|
fill: 'yellow',
|
||||||
@@ -560,7 +560,7 @@ Test.Modules.PERFORMANCE = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
innerRadius: 20,
|
innerRadius: 20,
|
||||||
outerRadius: 50,
|
outerRadius: 50,
|
||||||
fill: 'yellow',
|
fill: 'yellow',
|
||||||
|
@@ -517,7 +517,7 @@ Test.Modules.CONTAINER = {
|
|||||||
fill: 'red'
|
fill: 'red'
|
||||||
});
|
});
|
||||||
|
|
||||||
var textpath = new Kinetic.Plugins.TextPath({
|
var textpath = new Kinetic.TextPath({
|
||||||
y: 35,
|
y: 35,
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
@@ -528,7 +528,7 @@ Test.Modules.CONTAINER = {
|
|||||||
data: "M 10,10 300,150 550,150"
|
data: "M 10,10 300,150 550,150"
|
||||||
});
|
});
|
||||||
|
|
||||||
var path = new Kinetic.Plugins.Path({
|
var path = new Kinetic.Path({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: -75,
|
y: -75,
|
||||||
data: 'M200,100h100v50z',
|
data: 'M200,100h100v50z',
|
||||||
@@ -541,7 +541,7 @@ Test.Modules.CONTAINER = {
|
|||||||
shadowOpacity: 0.5
|
shadowOpacity: 0.5
|
||||||
});
|
});
|
||||||
|
|
||||||
var poly = new Kinetic.Plugins.RegularPolygon({
|
var poly = new Kinetic.RegularPolygon({
|
||||||
x: stage.getWidth() / 2,
|
x: stage.getWidth() / 2,
|
||||||
y: stage.getHeight() / 2,
|
y: stage.getHeight() / 2,
|
||||||
sides: 5,
|
sides: 5,
|
||||||
|
@@ -7,7 +7,7 @@ Test.Modules.LABEL = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var label = new Kinetic.Plugins.Label({
|
var label = new Kinetic.Label({
|
||||||
x: 100,
|
x: 100,
|
||||||
y: 100,
|
y: 100,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@ Test.Modules.REGULAR_POLYGON = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var poly = new Kinetic.Plugins.RegularPolygon({
|
var poly = new Kinetic.RegularPolygon({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
sides: 3,
|
sides: 3,
|
||||||
@@ -36,7 +36,7 @@ Test.Modules.REGULAR_POLYGON = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var poly = new Kinetic.Plugins.RegularPolygon({
|
var poly = new Kinetic.RegularPolygon({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
sides: 4,
|
sides: 4,
|
||||||
@@ -58,7 +58,7 @@ Test.Modules.REGULAR_POLYGON = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var poly = new Kinetic.Plugins.RegularPolygon({
|
var poly = new Kinetic.RegularPolygon({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
sides: 5,
|
sides: 5,
|
||||||
@@ -80,7 +80,7 @@ Test.Modules.REGULAR_POLYGON = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var poly = new Kinetic.Plugins.RegularPolygon({
|
var poly = new Kinetic.RegularPolygon({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
sides: 8,
|
sides: 8,
|
||||||
|
@@ -7,7 +7,7 @@ Test.Modules.STAR = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
numPoints: 5,
|
numPoints: 5,
|
||||||
@@ -48,7 +48,7 @@ Test.Modules.STAR = {
|
|||||||
fill: 'red'
|
fill: 'red'
|
||||||
});
|
});
|
||||||
|
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
numPoints: 5,
|
numPoints: 5,
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -220,7 +220,7 @@ Test.Modules.SHAPE = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
numPoints: 5,
|
numPoints: 5,
|
||||||
@@ -628,7 +628,7 @@ Test.Modules.SHAPE = {
|
|||||||
});
|
});
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
|
||||||
var star = new Kinetic.Plugins.Star({
|
var star = new Kinetic.Star({
|
||||||
x: 200,
|
x: 200,
|
||||||
y: 100,
|
y: 100,
|
||||||
numPoints: 5,
|
numPoints: 5,
|
||||||
|
Reference in New Issue
Block a user