Bezier class
@fileoverview Represents a cubic Bezier curve.
Uses the deCasteljau algorithm to compute points on the curve. http://en.wikipedia.org/wiki/De_Casteljau's_algorithm
Currently it uses an unrolled version of the algorithm for speed. Eventually it may be useful to use the loop form of the algorithm in order to support curves of arbitrary degree.
@author robbyw@google.com (Robby Walker)
- Implemented types
Constructors
- Bezier(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
- Object representing a cubic bezier curve. @param {number} x0 X coordinate of the start point. @param {number} y0 Y coordinate of the start point. @param {number} x1 X coordinate of the first control point. @param {number} y1 Y coordinate of the first control point. @param {number} x2 X coordinate of the second control point. @param {number} y2 Y coordinate of the second control point. @param {number} x3 X coordinate of the end point. @param {number} y3 Y coordinate of the end point. @struct @constructor @final
- Bezier.fromCoordinates(Coordinate startPoint, Coordinate control1, Coordinate control2, Coordinate endPoint)
-
factory
Properties
- controlPoint1 → Coordinate
-
no setter
- controlPoint2 → Coordinate
-
no setter
- endPoint → Coordinate
-
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startPoint → Coordinate
-
no setter
- x0 ↔ double
-
getter/setter pair
- x1 ↔ double
-
getter/setter pair
- x2 ↔ double
-
getter/setter pair
- x3 ↔ double
-
getter/setter pair
- y0 ↔ double
-
getter/setter pair
- y1 ↔ double
-
getter/setter pair
- y2 ↔ double
-
getter/setter pair
- y3 ↔ double
-
getter/setter pair
Methods
-
copy(
) → Bezier - @return {!goog.math.Bezier} A copy of this curve.
-
flip(
) → void - Modifies the curve in place to progress in the opposite direction.
-
getPoint(
double t) → Coordinate - Computes the curve at a point between 0 and 1. @param {number} t The point on the curve to find. @return {!goog.math.Coordinate} The computed coordinate.
-
getPointX(
double t) → double - Computes the curve's X coordinate at a point between 0 and 1. @param {number} t The point on the curve to find. @return {number} The computed coordinate.
-
getPointY(
double t) → double - Computes the curve's Y coordinate at a point between 0 and 1. @param {number} t The point on the curve to find. @return {number} The computed coordinate.
-
length(
) → double -
marshal(
MarshalledObject marshalled) → void -
Marshal method must operate by mutating empty object passed.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
solvePositionFromXValue(
double xVal) → double -
Computes the position t of a point on the curve given its x coordinate.
That is, for an input xVal, finds t s.t. getPointX(t) = xVal.
As such, the following should always be true up to some small epsilon:
t ~ solvePositionFromXValue(getPointX(t)) for t in
0, 1
. @param {number} xVal The x coordinate of the point to find on the curve. @return {number} The position t. -
solveYValueFromXValue(
double xVal) → double - Computes the y coordinate of a point on the curve given its x coordinate. @param {number} xVal The x coordinate of the point on the curve. @return {number} The y coordinate of the point on the curve.
-
subdivide(
double s, double t) → void -
Changes this curve in place to be the portion of itself from
s, t
. @param {number} s The start of the desired portion of the curve. @param {number} t The end of the desired portion of the curve. -
subdivideLeft(
double t) → void -
Changes this curve in place to be the portion of itself from
t, 1
. @param {number} t The start of the desired portion of the curve. -
subdivideRight(
double t) → void -
Changes this curve in place to be the portion of itself from
0, t
. @param {number} t The end of the desired portion of the curve. -
toCssAnimationTimingFunction(
) → String - Returns CSS string representation of bezier.
-
toString(
) → String -
return string representation
override
Operators
-
operator ==(
Object other) → bool -
Test if the given curve is exactly the same as this one.
@param {goog.math.Bezier} other The other curve.
@return {boolean} Whether the given curve is the same as this one.
override
Static Properties
- KAPPA → double
-
Constant used to approximate ellipses.
See: http://canvaspaint.org/blog/2006/12/ellipse/
@type {number}
final
- LINEAR → Bezier
-
Linear curve
final
Static Methods
-
unmarshal(
MarshalledObject marshalled) → Bezier