Rectangle class
An axis-aligned rectangle defined by position and size.
The rectangle is defined by x, y (bottom-left corner), width, and height.
- Implemented types
Constructors
- Rectangle({required double x, required double y, required double width, required double height})
-
const
- Rectangle.fromCenter({required Point center, required double width, required double height})
-
Create a rectangle from center point, width, and height
factory
- Rectangle.fromPoints(Point a, Point b)
-
Create a rectangle from two opposite corner points
factory
- Rectangle.square({required double x, required double y, required double size})
-
Create a square from bottom-left corner and side length
factory
Properties
- area → double
-
Area of this shape.
no setteroverride
- bottomLeft → Point
-
Bottom-left corner
no setter
- bottomRight → Point
-
Bottom-right corner
no setter
- center → Point
-
The center point of the rectangle
no setter
- diagonal → double
-
Length of the diagonal
no setter
-
edges
→ List<
Line> -
The four edges of the rectangle
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- height → double
-
Height of the rectangle
final
- isSquare → bool
-
Whether this rectangle is a square
no setter
- perimeter → double
-
Perimeter (circumference) of this shape.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- topLeft → Point
-
Top-left corner
no setter
- topRight → Point
-
Top-right corner
no setter
-
vertices
→ List<
Point> -
The four corner points
no setter
- width → double
-
Width of the rectangle
final
- x → double
-
X coordinate of the bottom-left corner
final
- y → double
-
Y coordinate of the bottom-left corner
final
Methods
-
contains(
Point point) → bool - Check if a point is inside this rectangle
-
intersectsCircle(
Circle circle) → bool - Check if a circle intersects this rectangle
-
intersectsLine(
Line line) → bool - Check if a line segment intersects this rectangle
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
overlaps(
Rectangle other) → bool - Check if this rectangle overlaps with another rectangle
-
rotate(
double deg) → Rectangle -
Rotate the shape by
degdegreesoverride -
scale(
double value) → Rectangle -
scale the shape by
valueoverride -
toPolygon(
) → Polygon - Convert this rectangle to a Polygon
-
toString(
) → String -
A string representation of this object.
override
-
translate(
{double x = 0, double y = 0}) → Rectangle -
translate the shape with
xin horizontally andyverticallyoverride
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override