Shape class abstract

Base class for various 2D geometric primitives defined on a Cartesian coordinate plane.

Implementations include:

Implementers

Constructors

Shape()

Properties

aabb → Aabb2
The axis-aligned bounding box of the shape.
no setter
center → Vector2
The central point of the shape.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isClosed → bool
True if the shape is "closed", in the sense that it has an interior. For example, a closed shape can be filled with a paint.
no setter
isConvex → bool
True if the shape is convex, i.e. a line segment connecting any two points of the shape would lie completely within the shape.
no setter
perimeter → double
The length of the shape's boundary. For some more complicated shapes this can be computed approximately.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

asPath() → Path
Converts the shape to a Path object, suitable for rendering on a canvas. If a particular geometric primitive cannot be represented as a Path faithfully, an approximate path can be returned.
containsPoint(Vector2 point) → bool
Returns true if the given point is inside the shape or on the boundary.
move(Vector2 offset) → void
Translates the shape by the specified offset vector, in-place.
nearestPoint(Vector2 point) → Vector2
Returns a point on the shape's boundary which is closest to the given point.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
project(Transform2D transform, [Shape? target]) → Shape
Returns the result of applying an affine transformation to the shape.
randomPoint({Random? random, bool within = true}) → Vector2
Returns a random point within the shape if within is true (default) and otherwise a point along the edges of the shape. Do note that within=true also includes the edges.
support(Vector2 direction) → Vector2
Finds the intersection of this shape with another one, if it exists. Returns a point on the boundary that is furthest in the given direction.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited