public readonly struct RectangleAn axis-aligned rectangle in 2D: layout boxes, scissor regions, texture atlas entries, clipping bounds.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Stored as position plus size rather than two corners, because that is how layout and UI code thinks and it is the form that keeps Width exact under translation. The origin is the top-left and Y increases downward, matching the UV convention.
Fields and properties (13)
public readonly float XThe left edge.
public readonly float YThe top edge.
public readonly float WidthThe width. Negative widths are not meaningful and are not checked for.
public readonly float HeightThe height.
public static Rectangle EmptyThe rectangle at the origin with no size.
public float LeftThe left edge.
public float TopThe top edge.
public float RightThe right edge.
public float BottomThe bottom edge.
public Vector2 PositionThe top-left corner.
public Vector2 SizeThe width and height.
public Vector2 CenterThe midpoint.
public bool IsEmptyWhether the rectangle encloses nothing.
Methods (19)
public Rectangle(float x, float y, float width, float height)Builds a rectangle from its position and size.
public Rectangle(Vector2 position, Vector2 size)Builds a rectangle from its position and size.
public static Rectangle FromCorners(Vector2 first, Vector2 second)The rectangle spanning two corners, in either order.
public bool Contains(Vector2 point)Whether a point is inside or on the top-left edges.
public bool Contains(Rectangle other)Whether another rectangle is entirely inside this one.
public bool Intersects(Rectangle other)Whether two rectangles overlap.
public static Rectangle Intersect(Rectangle left, Rectangle right)The overlap of two rectangles.
public static Rectangle Union(Rectangle left, Rectangle right)The smallest rectangle containing both.
public static Rectangle Inflate(Rectangle rectangle, float horizontal, float vertical)Grows the rectangle on every side.
public static Rectangle Offset(Rectangle rectangle, Vector2 offset)Moves the rectangle.
public static bool NearEqual(Rectangle left, Rectangle right, float tolerance = 1E-06)Whether two rectangles agree to within a tolerance.
public static bool operator ==(Rectangle left, Rectangle right)Exact equality, IEEE semantics. See NearEqual.
public static bool operator !=(Rectangle left, Rectangle right)The negation of op_Equality.
public void Deconstruct(out float x, out float y, out float width, out float height)Splits the rectangle into its components.
public bool Equals(Rectangle other)Indicates whether the current object is equal to another object of the same type.
public override bool Equals(object? obj)Indicates whether this instance and a specified object are equal.
public override int GetHashCode()Returns the hash code for this instance.
public override string ToString()Returns the fully qualified type name of this instance.
public string ToString(string? format, IFormatProvider? formatProvider)Formats the value of the current instance using the specified format.
Used by (153, showing 40)
- UiHostHelloUi
- VideoGameVideoPlayback
- AdvancedFixtureVixen.Ui.Controls.Advanced.Tests
- CellVixen.Rendering
- CodeEditorVixen.Ui.Controls.Advanced
- ColorFieldVixen.Ui.Controls.Advanced
- ColorInputTestsVixen.Ui.Controls.Advanced.Tests
- ColorPickerTestsVixen.Ui.Controls.Advanced.Tests
- ColorStripVixen.Ui.Controls.Advanced
- ColorSwatchVixen.Ui.Controls.Advanced
- ContextMenuVixen.Ui.Controls
- ControlFixtureVixen.Ui.Controls.Tests
- ControlIconsVixen.Ui.Controls
- CurveEditorVixen.Ui.Controls.Advanced
- CurveEditorTestsVixen.Ui.Controls.Advanced.Tests
- DesktopDisplaysVixen.Platform.Desktop
- DesktopTextInputVixen.Platform.Desktop
- DisplayInfoVixen.Platform
- DockSplitterViewVixen.Ui.Controls.Advanced
- DockingHostVixen.Ui.Controls.Advanced
- DockingTestsVixen.Ui.Controls.Advanced.Tests
- DockingWindowTestsVixen.Ui.Controls.Advanced.Tests
- DrawCommandVixen.Ui
- DrawContextVixen.Ui
- FitVixen.Ui.Controls.Advanced
- GradientBarVixen.Ui.Controls.Advanced
- GradientEditorVixen.Ui.Controls.Advanced
- GradientRailVixen.Ui.Controls.Advanced
- HeadlessLifecycleTestsVixen.Platform.Headless.Tests
- HeadlessTextInputVixen.Platform.Headless
- ITextInputVixen.Platform
- IconVixen.Ui.Controls
- IconArtVixen.Ui.Controls
- IconArtTestsVixen.Ui.Controls.Tests
- IconAtlasVixen.Ui
- IconAtlasTestsVixen.Ui.Tests
- IconFieldVixen.Ui
- ImageVixen.Ui.Controls
- NavigationInteractionTestsVixen.Ui.Controls.Tests
- NineSliceVixen.Core.Mathematics