Import std.math.geometry
Rect
struct
Public Struct Rect Implements Equatable, Printable
A rectangle in 2D, from its corner with the smallest X and Y, of a Width and Height that aren't negative.
Examples
Local a = Rect(0, 0, 10, 10)
Local b = Rect(5, 5, 10, 10)
Expect(a.Intersects(b))
Expect(a.Intersection(b) == Rect(5, 5, 5, 5))
Expect(a.Union(b) == Rect(0, 0, 15, 15))
Expect(a.Contains(Vec2(2, 3)) && !a.Contains(Vec2(12, 3)))-
Its left edge, the smallest X it has.
-
Its top edge, the smallest Y it has.
-
How wide it is, which isn't negative.
-
How high it is, which isn't negative.
-
The rectangle from one corner to the other, whichever way around they are.
-
The rectangle of the
size, with its center at the point. -
The corner with the smallest X and Y.
-
The corner with the largest X and Y.
-
The point in its middle.
-
Its Width and Height, as a Vec2.
-
Its Width times its Height.
-
Whether the
pointis in the rectangle or on its edge. -
Whether the
otherrectangle is all in this one. -
Whether the two have a point in common, an edge's included.
-
The rectangle where the two overlap, or Null where they don't meet.
-
The smallest rectangle that holds both.
-
The rectangle with each edge moved out by
amount, or in by a negative one. Shrunk past nothing, a side is 0 long, at the center. -
Its parts, as "Rect(0, 0, 10, 5)".
Report an issue with this page or with FutureBlitz on GitHub.