Struct Padding
Represents a generic padding. A padding is an object of data that stores an offset from each side of a rectangle or square.
[DataContract]
public struct Padding : IEquatable<Padding>
- Implements
- Inherited Members
Constructors
Padding(Padding, float)
Creates a new padding from an existing padding, modifying it by growing or shrinking it.
public Padding(Padding padding, float growth)
Parameters
paddingPaddingThe padding whose initial values to use
growthfloatThe amount to grow each border by. Negative values will shrink the padding.
Padding(float)
Creates a new padding with the specified value, which will be applied to each edge.
public Padding(float value)
Parameters
valuefloatThe padding to apply to each edge
Padding(float, float)
Creates a new padding with the specified x and y values, applying them to both edges.
public Padding(float x, float y)
Parameters
xfloatThe x padding, which will turn into the left and right padding
yfloatThe y padding, which till turn into the top and bottom padding
Padding(float, float, float, float)
Create a new padding with the specified borders.
public Padding(float left, float right, float top, float bottom)
Parameters
leftfloatThe amount of padding on the left side
rightfloatThe amount of padding on the right side
topfloatThe amount of padding on the top side
bottomfloatThe amount of padding on the bottom side
Fields
Bottom
The amount of padding on the bottom side
[DataMember]
public float Bottom
Field Value
Left
The amount of padding on the left side
[DataMember]
public float Left
Field Value
Right
The amount of padding on the right side
[DataMember]
public float Right
Field Value
Top
The amount of padding on the top side
[DataMember]
public float Top
Field Value
Properties
Empty
The empty padding, with all borders set to 0
public static Padding Empty { get; }
Property Value
Height
The total height of this padding, a sum of the top and bottom padding.
public float Height { get; }
Property Value
Width
The total width of this padding, a sum of the left and right padding.
public float Width { get; }
Property Value
Methods
Equals(Padding)
Indicates whether this instance and a specified object are equal.
public bool Equals(Padding other)
Parameters
otherPadding
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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.
Operators
operator +(Padding, Padding)
Adds two paddings together in a memberwise fashion.
public static Padding operator +(Padding left, Padding right)
Parameters
Returns
operator ==(Padding, Padding)
Indicates whether this instance and a specified object are equal.
public static bool operator ==(Padding left, Padding right)
Parameters
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
implicit operator Padding(Vector2)
Implicitly creates a padding from the given two-dimensional vector. The left and right padding will both be the vector's x value, and the top and bottom padding will both be the vector's y value.
public static implicit operator Padding(Vector2 vec)
Parameters
vecVector2The vector to convert
Returns
- Padding
A padding based on the vector's values
operator !=(Padding, Padding)
Indicates whether this instance and a specified object are equal.
public static bool operator !=(Padding left, Padding right)
Parameters
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
operator *(Padding, Vector2)
Scales a padding by a Microsoft.Xna.Framework.Vector2.
public static Padding operator *(Padding p, Vector2 scale)
Parameters
pPaddingscaleVector2
Returns
operator *(Padding, float)
Scales a padding by a scalar.
public static Padding operator *(Padding p, float scale)
Parameters
Returns
operator -(Padding, Padding)
Subtracts two paddings in a memberwise fashion.
public static Padding operator -(Padding left, Padding right)