CatmullRomCurve constructor
Constructs a centripetal CatmullRomCurve.
It takes a list of two or more points that describe the points that the curve must pass through. See controlPoints for a description of the restrictions placed on control points. In addition to the given controlPoints, the curve will begin with an implicit control point at (0.0, 0.0) and end with an implicit control point at (1.0, 1.0), so that the curve begins and ends at those points.
The optional tension argument controls how tightly the curve approaches
the given controlPoints
. It must be in the range 0.0 to 1.0, inclusive. It
defaults to 0.0, which provides the smoothest curve. A value of 1.0
is equivalent to a linear interpolation between points.
The internal curve data structures are lazily computed the first time transform is called. If you would rather pre-compute the curve, use CatmullRomCurve.precompute instead.
See also:
Implementation
CatmullRomCurve(this.controlPoints, {this.tension = 0.0})
: assert(() {
return validateControlPoints(
controlPoints,
tension: tension,
reasons: _debugAssertReasons..clear(),
);
}(), 'control points $controlPoints could not be validated:\n ${_debugAssertReasons.join('\n ')}'),
// Pre-compute samples so that we don't have to evaluate the spline's inverse
// all the time in transformInternal.
_precomputedSamples = <Curve2DSample>[];