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