mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-05 01:10:27 -04:00
Add missing documentation for various location related functions on Curve.
This commit is contained in:
parent
c7d8aebb9e
commit
b0deda9445
2 changed files with 44 additions and 19 deletions
|
@ -759,14 +759,15 @@ statics: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/** @lends Curve# */{
|
/** @lends Curve# */{
|
||||||
// DOCS: Document #getParameterAt(offset, start)
|
|
||||||
// DOCS: Document #getParameterOf(point)
|
|
||||||
// DOCS: Document #getLocationAt(offset, isParameter)
|
|
||||||
// DOCS: Document #getLocationOf(point)
|
|
||||||
/**
|
/**
|
||||||
|
* Calculates the curve time parameter of the specified offset on the path,
|
||||||
|
* relative to the provided start parameter. If offset is a negative value,
|
||||||
|
* the parameter is searched to the left of the start parameter. If no start
|
||||||
|
* parameter is provided, a default of {@code 0} for positive values of
|
||||||
|
* {@code offset} and {@code 1} for negative values of {@code offset}.
|
||||||
* @param {Number} offset
|
* @param {Number} offset
|
||||||
* @param {Number} [start]
|
* @param {Number} [start]
|
||||||
* @return {Number}
|
* @return {Number} the curve time parameter at the specified offset.
|
||||||
*/
|
*/
|
||||||
getParameterAt: function(offset, start) {
|
getParameterAt: function(offset, start) {
|
||||||
return Curve.getParameterAt(this.getValues(), offset,
|
return Curve.getParameterAt(this.getValues(), offset,
|
||||||
|
@ -774,33 +775,52 @@ statics: {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Point} point
|
* Returns the curve time parameter of the specified point if it lies on the
|
||||||
* @return {Number}
|
* curve, {@code null} otherwise.
|
||||||
|
* @param {Point} point the point on the curve.
|
||||||
|
* @return {Number} the curve time parameter of the specified point.
|
||||||
*/
|
*/
|
||||||
getParameterOf: function(point) {
|
getParameterOf: function(point) {
|
||||||
point = Point.read(arguments);
|
point = Point.read(arguments);
|
||||||
return Curve.getParameterOf(this.getValues(), point.x, point.y);
|
return Curve.getParameterOf(this.getValues(), point.x, point.y);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the curve location at the specified offset or curve time
|
||||||
|
* parameter.
|
||||||
|
* @param {Number} offset the offset on the curve, or the curve time
|
||||||
|
* parameter if {@code isParameter} is {@code true}
|
||||||
|
* @param {Boolean} [isParameter=false] pass {@code true} if {@code offset}
|
||||||
|
* is a curve time parameter.
|
||||||
|
* @return {CurveLocation} the curve location at the specified the offset.
|
||||||
|
*/
|
||||||
getLocationAt: function(offset, isParameter) {
|
getLocationAt: function(offset, isParameter) {
|
||||||
if (!isParameter)
|
if (!isParameter)
|
||||||
offset = this.getParameterAt(offset);
|
offset = this.getParameterAt(offset);
|
||||||
return new CurveLocation(this, offset);
|
return new CurveLocation(this, offset);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the curve location of the specified point if it lies on the
|
||||||
|
* curve, {@code null} otherwise.
|
||||||
|
* @param {Point} point the point on the curve.
|
||||||
|
* @return {CurveLocation} the curve location of the specified point.
|
||||||
|
*/
|
||||||
getLocationOf: function(point) {
|
getLocationOf: function(point) {
|
||||||
var t = this.getParameterOf.apply(this, arguments);
|
var t = this.getParameterOf.apply(this, arguments);
|
||||||
return t != null ? new CurveLocation(this, t) : null;
|
return t != null ? new CurveLocation(this, t) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the point on the curve at the specified position.
|
* Returns the point on the curve at the specified offset.
|
||||||
*
|
*
|
||||||
* @name Curve#getPointAt
|
* @name Curve#getPointAt
|
||||||
* @function
|
* @function
|
||||||
* @param {Number} parameter the position at which to find the point as
|
* @param {Number} offset the offset on the curve, or the curve time
|
||||||
* a value between {@code 0} and {@code 1}.
|
* parameter if {@code isParameter} is {@code true}
|
||||||
* @return {Point}
|
* @param {Boolean} [isParameter=false] pass {@code true} if {@code offset}
|
||||||
|
* is a curve time parameter.
|
||||||
|
* @return {Point} the point on the curve at the specified offset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -808,8 +828,11 @@ statics: {
|
||||||
*
|
*
|
||||||
* @name Curve#getTangentAt
|
* @name Curve#getTangentAt
|
||||||
* @function
|
* @function
|
||||||
* @param {Number} parameter the position at which to find the tangent
|
* @param {Number} offset the offset on the curve, or the curve time
|
||||||
* point as a value between {@code 0} and {@code 1}.
|
* parameter if {@code isParameter} is {@code true}
|
||||||
|
* @param {Boolean} [isParameter=false] pass {@code true} if {@code offset}
|
||||||
|
* is a curve time parameter.
|
||||||
|
* @return {Point} the tangent to the curve at the specified offset.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -817,8 +840,11 @@ statics: {
|
||||||
*
|
*
|
||||||
* @name Curve#getNormalAt
|
* @name Curve#getNormalAt
|
||||||
* @function
|
* @function
|
||||||
* @param {Number} parameter the position at which to find the normal
|
* @param {Number} offset the offset on the curve, or the curve time
|
||||||
* point as a value between {@code 0} and {@code 1}.
|
* parameter if {@code isParameter} is {@code true}
|
||||||
|
* @param {Boolean} [isParameter=false] pass {@code true} if {@code offset}
|
||||||
|
* is a curve time parameter.
|
||||||
|
* @return {Point} the normal of the curve at the specified offset.
|
||||||
*/
|
*/
|
||||||
}),
|
}),
|
||||||
new function() { // Scope for methods that require numerical integration
|
new function() { // Scope for methods that require numerical integration
|
||||||
|
|
|
@ -1123,7 +1123,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the point on the path at the given offset.
|
* Calculates the point on the path at the given offset.
|
||||||
*
|
*
|
||||||
* @param {Number} offset
|
* @param {Number} offset
|
||||||
* @param {Boolean} [isParameter=false]
|
* @param {Boolean} [isParameter=false]
|
||||||
|
@ -1177,8 +1177,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the tangent to the path at the given offset as a vector
|
* Calculates the tangent to the path at the given offset as a vector point.
|
||||||
* point.
|
|
||||||
*
|
*
|
||||||
* @param {Number} offset
|
* @param {Number} offset
|
||||||
* @param {Boolean} [isParameter=false]
|
* @param {Boolean} [isParameter=false]
|
||||||
|
@ -1246,7 +1245,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the normal to the path at the given offset as a vector point.
|
* Calculates the normal to the path at the given offset as a vector point.
|
||||||
*
|
*
|
||||||
* @param {Number} offset
|
* @param {Number} offset
|
||||||
* @param {Boolean} [isParameter=false]
|
* @param {Boolean} [isParameter=false]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue