Struct Thickness
Describes the thickness of a frame around a rectangle. Four int values describe the Left, Top, Right, and Bottom sides of the rectangle, respectively.
public record struct Thickness : IEquatable<Thickness>
- Implements
- Inherited Members
Remarks
Use the helper API (GetInside(Rectangle) to get the rectangle describing the insides of the frame, with the thickness widths subtracted.
Thickness uses float internally. As a result, there is a potential precision loss for very large numbers. This is typically not an issue for UI dimensions but could be relevant in other contexts.
Constructors
- Thickness()
Initializes a new instance of the Thickness class with all widths set to 0.
- Thickness(int)
Initializes a new instance of the Thickness class with a uniform width to each side.
- Thickness(int, int, int, int)
Initializes a new instance of the Thickness class that has specific widths applied to each side of the rectangle.
Properties
- Bottom
Gets or sets the width of the lower side of the rectangle.
- Empty
Gets an empty thickness.
- Horizontal
Gets the total width of the left and right sides of the rectangle. Sets the width of the left and rigth sides of the rectangle to half the specified value.
- Left
Gets or sets the width of the left side of the rectangle.
- Right
Gets or sets the width of the right side of the rectangle.
- Top
Gets or sets the width of the upper side of the rectangle.
- Vertical
Gets the total height of the top and bottom sides of the rectangle. Sets the height of the top and bottom sides of the rectangle to half the specified value.
Methods
- Add(Thickness)
Adds the thickness widths of another Thickness to the current Thickness, returning a new Thickness.
- Contains(in Rectangle, in Point)
Gets whether the specified coordinates lie within the thickness (inside the bounding rectangle but outside the rectangle described by GetInside(Rectangle).
- Draw(Rectangle, ViewDiagnosticFlags, string?)
Draws the Thickness rectangle with an optional diagnostics label.
- GetInside(Rectangle)
Returns a rectangle describing the location and size of the inside area of
rect
with the thickness widths subtracted. The height and width of the returned rectangle will never be less than 0.
- ToString()
Returns the thickness widths of the Thickness formatted as a string.
Operators
- operator +(Thickness, Thickness)
Adds the thickness widths of another Thickness to another Thickness.