Table of Contents

Struct CanvasRect

Namespace
FlowGraph.Core.Coordinates
Assembly
FlowGraph.Core.dll

A rectangle in canvas coordinate space.

Canvas rectangles represent bounded regions in the graph coordinate space. Node bounds, selection areas, and visible regions are expressed as canvas rects.

public readonly record struct CanvasRect : IEquatable<CanvasRect>
Implements
Inherited Members
Extension Methods

Constructors

CanvasRect(double, double, double, double)

A rectangle in canvas coordinate space.

Canvas rectangles represent bounded regions in the graph coordinate space. Node bounds, selection areas, and visible regions are expressed as canvas rects.

public CanvasRect(double X, double Y, double Width, double Height)

Parameters

X double
Y double
Width double
Height double

Properties

Bottom

The bottom edge Y coordinate.

public double Bottom { get; }

Property Value

double

BottomLeft

The bottom-left corner of the rectangle.

public CanvasPoint BottomLeft { get; }

Property Value

CanvasPoint

BottomRight

The bottom-right corner of the rectangle.

public CanvasPoint BottomRight { get; }

Property Value

CanvasPoint

Center

The center of the rectangle.

public CanvasPoint Center { get; }

Property Value

CanvasPoint

Empty

An empty rectangle at the origin.

public static CanvasRect Empty { get; }

Property Value

CanvasRect

Height

public double Height { get; init; }

Property Value

double

IsEmpty

Whether this rectangle is empty (has zero or negative area).

public bool IsEmpty { get; }

Property Value

bool

Right

The right edge X coordinate.

public double Right { get; }

Property Value

double

Size

The size of the rectangle as a vector.

public CanvasVector Size { get; }

Property Value

CanvasVector

TopLeft

The top-left corner of the rectangle.

public CanvasPoint TopLeft { get; }

Property Value

CanvasPoint

TopRight

The top-right corner of the rectangle.

public CanvasPoint TopRight { get; }

Property Value

CanvasPoint

Width

public double Width { get; init; }

Property Value

double

X

public double X { get; init; }

Property Value

double

Y

public double Y { get; init; }

Property Value

double

Methods

Contains(CanvasPoint)

Checks if this rectangle contains a point.

public bool Contains(CanvasPoint point)

Parameters

point CanvasPoint

Returns

bool

Contains(CanvasRect)

Checks if this rectangle fully contains another rectangle.

public bool Contains(CanvasRect other)

Parameters

other CanvasRect

Returns

bool

FromCenter(CanvasPoint, double, double)

Creates a rectangle from a center point and size.

public static CanvasRect FromCenter(CanvasPoint center, double width, double height)

Parameters

center CanvasPoint
width double
height double

Returns

CanvasRect

FromCore(Rect)

Creates a rectangle from a core Rect.

public static CanvasRect FromCore(Rect rect)

Parameters

rect Rect

Returns

CanvasRect

FromPoints(CanvasPoint, CanvasPoint)

Creates a rectangle from two corner points.

public static CanvasRect FromPoints(CanvasPoint a, CanvasPoint b)

Parameters

a CanvasPoint
b CanvasPoint

Returns

CanvasRect

Inflate(double)

Returns a rectangle inflated by the specified amount on all sides.

public CanvasRect Inflate(double amount)

Parameters

amount double

Returns

CanvasRect

Inflate(double, double)

Returns a rectangle inflated by different horizontal and vertical amounts.

public CanvasRect Inflate(double horizontal, double vertical)

Parameters

horizontal double
vertical double

Returns

CanvasRect

Intersect(CanvasRect)

Returns the intersection of this rectangle with another. Returns Empty if they don't intersect.

public CanvasRect Intersect(CanvasRect other)

Parameters

other CanvasRect

Returns

CanvasRect

Intersects(CanvasRect)

Checks if this rectangle intersects with another rectangle.

public bool Intersects(CanvasRect other)

Parameters

other CanvasRect

Returns

bool

Offset(CanvasVector)

Returns a rectangle offset by a vector.

public CanvasRect Offset(CanvasVector vector)

Parameters

vector CanvasVector

Returns

CanvasRect

ToCore()

Converts to a core Rect.

public Rect ToCore()

Returns

Rect

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Union(CanvasRect)

Returns the smallest rectangle that contains both this and another rectangle.

public CanvasRect Union(CanvasRect other)

Parameters

other CanvasRect

Returns

CanvasRect