Skip to content

PixelRect

Namespace: Hex1b.Surfaces

Assembly: Hex1b.dll

Represents a rectangle in pixel coordinates.

csharp
public readonly record struct PixelRect : IEquatable<PixelRect>

Implements

Constructors

PixelRect(int, int, int, int)

Represents a rectangle in pixel coordinates.

Parameters:

  • X (Int32): Left edge (inclusive).
  • Y (Int32): Top edge (inclusive).
  • Width (Int32): Width in pixels.
  • Height (Int32): Height in pixels.
csharp
public PixelRect(int X, int Y, int Width, int Height)

Properties

Area

Gets the area of this rectangle.

Returns: Int32

csharp
public int Area { get; }

Bottom

Gets the bottom edge (exclusive).

Returns: Int32

csharp
public int Bottom { get; }

Height

Height in pixels.

Returns: Int32

csharp
public int Height { get; init; }

IsEmpty

Gets whether this rectangle has zero area.

Returns: Boolean

csharp
public bool IsEmpty { get; }

Gets the right edge (exclusive).

Returns: Int32

csharp
public int Right { get; }

Width

Width in pixels.

Returns: Int32

csharp
public int Width { get; init; }

X

Left edge (inclusive).

Returns: Int32

csharp
public int X { get; init; }

Y

Top edge (inclusive).

Returns: Int32

csharp
public int Y { get; init; }

Methods

Contains(int, int)

Returns whether this rectangle contains the specified point.

Parameters:

Returns: Boolean

csharp
public bool Contains(int x, int y)

Contains(PixelRect)

Returns whether this rectangle fully contains another.

Parameters:

Returns: Boolean

csharp
public bool Contains(PixelRect other)

Intersect(PixelRect)

Returns the intersection of this rectangle with another.

Parameters:

Returns: PixelRect

csharp
public PixelRect Intersect(PixelRect other)

Overlaps(PixelRect)

Returns whether this rectangle overlaps another.

Parameters:

Returns: Boolean

csharp
public bool Overlaps(PixelRect other)

Subtract(PixelRect)

Subtracts a rectangle from this one, returning up to 4 remaining fragments.

Parameters:

Returns: IReadOnlyList<PixelRect>

List of non-empty fragments remaining after subtraction.

csharp
public IReadOnlyList<PixelRect> Subtract(PixelRect hole)

Released under the MIT License.