Table of Contents

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

position Point

The top-left corner.

size Size

The size.

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

X int

The left column.

Y int

The top row.

Width int

The width, at least 0.

Height int

The 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

int

Height

The height, at least 0.

public int Height { get; init; }

Property Value

int

IsEmpty

Gets a value indicating whether the rectangle covers no pixels.

public bool IsEmpty { get; }

Property Value

bool

Position

Gets the top-left corner.

public Point Position { get; }

Property Value

Point

Right

Gets the column just past the right edge.

public int Right { get; }

Property Value

int

Size

Gets the size.

public Size Size { get; }

Property Value

Size

Width

The width, at least 0.

public int Width { get; init; }

Property Value

int

X

The left column.

public int X { get; init; }

Property Value

int

Y

The top row.

public int Y { get; init; }

Property Value

int

Methods

Contains(Point)

Returns whether the pixel at point lies inside the rectangle.

public bool Contains(Point point)

Parameters

point Point

The pixel.

Returns

bool

true if the rectangle contains it.

Contains(Rect)

Returns whether other lies entirely inside this rectangle.

public bool Contains(Rect other)

Parameters

other Rect

The other rectangle.

Returns

bool

true if this rectangle contains all of it.

Intersect(Rect)

Returns the overlap of two rectangles, which is empty when they do not overlap.

public Rect Intersect(Rect other)

Parameters

other Rect

The other rectangle.

Returns

Rect

The overlap.