Capsule class
A capsule (stadium) shape — a rectangle with semicircle caps on each end.
Defined by a center Line (the medial axis) and a radius. The total length is the line length plus the diameter (two semicircle caps).
- Implemented types
Constructors
- Capsule({required Line medialAxis, required double radius})
-
const
- Capsule.circle({required Point center, required double radius})
-
Create a capsule that is a perfect circle (medial axis has zero length)
factory
- Capsule.fromRect({required Point center, required double width, required double height})
-
Create a capsule from center point, total width, total height.
factory
Properties
- area → double
-
Area of this shape.
no setteroverride
- axisLength → double
-
Length of the medial axis
no setter
- boundingBox → Rectangle
-
Get the bounding rectangle of this capsule
no setter
- center → Point
-
Center point of the capsule
no setter
-
endCaps
→ List<
Circle> -
The two semicircle center points (endpoints of the medial axis)
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- medialAxis → Line
-
The medial axis of the capsule
final
- perimeter → double
-
Perimeter (circumference) of this shape.
no setteroverride
- radius → double
-
The radius of the semicircle caps (and half-width of the rectangular body)
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- totalLength → double
-
Total length of the capsule (axis + diameter)
no setter
- totalWidth → double
-
Total width perpendicular to the medial axis
no setter
Methods
-
contains(
Point p) → bool - Check if a point is inside this capsule.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rotate(
double deg) → Capsule -
Rotate the shape by
degdegreesoverride -
scale(
double value) → Capsule -
scale the shape by
valueoverride -
toString(
) → String -
A string representation of this object.
override
-
translate(
{double x = 0, double y = 0}) → Capsule -
translate the shape with
xin horizontally andyverticallyoverride
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override