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
Properties
Bottom
The bottom edge Y coordinate.
public double Bottom { get; }
Property Value
BottomLeft
The bottom-left corner of the rectangle.
public CanvasPoint BottomLeft { get; }
Property Value
BottomRight
The bottom-right corner of the rectangle.
public CanvasPoint BottomRight { get; }
Property Value
Center
The center of the rectangle.
public CanvasPoint Center { get; }
Property Value
Empty
An empty rectangle at the origin.
public static CanvasRect Empty { get; }
Property Value
Height
public double Height { get; init; }
Property Value
IsEmpty
Whether this rectangle is empty (has zero or negative area).
public bool IsEmpty { get; }
Property Value
Right
The right edge X coordinate.
public double Right { get; }
Property Value
Size
The size of the rectangle as a vector.
public CanvasVector Size { get; }
Property Value
TopLeft
The top-left corner of the rectangle.
public CanvasPoint TopLeft { get; }
Property Value
TopRight
The top-right corner of the rectangle.
public CanvasPoint TopRight { get; }
Property Value
Width
public double Width { get; init; }
Property Value
X
public double X { get; init; }
Property Value
Y
public double Y { get; init; }
Property Value
Methods
Contains(CanvasPoint)
Checks if this rectangle contains a point.
public bool Contains(CanvasPoint point)
Parameters
pointCanvasPoint
Returns
Contains(CanvasRect)
Checks if this rectangle fully contains another rectangle.
public bool Contains(CanvasRect other)
Parameters
otherCanvasRect
Returns
FromCenter(CanvasPoint, double, double)
Creates a rectangle from a center point and size.
public static CanvasRect FromCenter(CanvasPoint center, double width, double height)
Parameters
centerCanvasPointwidthdoubleheightdouble
Returns
FromCore(Rect)
Creates a rectangle from a core Rect.
public static CanvasRect FromCore(Rect rect)
Parameters
rectRect
Returns
FromPoints(CanvasPoint, CanvasPoint)
Creates a rectangle from two corner points.
public static CanvasRect FromPoints(CanvasPoint a, CanvasPoint b)
Parameters
Returns
Inflate(double)
Returns a rectangle inflated by the specified amount on all sides.
public CanvasRect Inflate(double amount)
Parameters
amountdouble
Returns
Inflate(double, double)
Returns a rectangle inflated by different horizontal and vertical amounts.
public CanvasRect Inflate(double horizontal, double vertical)
Parameters
Returns
Intersect(CanvasRect)
Returns the intersection of this rectangle with another. Returns Empty if they don't intersect.
public CanvasRect Intersect(CanvasRect other)
Parameters
otherCanvasRect
Returns
Intersects(CanvasRect)
Checks if this rectangle intersects with another rectangle.
public bool Intersects(CanvasRect other)
Parameters
otherCanvasRect
Returns
Offset(CanvasVector)
Returns a rectangle offset by a vector.
public CanvasRect Offset(CanvasVector vector)
Parameters
vectorCanvasVector
Returns
ToCore()
Converts to a core Rect.
public Rect ToCore()
Returns
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
otherCanvasRect