Skip to content

Class Bounds

Definition

Namespace: StardewUI.Layout
Assembly: StardewUI.dll

A bounding rectangle using floating-point dimensions.

[StardewUI.DuckType]
public record Bounds : StardewUI.Layout.IOffsettable<StardewUI.Layout.Bounds>, 
    IEquatable<StardewUI.Layout.Bounds>

Inheritance
Object ⇦ Bounds

Implements
IOffsettable<Bounds>, IEquatable<Bounds>

Members

Constructors

Name Description
Bounds(Vector2, Vector2) A bounding rectangle using floating-point dimensions.

Fields

Name Description
Empty Empty bounds, used for invalid results.

Properties

Name Description
Bottom The Y value at the bottom edge of the bounding rectangle.
EqualityContract
Left The X value at the left edge of the bounding rectangle.
Position The top-left position.
Right The X value at the right edge of the bounding rectangle.
Size The width and height.
Top The Y value at the top edge of the bounding rectangle.

Methods

Name Description
Center() Gets the point at the center of the bounding rectangle.
ContainsBounds(Bounds) Checks if an entire bounding rectangle is fully within these bounds.
ContainsPoint(Vector2) Checks if a given point is within the bounds.
Intersection(Bounds) Computes the intersection of this Bounds with another instance.
IntersectsWith(Bounds) Checks if this Bounds intersects with another instance, without computing the intersection.
Offset(Vector2) Offsets a Bounds by a given distance.
Truncate() Converts the bounds to an integer Rectangle, truncating any fractional values.
Union(Bounds) Computes the union of this Bounds with another instance.

Details

Constructors

Bounds(Vector2, Vector2)

A bounding rectangle using floating-point dimensions.

public Bounds(Microsoft.Xna.Framework.Vector2 Position, Microsoft.Xna.Framework.Vector2 Size);
Parameters

Position   Vector2
The top-left position.

Size   Vector2
The width and height.


Fields

Empty

Empty bounds, used for invalid results.

public static readonly StardewUI.Layout.Bounds Empty;
Field Value

Bounds


Properties

Bottom

The Y value at the bottom edge of the bounding rectangle.

public float Bottom { get; }
Property Value

Single


EqualityContract

protected System.Type EqualityContract { get; }
Property Value

Type


Left

The X value at the left edge of the bounding rectangle.

public float Left { get; }
Property Value

Single


Position

The top-left position.

public Microsoft.Xna.Framework.Vector2 Position { get; set; }
Property Value

Vector2


The X value at the right edge of the bounding rectangle.

public float Right { get; }
Property Value

Single


Size

The width and height.

public Microsoft.Xna.Framework.Vector2 Size { get; set; }
Property Value

Vector2


Top

The Y value at the top edge of the bounding rectangle.

public float Top { get; }
Property Value

Single


Methods

Center()

Gets the point at the center of the bounding rectangle.

public Microsoft.Xna.Framework.Vector2 Center();
Returns

Vector2


ContainsBounds(Bounds)

Checks if an entire bounding rectangle is fully within these bounds.

public bool ContainsBounds(StardewUI.Layout.Bounds bounds);
Parameters

bounds   Bounds
The other bounds.

Returns

Boolean

true if bounds are a subset of the current instance; false if the two bounds do not overlap or only overlap partially.


ContainsPoint(Vector2)

Checks if a given point is within the bounds.

public bool ContainsPoint(Microsoft.Xna.Framework.Vector2 point);
Parameters

point   Vector2
The point to check.

Returns

Boolean

true if point is inside these bounds; otherwise false.


Intersection(Bounds)

Computes the intersection of this Bounds with another instance.

public StardewUI.Layout.Bounds Intersection(StardewUI.Layout.Bounds other);
Parameters

other   Bounds
The other bounds to intersect with.

Returns

Bounds

A new Bounds whose area is the intersection of this instance and other, or Empty if they do not overlap.


IntersectsWith(Bounds)

Checks if this Bounds intersects with another instance, without computing the intersection.

public bool IntersectsWith(StardewUI.Layout.Bounds other);
Parameters

other   Bounds
The other bounds to check for intersection.

Returns

Boolean

True if this Bounds and the other bounds have any intersecting area, otherwise false.


Offset(Vector2)

Offsets a Bounds by a given distance.

public StardewUI.Layout.Bounds Offset(Microsoft.Xna.Framework.Vector2 distance);
Parameters

distance   Vector2
The offset distance.

Returns

Bounds

A new Bounds with the same size as this instance and a Position offset by the specified distance.


Truncate()

Converts the bounds to an integer Rectangle, truncating any fractional values.

public Microsoft.Xna.Framework.Rectangle Truncate();
Returns

Rectangle

Remarks

Truncating is the same behavior used in ToPoint(), making this consistent with the equivalent component-by-component translation to XNA.


Union(Bounds)

Computes the union of this Bounds with another instance.

public StardewUI.Layout.Bounds Union(StardewUI.Layout.Bounds other);
Parameters

other   Bounds
The other bounds to add to the union.

Returns

Bounds

A new Bounds whose set is the union of this instance and other; i.e. is exactly large enough to contain both bounds.