mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Various clean-ups in Path.
This commit is contained in:
parent
311ae66a0f
commit
620cb2c754
1 changed files with 8 additions and 5 deletions
|
@ -278,7 +278,8 @@ Path = PathItem.extend({
|
||||||
if (parameter == null)
|
if (parameter == null)
|
||||||
parameter = 0.5;
|
parameter = 0.5;
|
||||||
var current = this.currentSegment.point;
|
var current = this.currentSegment.point;
|
||||||
// handle = (through - (1 - t)^2 * current - t^2 * to) / (2 * (1 - t) * t)
|
// handle = (through - (1 - t)^2 * current - t^2 * to) /
|
||||||
|
// (2 * (1 - t) * t)
|
||||||
var t1 = 1 - parameter;
|
var t1 = 1 - parameter;
|
||||||
var handle = through.subtract(
|
var handle = through.subtract(
|
||||||
current.multiply(t1 * t1)).subtract(
|
current.multiply(t1 * t1)).subtract(
|
||||||
|
@ -392,7 +393,8 @@ Path = PathItem.extend({
|
||||||
throughVector = Point.read(throughVector);
|
throughVector = Point.read(throughVector);
|
||||||
toVector = Point.read(toVector);
|
toVector = Point.read(toVector);
|
||||||
var current = this.currentSegment.point;
|
var current = this.currentSegment.point;
|
||||||
this.curveTo(current.add(throughVector), current.add(toVector), parameter);
|
this.curveTo(current.add(throughVector), current.add(toVector),
|
||||||
|
parameter);
|
||||||
},
|
},
|
||||||
|
|
||||||
arcBy: function(throughVector, toVector) {
|
arcBy: function(throughVector, toVector) {
|
||||||
|
@ -444,7 +446,8 @@ Path = PathItem.extend({
|
||||||
var x = segment.point.x;
|
var x = segment.point.x;
|
||||||
var y = segment.point.y;
|
var y = segment.point.y;
|
||||||
var handleIn = segment.handleIn;
|
var handleIn = segment.handleIn;
|
||||||
ctx.bezierCurveTo(outX, outY, handleIn.x + x, handleIn.y + y, x, y);
|
ctx.bezierCurveTo(outX, outY, handleIn.x + x, handleIn.y + y,
|
||||||
|
x, y);
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
}
|
}
|
||||||
if (!param.compound) {
|
if (!param.compound) {
|
||||||
|
@ -464,7 +467,7 @@ Path = PathItem.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}, new function() { // inject methods that require scoped privates
|
}, new function() { // Inject methods that require scoped privates
|
||||||
/**
|
/**
|
||||||
* Solves a tri-diagonal system for one of coordinates (x or y) of first
|
* Solves a tri-diagonal system for one of coordinates (x or y) of first
|
||||||
* bezier control points.
|
* bezier control points.
|
||||||
|
@ -472,7 +475,7 @@ Path = PathItem.extend({
|
||||||
* @param rhs right hand side vector.
|
* @param rhs right hand side vector.
|
||||||
* @return Solution vector.
|
* @return Solution vector.
|
||||||
*/
|
*/
|
||||||
var getFirstControlPoints = function(rhs) {
|
function getFirstControlPoints(rhs) {
|
||||||
var n = rhs.length;
|
var n = rhs.length;
|
||||||
var x = []; // Solution vector.
|
var x = []; // Solution vector.
|
||||||
var tmp = []; // Temporary workspace.
|
var tmp = []; // Temporary workspace.
|
||||||
|
|
Loading…
Reference in a new issue