Some Curve._evaluateMethods related cleanup.

This commit is contained in:
Jürg Lehni 2016-01-27 11:37:12 +01:00
parent 849688833e
commit ed8a904b74
4 changed files with 17 additions and 21 deletions

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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);