Struct Size
- Namespace
- Avalonia
- Assembly
- Avalonia.Base.dll
Defines a size.
public readonly struct Size : IEquatable<Size>
- Implements
- Inherited Members
Constructors
Size(double, double)
Initializes a new instance of the Size structure.
public Size(double width, double height)
Parameters
Size(Vector2)
Initializes a new instance of the Size structure.
public Size(Vector2 vector2)
Parameters
vector2
Vector2The vector to take values from.
Fields
Infinity
A size representing infinity.
public static readonly Size Infinity
Field Value
Properties
AspectRatio
Gets the aspect ratio of the size.
public double AspectRatio { get; }
Property Value
Height
Gets the height.
public double Height { get; }
Property Value
Width
Gets the width.
public double Width { get; }
Property Value
Methods
Constrain(Size)
Constrains the size.
public Size Constrain(Size constraint)
Parameters
constraint
SizeThe size to constrain to.
Returns
- Size
The constrained size.
Deconstruct(out double, out double)
Deconstructs the size into its Width and Height values.
public void Deconstruct(out double width, out double height)
Parameters
Deflate(Thickness)
Deflates the size by a Thickness.
public Size Deflate(Thickness thickness)
Parameters
thickness
ThicknessThe thickness.
Returns
- Size
The deflated size.
Remarks
The deflated size cannot be less than 0.
Equals(Size)
Returns a boolean indicating whether the size is equal to the other given size (bitwise).
public bool Equals(Size other)
Parameters
other
SizeThe other size to test equality against.
Returns
- bool
True if this size is equal to other; False otherwise.
Equals(object?)
Checks for equality between a size and an object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object.
Returns
- bool
True if
obj
is a size that equals the current size.
GetHashCode()
Returns a hash code for a Size.
public override int GetHashCode()
Returns
- int
The hash code.
Inflate(Thickness)
Inflates the size by a Thickness.
public Size Inflate(Thickness thickness)
Parameters
thickness
ThicknessThe thickness.
Returns
- Size
The inflated size.
NearlyEquals(Size)
Returns a boolean indicating whether the size is equal to the other given size (numerically).
public bool NearlyEquals(Size other)
Parameters
other
SizeThe other size to test equality against.
Returns
- bool
True if this size is equal to other; False otherwise.
Parse(string)
Parses a Size string.
public static Size Parse(string s)
Parameters
s
stringThe string.
Returns
ToString()
Returns the string representation of the size.
public override string ToString()
Returns
- string
The string representation of the size.
WithHeight(double)
Returns a new Size with the same width and the specified height.
public Size WithHeight(double height)
Parameters
height
doubleThe height.
Returns
WithWidth(double)
Returns a new Size with the same height and the specified width.
public Size WithWidth(double width)
Parameters
width
doubleThe width.
Returns
Operators
operator +(Size, Size)
public static Size operator +(Size size, Size toAdd)
Parameters
Returns
operator /(Size, Size)
Divides a size by another size to produce a scaling factor.
public static Vector operator /(Size left, Size right)
Parameters
Returns
- Vector
The scaled size.
operator /(Size, Vector)
Scales a size.
public static Size operator /(Size size, Vector scale)
Parameters
Returns
- Size
The scaled size.
operator /(Size, double)
Scales a size.
public static Size operator /(Size size, double scale)
Parameters
Returns
- Size
The scaled size.
operator ==(Size, Size)
Checks for equality between two Sizes.
public static bool operator ==(Size left, Size right)
Parameters
Returns
- bool
True if the sizes are equal; otherwise false.
operator !=(Size, Size)
Checks for inequality between two Sizes.
public static bool operator !=(Size left, Size right)
Parameters
Returns
- bool
True if the sizes are unequal; otherwise false.
operator *(Size, Vector)
Scales a size.
public static Size operator *(Size size, Vector scale)
Parameters
Returns
- Size
The scaled size.
operator *(Size, double)
Scales a size.
public static Size operator *(Size size, double scale)
Parameters
Returns
- Size
The scaled size.
operator -(Size, Size)
public static Size operator -(Size size, Size toSubtract)