Struct PixelRect
- Namespace
- Avalonia
- Assembly
- Avalonia.Base.dll
Represents a rectangle in device pixels.
public readonly struct PixelRect : IEquatable<PixelRect>
- Implements
- Inherited Members
Constructors
PixelRect(PixelPoint, PixelPoint)
Initializes a new instance of the PixelRect structure.
public PixelRect(PixelPoint topLeft, PixelPoint bottomRight)
Parameters
topLeft
PixelPointThe top left position of the rectangle.
bottomRight
PixelPointThe bottom right position of the rectangle.
PixelRect(PixelPoint, PixelSize)
Initializes a new instance of the PixelRect structure.
public PixelRect(PixelPoint position, PixelSize size)
Parameters
position
PixelPointThe position of the rectangle.
size
PixelSizeThe size of the rectangle.
PixelRect(PixelSize)
Initializes a new instance of the PixelRect structure.
public PixelRect(PixelSize size)
Parameters
size
PixelSizeThe size of the rectangle.
PixelRect(int, int, int, int)
Initializes a new instance of the PixelRect structure.
public PixelRect(int x, int y, int width, int height)
Parameters
Properties
Bottom
Gets the bottom position of the rectangle.
public int Bottom { get; }
Property Value
BottomLeft
Gets the bottom left point of the rectangle.
public PixelPoint BottomLeft { get; }
Property Value
BottomRight
Gets the bottom right point of the rectangle.
public PixelPoint BottomRight { get; }
Property Value
Center
Gets the center point of the rectangle.
public PixelPoint Center { get; }
Property Value
Height
Gets the height.
public int Height { get; }
Property Value
Position
Gets the position of the rectangle.
public PixelPoint Position { get; }
Property Value
Right
Gets the right position of the rectangle.
public int Right { get; }
Property Value
Size
Gets the size of the rectangle.
public PixelSize Size { get; }
Property Value
TopLeft
Gets the top left point of the rectangle.
public PixelPoint TopLeft { get; }
Property Value
TopRight
Gets the top right point of the rectangle.
public PixelPoint TopRight { get; }
Property Value
Width
Gets the width.
public int Width { get; }
Property Value
X
Gets the X position.
public int X { get; }
Property Value
Y
Gets the Y position.
public int Y { get; }
Property Value
Methods
CenterRect(PixelRect)
Centers another rectangle in this rectangle.
public PixelRect CenterRect(PixelRect rect)
Parameters
rect
PixelRectThe rectangle to center.
Returns
- PixelRect
The centered rectangle.
Contains(PixelPoint)
Determines whether a point in the bounds of the rectangle.
public bool Contains(PixelPoint p)
Parameters
p
PixelPointThe point.
Returns
- bool
true if the point is in the bounds of the rectangle; otherwise false.
Contains(PixelRect)
Determines whether the rectangle fully contains another rectangle.
public bool Contains(PixelRect r)
Parameters
r
PixelRectThe rectangle.
Returns
- bool
true if the rectangle is fully contained; otherwise false.
ContainsExclusive(PixelPoint)
Determines whether a point is in the bounds of the rectangle, exclusive of the rectangle's bottom/right edge.
public bool ContainsExclusive(PixelPoint p)
Parameters
p
PixelPointThe point.
Returns
- bool
true if the point is in the bounds of the rectangle; otherwise false.
Equals(PixelRect)
Returns a boolean indicating whether the rect is equal to the other given rect.
public bool Equals(PixelRect other)
Parameters
other
PixelRectThe other rect to test equality against.
Returns
- bool
True if this rect is equal to other; False otherwise.
Equals(object?)
Returns a boolean indicating whether the given object is equal to this rectangle.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare against.
Returns
- bool
True if the object is equal to this rectangle; false otherwise.
FromRect(Rect, Vector)
Converts a Rect to device pixels using the specified scaling factor.
public static PixelRect FromRect(Rect rect, Vector scale)
Parameters
Returns
- PixelRect
The device-independent point.
FromRect(Rect, double)
Converts a Rect to device pixels using the specified scaling factor.
public static PixelRect FromRect(Rect rect, double scale)
Parameters
Returns
- PixelRect
The device-independent rect.
FromRectWithDpi(Rect, Vector)
Converts a Rect to device pixels using the specified dots per inch (DPI).
public static PixelRect FromRectWithDpi(Rect rect, Vector dpi)
Parameters
Returns
- PixelRect
The device-independent point.
FromRectWithDpi(Rect, double)
Converts a Rect to device pixels using the specified dots per inch (DPI).
public static PixelRect FromRectWithDpi(Rect rect, double dpi)
Parameters
Returns
- PixelRect
The device-independent point.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
The hash code.
Intersect(PixelRect)
Gets the intersection of two rectangles.
public PixelRect Intersect(PixelRect rect)
Parameters
rect
PixelRectThe other rectangle.
Returns
- PixelRect
The intersection.
Intersects(PixelRect)
Determines whether a rectangle intersects with this rectangle.
public bool Intersects(PixelRect rect)
Parameters
rect
PixelRectThe other rectangle.
Returns
- bool
True if the specified rectangle intersects with this one; otherwise false.
Parse(string)
Parses a PixelRect string.
public static PixelRect Parse(string s)
Parameters
s
stringThe string.
Returns
ToRect(Vector)
public Rect ToRect(Vector scale)
Parameters
scale
VectorThe scaling factor.
Returns
- Rect
The device-independent rect.
ToRect(double)
public Rect ToRect(double scale)
Parameters
scale
doubleThe scaling factor.
Returns
- Rect
The device-independent rect.
ToRectWithDpi(Vector)
public Rect ToRectWithDpi(Vector dpi)
Parameters
dpi
VectorThe dots per inch of the device.
Returns
- Rect
The device-independent rect.
ToRectWithDpi(double)
public Rect ToRectWithDpi(double dpi)
Parameters
dpi
doubleThe dots per inch of the device.
Returns
- Rect
The device-independent rect.
ToString()
Returns the string representation of the rectangle.
public override string ToString()
Returns
- string
The string representation of the rectangle.
Translate(PixelVector)
Translates the rectangle by an offset.
public PixelRect Translate(PixelVector offset)
Parameters
offset
PixelVectorThe offset.
Returns
- PixelRect
The translated rectangle.
Union(PixelRect)
Gets the union of two rectangles.
public PixelRect Union(PixelRect rect)
Parameters
rect
PixelRectThe other rectangle.
Returns
- PixelRect
The union.
WithHeight(int)
Returns a new PixelRect with the specified height.
public PixelRect WithHeight(int height)
Parameters
height
intThe height.
Returns
WithWidth(int)
Returns a new PixelRect with the specified width.
public PixelRect WithWidth(int width)
Parameters
width
intThe width.
Returns
WithX(int)
Returns a new PixelRect with the specified X position.
public PixelRect WithX(int x)
Parameters
x
intThe x position.
Returns
WithY(int)
Returns a new PixelRect with the specified Y position.
public PixelRect WithY(int y)
Parameters
y
intThe y position.
Returns
Operators
operator ==(PixelRect, PixelRect)
Checks for equality between two PixelRects.
public static bool operator ==(PixelRect left, PixelRect right)
Parameters
Returns
- bool
True if the rects are equal; otherwise false.
operator !=(PixelRect, PixelRect)
Checks for inequality between two PixelRects.
public static bool operator !=(PixelRect left, PixelRect right)
Parameters
Returns
- bool
True if the rects are unequal; otherwise false.