Struct Rect
- Namespace
- Egami
- Assembly
- Egami.dll
A rectangle of pixels: the top-left corner and a size.
public readonly record struct Rect : IEquatable<Rect>
- Implements
- Inherited Members
Examples
// Draw part of an image, such as one tile of a sprite sheet: no copy is made.
Rect tile = new(0, 0, 32, 32);
photo.Apply(ops => ops.DrawImage(logo, tile, new Point(10, 10)), Ct);
Constructors
Rect(Point, Size)
Initializes a new instance of the Rect struct from a corner and a size.
public Rect(Point position, Size size)
Parameters
Rect(int, int, int, int)
A rectangle of pixels: the top-left corner and a size.
public Rect(int X, int Y, int Width, int Height)
Parameters
XintThe left column.
YintThe top row.
WidthintThe width, at least 0.
HeightintThe height, at least 0.
Examples
// Draw part of an image, such as one tile of a sprite sheet: no copy is made.
Rect tile = new(0, 0, 32, 32);
photo.Apply(ops => ops.DrawImage(logo, tile, new Point(10, 10)), Ct);
Properties
Bottom
Gets the row just past the bottom edge.
public int Bottom { get; }
Property Value
Height
The height, at least 0.
public int Height { get; init; }
Property Value
IsEmpty
Gets a value indicating whether the rectangle covers no pixels.
public bool IsEmpty { get; }
Property Value
Position
Gets the top-left corner.
public Point Position { get; }
Property Value
Right
Gets the column just past the right edge.
public int Right { get; }
Property Value
Size
Gets the size.
public Size Size { get; }
Property Value
Width
The width, at least 0.
public int Width { get; init; }
Property Value
X
The left column.
public int X { get; init; }
Property Value
Y
The top row.
public int Y { get; init; }
Property Value
Methods
Contains(Point)
Returns whether the pixel at point lies inside the rectangle.
public bool Contains(Point point)
Parameters
pointPointThe pixel.
Returns
Contains(Rect)
Returns whether other lies entirely inside this rectangle.
public bool Contains(Rect other)
Parameters
otherRectThe other rectangle.
Returns
Intersect(Rect)
Returns the overlap of two rectangles, which is empty when they do not overlap.
public Rect Intersect(Rect other)
Parameters
otherRectThe other rectangle.
Returns
- Rect
The overlap.