CubicLine class
Represents a cubic Bezier curve segment, defined by a start point, end point, and two control points. This class extends Offset to represent the starting point of the curve.
For more information on Bezier curves, refer to: https://cubic-bezier.com/
- Inheritance
-
- Object
- OffsetBase
- Offset
- CubicLine
Constructors
- CubicLine.new({required OffsetPoint start, required Offset cpStart, required Offset cpEnd, required OffsetPoint end, Offset? upStartVector, Offset? upEndVector, double startSize = 0.0, double endSize = 0.0})
- Creates a CubicLine segment.
Properties
- cpEnd → Offset
-
The second control point, influencing the curve's shape from the end point.
final
- cpStart → Offset
-
The first control point, influencing the curve's shape from the start point.
final
- direction → double
-
The angle of this offset as radians clockwise from the positive x-axis, in
the range -pi to pi, assuming positive values of the x-axis go to the
right and positive values of the y-axis go down.
no setterinherited
- distance → double
-
The magnitude of the offset.
no setterinherited
- distanceSquared → double
-
The square of the magnitude of the offset.
no setterinherited
- dx → double
-
The x component of the offset.
no setterinherited
- dy → double
-
The y component of the offset.
no setterinherited
- end → OffsetPoint
-
The ending point of the cubic Bezier curve.
final
- endSize ↔ double
-
The size ratio of the line at its ending point (typically 0.0 to 1.0).
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setteroverride
- isDot → bool
-
Indicates if this line segment represents a 'dot' (i.e., start and end points are the same, and velocity is zero).
no setter
- isFinite → bool
-
Whether both components are finite (neither infinite nor NaN).
no setterinherited
- isInfinite → bool
-
Returns true if either component is double.infinity, and false if both
are finite (or negative infinity, or NaN).
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- start → OffsetPoint
-
The starting point of the cubic Bezier curve.
final
- startSize ↔ double
-
The size ratio of the line at its starting point (typically 0.0 to 1.0).
getter/setter pair
- upEndVector → Offset
-
The 'Up' vector for the end point, calculated if not already cached.
This vector is perpendicular to the curve's direction at the end.
no setter
- upStartVector → Offset
-
The 'Up' vector for the start point, calculated if not already cached.
This vector is perpendicular to the curve's direction at the start.
no setter
Methods
-
combineVelocity(
double inVelocity, {double velocityRatio = 0.65, double maxFallOff = 1.0}) → double -
Combines the line's intrinsic velocity with an
inVelocity
based on avelocityRatio
. -
cpeDown(
double size, double maxSize) → Offset - Returns the 'Down' offset for the end point, scaled by the end radius.
-
cpeUp(
double size, double maxSize) → Offset - Returns the 'Up' offset for the end point, scaled by the end radius.
-
cpsDown(
double size, double maxSize) → Offset - Returns the 'Down' offset for the start point, scaled by the start radius.
-
cpsUp(
double size, double maxSize) → Offset - Returns the 'Up' offset for the start point, scaled by the start radius.
-
endRadius(
double size, double maxSize) → double -
Returns the calculated radius for the end point based on
size
,maxSize
, and endSize. -
length(
{double accuracy = 0.1}) → double -
Calculates the approximate length of the cubic curve with a given
accuracy
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
point(
double t) → Offset -
Calculates a point on the cubic curve at a given parameter
t
. -
scale(
double scaleX, double scaleY) → CubicLine -
Returns a new offset with the x component scaled by
scaleX
and the y component scaled byscaleY
.override -
startRadius(
double size, double maxSize) → double -
Returns the calculated radius for the start point based on
size
,maxSize
, and startSize. -
toArc(
{double? deltaSize, double precision = 0.5}) → List< CubicArc> - Converts this cubic line into a list of CubicArc segments. This is used to approximate the curve with a series of arcs for drawing.
-
toPath(
) → Path - Converts this cubic line segment into a Flutter Path object.
-
toShape(
double size, double maxSize) → Path - Converts this cubic line into a closed Path representing a filled shape. This is typically used for drawing thick, filled lines.
-
toString(
) → String -
A string representation of this object.
inherited
-
translate(
double translateX, double translateY) → CubicLine -
Returns a new offset with translateX added to the x component and
translateY added to the y component.
override
-
velocity(
{double accuracy = 0.0}) → double - Calculates the velocity along this line segment.
Operators
-
operator %(
double operand) → Offset -
Modulo (remainder) operator.
inherited
-
operator &(
Size other) → Rect -
Rectangle constructor operator.
inherited
-
operator *(
double operand) → Offset -
Multiplication operator.
inherited
-
operator +(
Offset other) → Offset -
Binary addition operator.
inherited
-
operator -(
Offset other) → Offset -
Binary subtraction operator.
inherited
-
operator /(
double operand) → Offset -
Division operator.
inherited
-
operator <(
OffsetBase other) → bool -
Less-than operator. Compares an Offset or Size to another Offset or
Size, and returns true if both the horizontal and vertical values of the
left-hand-side operand are smaller than the horizontal and vertical values
of the right-hand-side operand respectively. Returns false otherwise.
inherited
-
operator <=(
OffsetBase other) → bool -
Less-than-or-equal-to operator. Compares an Offset or Size to another
Offset or Size, and returns true if both the horizontal and vertical
values of the left-hand-side operand are smaller than or equal to the
horizontal and vertical values of the right-hand-side operand
respectively. Returns false otherwise.
inherited
-
operator ==(
Object other) → bool -
Compares two Offsets for equality.
override
-
operator >(
OffsetBase other) → bool -
Greater-than operator. Compares an Offset or Size to another Offset
or Size, and returns true if both the horizontal and vertical values of
the left-hand-side operand are bigger than the horizontal and vertical
values of the right-hand-side operand respectively. Returns false
otherwise.
inherited
-
operator >=(
OffsetBase other) → bool -
Greater-than-or-equal-to operator. Compares an Offset or Size to
another Offset or Size, and returns true if both the horizontal and
vertical values of the left-hand-side operand are bigger than or equal to
the horizontal and vertical values of the right-hand-side operand
respectively. Returns false otherwise.
inherited
-
operator unary-(
) → Offset -
Unary negation operator.
inherited
-
operator ~/(
double operand) → Offset -
Integer (truncating) division operator.
inherited
Static Methods
-
softCP(
OffsetPoint current, {OffsetPoint? previous, OffsetPoint? next, bool reverse = false, double smoothing = 0.65}) → Offset -
Calculates a 'soft' control point for a
current
point based on itsprevious
andnext
neighbors. This is used to create smooth curves.