Skip to main content

PixelRect Struct

Definition

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia

Represents a rectangle in device pixels.

public struct PixelRect

Inheritance: ValueType -> PixelRect

Implements: IEquatable<PixelRect>

Constructors

NameDescription
PixelRect (4 overloads)Initializes a new instance of the Avalonia.PixelRect structure.

PixelRect overloads

PixelRect Constructor

Initializes a new instance of the Avalonia.PixelRect structure.

public PixelRect(Avalonia.PixelPoint topLeft, Avalonia.PixelPoint bottomRight)
Parameters

topLeft Avalonia.PixelPoint

The top left position of the rectangle.

bottomRight Avalonia.PixelPoint

The bottom right position of the rectangle.

PixelRect Constructor

Initializes a new instance of the Avalonia.PixelRect structure.

public PixelRect(Avalonia.PixelPoint position, Avalonia.PixelSize size)
Parameters

position Avalonia.PixelPoint

The position of the rectangle.

size Avalonia.PixelSize

The size of the rectangle.

PixelRect Constructor

Initializes a new instance of the Avalonia.PixelRect structure.

public PixelRect(Avalonia.PixelSize size)
Parameters

size Avalonia.PixelSize

The size of the rectangle.

PixelRect Constructor

Initializes a new instance of the Avalonia.PixelRect structure.

public PixelRect(int x, int y, int width, int height)
Parameters

x int

The X position.

y int

The Y position.

width int

The width.

height int

The height.

Methods

NameDescription
CenterRectCenters another rectangle in this rectangle.
Contains (2 overloads)Determines whether a point in the bounds of the rectangle.
ContainsExclusiveDetermines whether a point is in the bounds of the rectangle, exclusive of the rectangle's bottom/right edge.
Equals (2 overloads)Returns a boolean indicating whether the rect is equal to the other given rect.
FromRect (2 overloads)Converts a Avalonia.Rect to device pixels using the specified scaling factor.
FromRectWithDpi (2 overloads)Converts a Avalonia.Rect to device pixels using the specified dots per inch (DPI).
GetHashCodeReturns the hash code for this instance.
IntersectGets the intersection of two rectangles.
IntersectsDetermines whether a rectangle intersects with this rectangle.
ParseParses a Avalonia.PixelRect string.
ToRect (2 overloads)Converts the Avalonia.PixelRect to a device-independent Avalonia.Rect using the specified scaling factor.
ToRectWithDpi (2 overloads)Converts the Avalonia.PixelRect to a device-independent Avalonia.Rect using the specified dots per inch (DPI).
ToStringReturns the string representation of the rectangle.
TranslateTranslates the rectangle by an offset.
UnionGets the union of two rectangles.
WithHeightReturns a new Avalonia.PixelRect with the specified height.
WithWidthReturns a new Avalonia.PixelRect with the specified width.
WithXReturns a new Avalonia.PixelRect with the specified X position.
WithYReturns a new Avalonia.PixelRect with the specified Y position.

CenterRect Method

Centers another rectangle in this rectangle.

public Avalonia.PixelRect CenterRect(Avalonia.PixelRect rect)

Parameters

rect Avalonia.PixelRect

The rectangle to center.

Returns

Avalonia.PixelRect

The centered rectangle.

Contains overloads

Contains Method

Determines whether a point in the bounds of the rectangle.

public bool Contains(Avalonia.PixelPoint p)
Parameters

p Avalonia.PixelPoint

The point.

Returns

bool

true if the point is in the bounds of the rectangle; otherwise false.

Contains Method

Determines whether the rectangle fully contains another rectangle.

public bool Contains(Avalonia.PixelRect r)
Parameters

r Avalonia.PixelRect

The rectangle.

Returns

bool

true if the rectangle is fully contained; otherwise false.

ContainsExclusive Method

Determines whether a point is in the bounds of the rectangle, exclusive of the rectangle's bottom/right edge.

public bool ContainsExclusive(Avalonia.PixelPoint p)

Parameters

p Avalonia.PixelPoint

The point.

Returns

bool

true if the point is in the bounds of the rectangle; otherwise false.

Equals overloads

Equals Method

Returns a boolean indicating whether the rect is equal to the other given rect.

public bool Equals(Avalonia.PixelRect other)
Parameters

other Avalonia.PixelRect

The other rect to test equality against.

Returns

bool

True if this rect is equal to other; False otherwise.

Equals Method

Returns a boolean indicating whether the given object is equal to this rectangle.

public bool Equals(object obj)
Parameters

obj object

The object to compare against.

Returns

bool

True if the object is equal to this rectangle; false otherwise.

FromRect overloads

FromRect Method

Converts a Avalonia.Rect to device pixels using the specified scaling factor.

public Avalonia.PixelRect FromRect(Avalonia.Rect rect, Avalonia.Vector scale)
Parameters

rect Avalonia.Rect

The rect.

scale Avalonia.Vector

The scaling factor.

Returns

Avalonia.PixelRect

The device-independent point.

FromRect Method

Converts a Avalonia.Rect to device pixels using the specified scaling factor.

public Avalonia.PixelRect FromRect(Avalonia.Rect rect, double scale)
Parameters

rect Avalonia.Rect

The rect.

scale double

The scaling factor.

Returns

Avalonia.PixelRect

The device-independent rect.

FromRectWithDpi overloads

FromRectWithDpi Method

Converts a Avalonia.Rect to device pixels using the specified dots per inch (DPI).

public Avalonia.PixelRect FromRectWithDpi(Avalonia.Rect rect, Avalonia.Vector dpi)
Parameters

rect Avalonia.Rect

The rect.

dpi Avalonia.Vector

The dots per inch of the device.

Returns

Avalonia.PixelRect

The device-independent point.

FromRectWithDpi Method

Converts a Avalonia.Rect to device pixels using the specified dots per inch (DPI).

public Avalonia.PixelRect FromRectWithDpi(Avalonia.Rect rect, double dpi)
Parameters

rect Avalonia.Rect

The rect.

dpi double

The dots per inch of the device.

Returns

Avalonia.PixelRect

The device-independent point.

GetHashCode Method

Returns the hash code for this instance.

public int GetHashCode()

Returns

int

The hash code.

Intersect Method

Gets the intersection of two rectangles.

public Avalonia.PixelRect Intersect(Avalonia.PixelRect rect)

Parameters

rect Avalonia.PixelRect

The other rectangle.

Returns

Avalonia.PixelRect

The intersection.

Intersects Method

Determines whether a rectangle intersects with this rectangle.

public bool Intersects(Avalonia.PixelRect rect)

Parameters

rect Avalonia.PixelRect

The other rectangle.

Returns

bool

True if the specified rectangle intersects with this one; otherwise false.

Parse Method

Parses a Avalonia.PixelRect string.

public Avalonia.PixelRect Parse(string s)

Parameters

s string

The string.

Returns

Avalonia.PixelRect

The parsed Avalonia.PixelRect.

ToRect overloads

ToRect Method

Converts the Avalonia.PixelRect to a device-independent Avalonia.Rect using the specified scaling factor.

public Avalonia.Rect ToRect(Avalonia.Vector scale)
Parameters

scale Avalonia.Vector

The scaling factor.

Returns

Avalonia.Rect

The device-independent rect.

ToRect Method

Converts the Avalonia.PixelRect to a device-independent Avalonia.Rect using the specified scaling factor.

public Avalonia.Rect ToRect(double scale)
Parameters

scale double

The scaling factor.

Returns

Avalonia.Rect

The device-independent rect.

ToRectWithDpi overloads

ToRectWithDpi Method

Converts the Avalonia.PixelRect to a device-independent Avalonia.Rect using the specified dots per inch (DPI).

public Avalonia.Rect ToRectWithDpi(Avalonia.Vector dpi)
Parameters

dpi Avalonia.Vector

The dots per inch of the device.

Returns

Avalonia.Rect

The device-independent rect.

ToRectWithDpi Method

Converts the Avalonia.PixelRect to a device-independent Avalonia.Rect using the specified dots per inch (DPI).

public Avalonia.Rect ToRectWithDpi(double dpi)
Parameters

dpi double

The dots per inch of the device.

Returns

Avalonia.Rect

The device-independent rect.

ToString Method

Returns the string representation of the rectangle.

public string ToString()

Returns

string

The string representation of the rectangle.

Translate Method

Translates the rectangle by an offset.

public Avalonia.PixelRect Translate(Avalonia.PixelVector offset)

Parameters

offset Avalonia.PixelVector

The offset.

Returns

Avalonia.PixelRect

The translated rectangle.

Union Method

Gets the union of two rectangles.

public Avalonia.PixelRect Union(Avalonia.PixelRect rect)

Parameters

rect Avalonia.PixelRect

The other rectangle.

Returns

Avalonia.PixelRect

The union.

WithHeight Method

Returns a new Avalonia.PixelRect with the specified height.

public Avalonia.PixelRect WithHeight(int height)

Parameters

height int

The height.

Returns

Avalonia.PixelRect

The new Avalonia.PixelRect.

WithWidth Method

Returns a new Avalonia.PixelRect with the specified width.

public Avalonia.PixelRect WithWidth(int width)

Parameters

width int

The width.

Returns

Avalonia.PixelRect

The new Avalonia.PixelRect.

WithX Method

Returns a new Avalonia.PixelRect with the specified X position.

public Avalonia.PixelRect WithX(int x)

Parameters

x int

The x position.

Returns

Avalonia.PixelRect

The new Avalonia.PixelRect.

WithY Method

Returns a new Avalonia.PixelRect with the specified Y position.

public Avalonia.PixelRect WithY(int y)

Parameters

y int

The y position.

Returns

Avalonia.PixelRect

The new Avalonia.PixelRect.

Properties

NameDescription
BottomGets the bottom position of the rectangle.
BottomLeftGets the bottom left point of the rectangle.
BottomRightGets the bottom right point of the rectangle.
CenterGets the center point of the rectangle.
HeightGets the height.
PositionGets the position of the rectangle.
RightGets the right position of the rectangle.
SizeGets the size of the rectangle.
TopLeftGets the top left point of the rectangle.
TopRightGets the top right point of the rectangle.
WidthGets the width.
XGets the X position.
YGets the Y position.

Bottom Property

Gets the bottom position of the rectangle.

public int Bottom { get; set; }

BottomLeft Property

Gets the bottom left point of the rectangle.

public Avalonia.PixelPoint BottomLeft { get; set; }

BottomRight Property

Gets the bottom right point of the rectangle.

public Avalonia.PixelPoint BottomRight { get; set; }

Center Property

Gets the center point of the rectangle.

public Avalonia.PixelPoint Center { get; set; }

Height Property

Gets the height.

public int Height { get; set; }

Position Property

Gets the position of the rectangle.

public Avalonia.PixelPoint Position { get; set; }

Right Property

Gets the right position of the rectangle.

public int Right { get; set; }

Size Property

Gets the size of the rectangle.

public Avalonia.PixelSize Size { get; set; }

TopLeft Property

Gets the top left point of the rectangle.

public Avalonia.PixelPoint TopLeft { get; set; }

TopRight Property

Gets the top right point of the rectangle.

public Avalonia.PixelPoint TopRight { get; set; }

Width Property

Gets the width.

public int Width { get; set; }

X Property

Gets the X position.

public int X { get; set; }

Y Property

Gets the Y position.

public int Y { get; set; }