class Geometry · Computations
Rectangles
Creates rectangles (along a segment, anchored at or centered on a pin) and computes their corners, sides, size and diagonal.
Static methods
alongPaddedSegmentstatic
static alongPaddedSegment(p1: Point | VectorLike, p2: Point | VectorLike, height: Real | NumberLike, leftSide: Bool | BoolLike, distance: Real | NumberLike, paddingStart: Real | NumberLike, paddingEnd: Real | NumberLike, result?: Rectangle | null): RectangleCreates a rectangle along a segment defined by two points, with a specified height, side, distance, and optional start and end paddings.
If the sum of paddingStart and paddingEnd exceeds the length of the segment, the
rectangle is positioned according to the weighted ratio having width 0.
p1- The first point defining the segment.
p2- The second point defining the segment.
height- The height of the rectangle extending from the segment.
leftSide- Determines the direction the rectangle extends from the segment.
distance- The offset distance from the segment start at which the rectangle is positioned, after applying paddings.
paddingStart- The padding applied at the start of the segment.
paddingEnd- The padding applied at the end of the segment.
resultoptional- Optional rectangle to store the result; if null, a new rectangle is created.
Returns A rectangle constructed along the segment with the specified parameters.
alongSegmentstatic
static alongSegment(bottomLeft: Point | VectorLike, bottomRight: Point | VectorLike, height: Real | NumberLike, left: Bool | BoolLike, result?: Rectangle | null): RectangleCreates a rectangle from a baseline defined by two points and a specified height.
bottomLeft- The bottom-left point of the baseline.
bottomRight- The bottom-right point of the baseline.
height- The height of the rectangle extending from the baseline.
left- Determines the direction the rectangle extends from the baseline.
resultoptional- Optional rectangle to store the result; if null, a new rectangle is created.
Returns A rectangle constructed from the baseline and height.
anchoredRectanglestatic
static anchoredRectangle(anchor: Pin | PinLike, xRatio: Real | NumberLike, yRatio: Real | NumberLike, width: Real | NumberLike, height: Real | NumberLike, result?: Rectangle | null): RectangleCreates a rectangle anchored at a specific point using x and y ratios to position the anchor within the rectangle bounds.
anchor- The pin point where the rectangle is anchored.
xRatio- The ratio (0 to 1) defining the anchor position along the rectangle's width.
yRatio- The ratio (0 to 1) defining the anchor position along the rectangle's height.
width- The width of the rectangle.
height- The height of the rectangle.
resultoptional- Optional rectangle to store the result; if null, a new rectangle is created.
Returns A rectangle anchored at the specified point with the given dimensions and ratios.
areastatic
bottomLeftstatic
static bottomLeft(rectangle: Rectangle | ShapeLike, result?: Point | null): PointGets the bottom-left corner point of a rectangle.
rectangle- The rectangle whose bottom-left corner is to be retrieved.
resultoptional- Optional point object to store the result; if null, a new point is created.
Returns The bottom-left corner point of the rectangle.
bottomRightstatic
static bottomRight(rectangle: Rectangle | ShapeLike, result?: Point | null): PointGets the bottom-right corner point of a rectangle.
rectangle- The rectangle whose bottom-right corner is to be retrieved.
resultoptional- Optional point object to store the result; if null, a new point is created.
Returns The bottom-right corner point of the rectangle.
bottomSidestatic
static bottomSide(rectangle: Rectangle | ShapeLike, result?: Segment | null): SegmentGets the bottom side of a rectangle as a line segment going from left to right.
rectangle- The rectangle whose bottom side is to be retrieved.
resultoptional- Optional line segment object to store the result; if null, a new line segment is created.
Returns A line segment representing the bottom side of the rectangle, oriented from left to right.
boundingBoxstatic
static boundingBox(rectangle: Rectangle | ShapeLike, result?: Box | null): BoxComputes the axis-aligned bounding box of the specified rectangle.
rectangle- The rectangle whose bounding box is computed.
resultoptional- Optional box to store the result; if null, a new box is created.
Returns A box representing the bounds of the rectangle.
centeredRectanglestatic
static centeredRectangle(center: Pin | PinLike, width: Real | NumberLike, height: Real | NumberLike, result?: Rectangle | null): RectangleCreates a rectangle centered at a specific point.
center- The pin point at the center of the rectangle.
width- The width of the rectangle.
height- The height of the rectangle.
resultoptional- Optional rectangle to store the result; if null, a new rectangle is created.
Returns A rectangle centered at the specified point.
copystatic
diagonalstatic
static diagonal(rectangle: Rectangle | ShapeLike, result?: Real | null): RealCalculates the diagonal length of a rectangle.
rectangle- The rectangle whose diagonal is to be calculated.
resultoptional- Optional length object to store the result; if null, a new length is created.
Returns The diagonal length of the rectangle.
heightstatic
leftSidestatic
static leftSide(rectangle: Rectangle | ShapeLike, result?: Segment | null): SegmentGets the left side of a rectangle as a line segment going from bottom to top.
rectangle- The rectangle whose left side is to be retrieved.
resultoptional- Optional line segment object to store the result; if null, a new line segment is created.
Returns A line segment representing the left side of the rectangle, oriented from bottom to top.
rightSidestatic
static rightSide(rectangle: Rectangle | ShapeLike, result?: Segment | null): SegmentGets the right side of a rectangle as a line segment going from bottom to top.
rectangle- The rectangle whose right side is to be retrieved.
resultoptional- Optional line segment object to store the result; if null, a new line segment is created.
Returns A line segment representing the right side of the rectangle, oriented from bottom to top.
topLeftstatic
static topLeft(rectangle: Rectangle | ShapeLike, result?: Point | null): PointGets the top-left corner point of a rectangle.
rectangle- The rectangle whose top-left corner is to be retrieved.
resultoptional- Optional point object to store the result; if null, a new point is created.
Returns The top-left corner point of the rectangle.
topRightstatic
static topRight(rectangle: Rectangle | ShapeLike, result?: Point | null): PointGets the top-right corner point of a rectangle.
rectangle- The rectangle whose top-right corner is to be retrieved.
resultoptional- Optional point object to store the result; if null, a new point is created.
Returns The top-right corner point of the rectangle.
topSidestatic
static topSide(rectangle: Rectangle | ShapeLike, result?: Segment | null): SegmentGets the top side of a rectangle as a line segment going from left to right.
rectangle- The rectangle whose top side is to be retrieved.
resultoptional- Optional line segment object to store the result; if null, a new line segment is created.
Returns A line segment representing the top side of the rectangle, oriented from left to right.
