mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Remove Curve.create() in favor of direct constructor.
This commit is contained in:
parent
772c83596f
commit
52c889428b
2 changed files with 15 additions and 15 deletions
|
@ -58,24 +58,32 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
*/
|
||||
initialize: function Curve(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
||||
var count = arguments.length;
|
||||
if (count === 0) {
|
||||
if (count === 3) {
|
||||
// Undocumented internal constructor, used by Path#getCurves()
|
||||
// new Segment(path, segment1, segment2);
|
||||
this._path = arg0;
|
||||
this._segment1 = arg1;
|
||||
this._segment2 = arg2;
|
||||
} else if (count === 0) {
|
||||
this._segment1 = new Segment();
|
||||
this._segment2 = new Segment();
|
||||
} else if (count == 1) {
|
||||
} else if (count === 1) {
|
||||
// new Segment(segment);
|
||||
// Note: This copies from existing segments through bean getters
|
||||
this._segment1 = new Segment(arg0.segment1);
|
||||
this._segment2 = new Segment(arg0.segment2);
|
||||
} else if (count == 2) {
|
||||
} else if (count === 2) {
|
||||
// new Segment(segment1, segment2);
|
||||
this._segment1 = new Segment(arg0);
|
||||
this._segment2 = new Segment(arg1);
|
||||
} else {
|
||||
var point1, handle1, handle2, point2;
|
||||
if (count == 4) {
|
||||
if (count === 4) {
|
||||
point1 = arg0;
|
||||
handle1 = arg1;
|
||||
handle2 = arg2;
|
||||
point2 = arg3;
|
||||
} else if (count == 8) {
|
||||
} else if (count === 8) {
|
||||
// Convert getValue() array back to points and handles so we
|
||||
// can create segments for those.
|
||||
point1 = [arg0, arg1];
|
||||
|
@ -403,14 +411,6 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
|
||||
// Mess with indentation in order to get more line-space below...
|
||||
statics: {
|
||||
create: function(path, segment1, segment2) {
|
||||
var curve = Base.create(Curve);
|
||||
curve._path = path;
|
||||
curve._segment1 = segment1;
|
||||
curve._segment2 = segment2;
|
||||
return curve;
|
||||
},
|
||||
|
||||
getValues: function(segment1, segment2) {
|
||||
var p1 = segment1._point,
|
||||
h1 = segment1._handleOut,
|
||||
|
|
|
@ -169,7 +169,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
var length = this._countCurves();
|
||||
curves = this._curves = new Array(length);
|
||||
for (var i = 0; i < length; i++)
|
||||
curves[i] = Curve.create(this, segments[i],
|
||||
curves[i] = new Curve(this, segments[i],
|
||||
// Use first segment for segment2 of closing curve
|
||||
segments[i + 1] || segments[0]);
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
var length = this._curves.length = this._countCurves();
|
||||
// If we were closing this path, we need to add a new curve now
|
||||
if (closed)
|
||||
this._curves[length - 1] = Curve.create(this,
|
||||
this._curves[length - 1] = new Curve(this,
|
||||
this._segments[length - 1], this._segments[0]);
|
||||
}
|
||||
this._changed(/*#=*/ Change.GEOMETRY);
|
||||
|
|
Loading…
Reference in a new issue