mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Clean up Curve#divide() code.
This commit is contained in:
parent
3101989974
commit
85de8a0b7d
1 changed files with 9 additions and 11 deletions
|
@ -393,26 +393,24 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
|||
var parts = Curve.subdivide(this.getValues(), parameter),
|
||||
isLinear = this.isLinear(),
|
||||
left = parts[0],
|
||||
right = parts[1],
|
||||
point1 = this._segment1._point,
|
||||
point2 = this._segment2._point;
|
||||
right = parts[1];
|
||||
|
||||
// Write back the results:
|
||||
if (!isLinear) {
|
||||
this._segment1._handleOut.set(left[2] - point1._x,
|
||||
left[3] - point1._y);
|
||||
this._segment1._handleOut.set(left[2] - left[0],
|
||||
left[3] - left[1]);
|
||||
// segment2 is the end segment. By inserting newSegment
|
||||
// between segment1 and 2, 2 becomes the end segment.
|
||||
// Convert absolute -> relative
|
||||
this._segment2._handleIn.set(right[4] - point2._x,
|
||||
right[5] - point2._y);
|
||||
this._segment2._handleIn.set(right[4] - right[6],
|
||||
right[5] - right[7]);
|
||||
}
|
||||
|
||||
// Create the new segment, convert absolute -> relative:
|
||||
var x = left[6], y = left[7],
|
||||
segment = new Segment(Point.create(x, y),
|
||||
isLinear ? null : Point.create(left[4] - x, left[5] - y),
|
||||
isLinear ? null : Point.create(right[2] - x, right[3] - y));
|
||||
!isLinear && Point.create(left[4] - x, left[5] - y),
|
||||
!isLinear && Point.create(right[2] - x, right[3] - y));
|
||||
|
||||
// Insert it in the segments list, if needed:
|
||||
if (this._path) {
|
||||
|
@ -427,8 +425,8 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
|||
// become the owner of the newly inserted segment.
|
||||
// TODO: I expect this.getNext() to produce the correct result,
|
||||
// but since we're inserting differently in _add (something
|
||||
// linked with CurveLocation#dividie()), this is not the case...
|
||||
res = this;
|
||||
// linked with CurveLocation#divide()), this is not the case...
|
||||
res = this; // this.getNext();
|
||||
} else {
|
||||
// otherwise create it from the result of split
|
||||
var end = this._segment2;
|
||||
|
|
Loading…
Reference in a new issue