removed plugins directory because Kinetic will be using a configurator in the near future

This commit is contained in:
Eric Rowell
2012-07-31 20:36:36 -07:00
parent 87182d704c
commit 75b20573cd
13 changed files with 1196 additions and 138 deletions

View File

@@ -8,7 +8,7 @@
* @augments Kinetic.Shape
* @param {Object} config
*/
Kinetic.Plugins.Path = Kinetic.Shape.extend({
Kinetic.Path = Kinetic.Shape.extend({
init: function(config) {
this.shapeType = "Path";
this.dataArray = [];
@@ -17,9 +17,9 @@ Kinetic.Plugins.Path = Kinetic.Shape.extend({
config.drawFunc = this.drawFunc;
// call super constructor
this._super(config);
this.dataArray = Kinetic.Plugins.Path.parsePathData(this.attrs.data);
this.dataArray = Kinetic.Path.parsePathData(this.attrs.data);
this.on('dataChange', function() {
that.dataArray = Kinetic.Plugins.Path.parsePathData(that.attrs.data);
that.dataArray = Kinetic.Path.parsePathData(that.attrs.data);
});
},
drawFunc: function(context) {
@@ -72,10 +72,10 @@ Kinetic.Plugins.Path = Kinetic.Shape.extend({
* Utility methods written by jfollas to
* 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));
};
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) {
fromX = P1x;
}
@@ -119,7 +119,7 @@ Kinetic.Plugins.Path.getPointOnLine = function(dist, P1x, P1y, P2x, P2y, fromX,
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) {
return t * t * t;
}
@@ -140,7 +140,7 @@ Kinetic.Plugins.Path.getPointOnCubicBezier = function(pct, P1x, P1y, P2x, P2y, P
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) {
return t * t;
}
@@ -158,7 +158,7 @@ Kinetic.Plugins.Path.getPointOnQuadraticBezier = function(pct, P1x, P1y, P2x, P2
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 pt = {
x: rx * Math.cos(theta),
@@ -175,7 +175,7 @@ Kinetic.Plugins.Path.getPointOnEllipticalArc = function(cx, cy, rx, ry, theta, p
* L data for the purpose of high performance Path
* rendering
*/
Kinetic.Plugins.Path.parsePathData = function(data) {
Kinetic.Path.parsePathData = function(data) {
// Path Data Segment must begin with a moveTo
//m (x y)+ Relative moveTo (subsequent points are treated as lineTo)
//M (x y)+ Absolute moveTo (subsequent points are treated as lineTo)
@@ -414,9 +414,9 @@ Kinetic.Plugins.Path.parsePathData = function(data) {
return ca;
};
Kinetic.Plugins.Path.calcLength = function(x, y, cmd, points) {
Kinetic.Path.calcLength = function(x, y, cmd, points) {
var len, p1, p2;
var path = Kinetic.Plugins.Path;
var path = Kinetic.Path;
switch (cmd) {
case 'L':
@@ -478,7 +478,7 @@ Kinetic.Plugins.Path.calcLength = function(x, y, cmd, points) {
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
var psi = psiDeg * (Math.PI / 180.0);
var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
@@ -536,7 +536,7 @@ Kinetic.Plugins.Path.convertEndpointToCenterParameterization = function(x1, y1,
};
// add getters setters
Kinetic.Node.addGettersSetters(Kinetic.Plugins.Path, ['data']);
Kinetic.Node.addGettersSetters(Kinetic.Path, ['data']);
/**
* set SVG path data string. This method
@@ -544,12 +544,12 @@ Kinetic.Node.addGettersSetters(Kinetic.Plugins.Path, ['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
* @name setData
* @methodOf Kinetic.Plugins.Path.prototype
* @methodOf Kinetic.Path.prototype
* @param {String} SVG path command string
*/
/**
* get SVG path data string
* @name getData
* @methodOf Kinetic.Plugins.Path.prototype
* @methodOf Kinetic.Path.prototype
*/

View File

@@ -7,7 +7,7 @@
* @augments Kinetic.Shape
* @param {Object} config
*/
Kinetic.Plugins.RegularPolygon = Kinetic.Shape.extend({
Kinetic.RegularPolygon = Kinetic.Shape.extend({
init: function(config) {
this.setDefaultAttrs({
radius: 0,
@@ -35,29 +35,29 @@ Kinetic.Plugins.RegularPolygon = Kinetic.Shape.extend({
});
// add getters setters
Kinetic.Node.addGettersSetters(Kinetic.Plugins.RegularPolygon, ['radius', 'sides']);
Kinetic.Node.addGettersSetters(Kinetic.RegularPolygon, ['radius', 'sides']);
/**
* set radius
* @name setRadius
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
* @methodOf Kinetic.RegularPolygon.prototype
* @param {Number} radius
*/
/**
* set number of sides
* @name setSides
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
* @methodOf Kinetic.RegularPolygon.prototype
* @param {int} sides
*/
/**
* get radius
* @name getRadius
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
* @methodOf Kinetic.RegularPolygon.prototype
*/
/**
* get number of sides
* @name getSides
* @methodOf Kinetic.Plugins.RegularPolygon.prototype
* @methodOf Kinetic.RegularPolygon.prototype
*/

View File

@@ -7,7 +7,7 @@
* @augments Kinetic.Shape
* @param {Object} config
*/
Kinetic.Plugins.Star = Kinetic.Shape.extend({
Kinetic.Star = Kinetic.Shape.extend({
init: function(config) {
this.setDefaultAttrs({
numPoints: 0,
@@ -38,43 +38,43 @@ Kinetic.Plugins.Star = Kinetic.Shape.extend({
});
// add getters setters
Kinetic.Node.addGettersSetters(Kinetic.Plugins.Star, ['numPoints', 'innerRadius', 'outerRadius']);
Kinetic.Node.addGettersSetters(Kinetic.Star, ['numPoints', 'innerRadius', 'outerRadius']);
/**
* set number of points
* @name setNumPoints
* @methodOf Kinetic.Plugins.Star.prototype
* @methodOf Kinetic.Star.prototype
* @param {Integer} points
*/
/**
* set outer radius
* @name setOuterRadius
* @methodOf Kinetic.Plugins.Star.prototype
* @methodOf Kinetic.Star.prototype
* @param {Number} radius
*/
/**
* set inner radius
* @name setInnerRadius
* @methodOf Kinetic.Plugins.Star.prototype
* @methodOf Kinetic.Star.prototype
* @param {Number} radius
*/
/**
* get number of points
* @name getNumPoints
* @methodOf Kinetic.Plugins.Star.prototype
* @methodOf Kinetic.Star.prototype
*/
/**
* get outer radius
* @name getOuterRadius
* @methodOf Kinetic.Plugins.Star.prototype
* @methodOf Kinetic.Star.prototype
*/
/**
* get inner radius
* @name getInnerRadius
* @methodOf Kinetic.Plugins.Star.prototype
* @methodOf Kinetic.Star.prototype
*/

View File

@@ -8,7 +8,7 @@
* @augments Kinetic.Shape
* @param {Object} config
*/
Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
Kinetic.TextPath = Kinetic.Shape.extend({
init: function(config) {
this.setDefaultAttrs({
fontFamily: 'Calibri',
@@ -26,9 +26,9 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
config.drawFunc = this.drawFunc;
// call super constructor
this._super(config);
this.dataArray = Kinetic.Plugins.Path.parsePathData(this.attrs.data);
this.dataArray = Kinetic.Path.parsePathData(this.attrs.data);
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
var attrs = ['text', 'textStroke', 'textStrokeWidth'];
@@ -81,7 +81,7 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
/**
* get text width in pixels
* @name getTextWidth
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
getTextWidth: function() {
return this.textWidth;
@@ -89,7 +89,7 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
/**
* get text height in pixels
* @name getTextHeight
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
getTextHeight: function() {
return this.textHeight;
@@ -176,8 +176,8 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
switch (pathCmd.command) {
case 'L':
if(Kinetic.Plugins.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);
if(Kinetic.Path.getLineLength(p0.x, p0.y, pathCmd.points[0], pathCmd.points[1]) > glyphWidth) {
p1 = Kinetic.Path.getPointOnLine(glyphWidth, p0.x, p0.y, pathCmd.points[0], pathCmd.points[1], p0.x, p0.y);
}
else
pathCmd = undefined;
@@ -202,7 +202,7 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
currentT = end;
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;
case 'C':
if(currentT === 0) {
@@ -220,7 +220,7 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
currentT = 1.0;
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;
case 'Q':
if(currentT === 0)
@@ -234,13 +234,13 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
currentT = 1.0;
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;
}
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) {
@@ -257,7 +257,7 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
if(p0 === undefined || p1 === undefined)
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.
// Can foresee having a rough pair table built in that the developer can override as needed.
@@ -265,7 +265,7 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
var kern = 0;
// 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));
this.glyphInfo.push({
@@ -282,95 +282,95 @@ Kinetic.Plugins.TextPath = Kinetic.Shape.extend({
});
// add setters and getters
Kinetic.Node.addGettersSetters(Kinetic.Plugins.TextPath, ['fontFamily', 'fontSize', 'fontStyle', 'textFill', 'textStroke', 'textStrokeWidth', 'text']);
Kinetic.Node.addGettersSetters(Kinetic.TextPath, ['fontFamily', 'fontSize', 'fontStyle', 'textFill', 'textStroke', 'textStrokeWidth', 'text']);
/**
* set font family
* @name setFontFamily
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
* @param {String} fontFamily
*/
/**
* set font size
* @name setFontSize
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
* @param {int} fontSize
*/
/**
* set font style. Can be "normal", "italic", or "bold". "normal" is the default.
* @name setFontStyle
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
* @param {String} fontStyle
*/
/**
* set text fill color
* @name setTextFill
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
* @param {String} textFill
*/
/**
* set text stroke color
* @name setFontStroke
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
* @param {String} textStroke
*/
/**
* set text stroke width
* @name setTextStrokeWidth
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
* @param {int} textStrokeWidth
*/
/**
* set text
* @name setText
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
* @param {String} text
*/
/**
* get font family
* @name getFontFamily
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
/**
* get font size
* @name getFontSize
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
/**
* get font style
* @name getFontStyle
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
/**
* get text fill color
* @name getTextFill
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
/**
* get text stroke color
* @name getTextStroke
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
/**
* get text stroke width
* @name getTextStrokeWidth
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/
/**
* get text
* @name getText
* @methodOf Kinetic.Plugins.TextPath.prototype
* @methodOf Kinetic.TextPath.prototype
*/