Struct Frame
Represents thickness values for each edge of a rectangular element.
public struct Frame
- Inherited Members
Remarks
A Frame defines spacing from the left, top, right, and bottom edges.
It is typically used for layout constructs such as Margin
, Padding
, or BorderWidth
.
Unlike Rect, it does not represent position or size—only edge offsets.
Constructors
Frame()
Initializes a new Frame with all edges set to zero.
public Frame()
Frame(NFloat, NFloat, NFloat, NFloat)
Initializes a new Frame with the specified edge thicknesses.
public Frame(NFloat top, NFloat right, NFloat bottom, NFloat left)
Parameters
top
NFloatTop edge thickness.
right
NFloatRight edge thickness.
bottom
NFloatBottom edge thickness.
left
NFloatLeft edge thickness.
Fields
Bottom
The thickness of the bottom edge.
public NFloat Bottom
Field Value
Left
The thickness of the left edge.
public NFloat Left
Field Value
Right
The thickness of the right edge.
public NFloat Right
Field Value
Top
The thickness of the top edge.
public NFloat Top
Field Value
Zero
A frame with all edge values set to zero.
public static readonly Frame Zero
Field Value
Properties
IsUniform
Returns true
if all four edges have equal thickness.
public bool IsUniform { get; }
Property Value
IsZero
Returns true if all sides (Left, Top, Right, Bottom) are zero.
public readonly bool IsZero { get; }
Property Value
TotalHeight
Gets the total vertical edge thickness (top + bottom).
public NFloat TotalHeight { get; }
Property Value
TotalWidth
Gets the total horizontal edge thickness (left + right).
public NFloat TotalWidth { get; }
Property Value
Methods
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Max(Frame, Frame)
Returns a frame containing the maximum value for each edge from two frames.
public static Frame Max(Frame lhs, Frame rhs)
Parameters
Returns
Min(Frame, Frame)
Returns a frame containing the minimum value for each edge from two frames.
public static Frame Min(Frame lhs, Frame rhs)
Parameters
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator +(Frame, Frame)
Adds the corresponding edge thicknesses of two frames.
public static Frame operator +(Frame lhs, Frame rhs)
Parameters
Returns
operator ==(Frame, Frame)
Returns true
if all edge values match exactly.
public static bool operator ==(Frame left, Frame right)
Parameters
Returns
implicit operator Frame(double)
Implicitly converts a double to a Frame, applying the same value to all four sides (Left, Top, Right, Bottom).
public static implicit operator Frame(double value)
Parameters
value
doubleThe double value to apply uniformly to all sides.
Returns
implicit operator Frame(int)
Implicitly converts an int to a Frame, applying the same value to all four sides (Left, Top, Right, Bottom).
public static implicit operator Frame(int value)
Parameters
value
intThe integer value to apply uniformly to all sides.
Returns
implicit operator Frame(NFloat)
Converts a scalar value into a uniform Frame for all sides.
public static implicit operator Frame(NFloat value)
Parameters
value
NFloat
Returns
implicit operator Frame(float)
Implicitly converts a float to a Frame, applying the same value to all four sides (Left, Top, Right, Bottom).
public static implicit operator Frame(float value)
Parameters
value
floatThe float value to apply uniformly to all sides.
Returns
implicit operator Frame((NFloat top, NFloat right, NFloat bottom, NFloat left))
Converts a 4-tuple (top, right, bottom, left) to a Frame.
public static implicit operator Frame((NFloat top, NFloat right, NFloat bottom, NFloat left) value)
Parameters
value
(NFloat topLeft, NFloat topRight, NFloat bottomRight, NFloat bottomLeft)
Returns
implicit operator Frame((NFloat horizontal, NFloat vertical))
Converts a 2-tuple (horizontal, vertical) to a Frame. Horizontal is applied to left and right; vertical to top and bottom.
public static implicit operator Frame((NFloat horizontal, NFloat vertical) value)
Parameters
value
(NFloat horizontal, NFloat vertical)
Returns
operator !=(Frame, Frame)
Returns true
if any edge value differs.
public static bool operator !=(Frame lhs, Frame rhs)
Parameters
Returns
operator *(Frame, NFloat)
Scales all edges of the frame by the specified scalar.
public static Frame operator *(Frame lhs, NFloat rhs)
Parameters
Returns
operator -(Frame, Frame)
Subtracts the corresponding edge thicknesses of two frames.
public static Frame operator -(Frame lhs, Frame rhs)