mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Some Curve._evaluateMethods related cleanup.
This commit is contained in:
parent
849688833e
commit
ed8a904b74
4 changed files with 17 additions and 21 deletions
|
@ -1149,25 +1149,21 @@ new function() { // // Scope to inject various curve evaluation methods
|
|||
var methods = ['getPoint', 'getTangent', 'getNormal', 'getWeightedTangent',
|
||||
'getWeightedNormal', 'getCurvature'];
|
||||
return Base.each(methods,
|
||||
// NOTE: Although Curve.getBounds() exists, we are using Path.getBounds() to
|
||||
// determine the bounds of Curve objects with defined segment1 and segment2
|
||||
// values Curve.getBounds() can be used directly on curve arrays, without
|
||||
// the need to create a Curve object first, as required by the code that
|
||||
// finds path intersections.
|
||||
function(name) {
|
||||
// NOTE: (For easier searching): This loop produces:
|
||||
// getPointAt, getTangentAt, getNormalAt, getWeightedTangentAt,
|
||||
// getWeightedNormalAt, getCurvatureAt
|
||||
this[name + 'At'] = function(offset, isParameter) {
|
||||
var values = this.getValues();
|
||||
return Curve[name](values, isParameter ? offset
|
||||
: Curve.getParameterAt(values, offset, 0));
|
||||
};
|
||||
}, {
|
||||
statics: {
|
||||
evaluateMethods: methods
|
||||
function(name) {
|
||||
// NOTE: (For easier searching): This loop produces:
|
||||
// getPointAt, getTangentAt, getNormalAt, getWeightedTangentAt,
|
||||
// getWeightedNormalAt, getCurvatureAt
|
||||
this[name + 'At'] = function(offset, isParameter) {
|
||||
var values = this.getValues();
|
||||
return Curve[name](values, isParameter ? offset
|
||||
: Curve.getParameterAt(values, offset, 0));
|
||||
};
|
||||
}, {
|
||||
statics: {
|
||||
_evaluateMethods: methods
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
},
|
||||
new function() { // Scope for methods that require private functions
|
||||
|
||||
|
|
|
@ -512,7 +512,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
|||
hasOverlap: function() {
|
||||
return !!this._overlap;
|
||||
}
|
||||
}, Base.each(Curve.evaluateMethods, function(name) {
|
||||
}, Base.each(Curve._evaluateMethods, function(name) {
|
||||
// Produce getters for #getTangent() / #getNormal() / #getCurvature()
|
||||
// NOTE: (For easier searching): This loop produces:
|
||||
// getPointAt, getTangentAt, getNormalAt, getWeightedTangentAt,
|
||||
|
|
|
@ -1688,7 +1688,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
|
||||
// TODO: intersects(item)
|
||||
// TODO: contains(item)
|
||||
}, Base.each(Curve.evaluateMethods,
|
||||
}, Base.each(Curve._evaluateMethods,
|
||||
function(name) {
|
||||
// NOTE: (For easier searching): This loop produces:
|
||||
// getPointAt, getTangentAt, getNormalAt, getWeightedTangentAt,
|
||||
|
|
|
@ -146,7 +146,7 @@ var PathIterator = Base.extend({
|
|||
ctx.bezierCurveTo.apply(ctx, curve.slice(2));
|
||||
}
|
||||
}
|
||||
}, Base.each(Curve.evaluateMethods,
|
||||
}, Base.each(Curve._evaluateMethods,
|
||||
function(name) {
|
||||
this[name + 'At'] = function(offset, weighted) {
|
||||
var param = this.getParameterAt(offset);
|
||||
|
|
Loading…
Reference in a new issue