Please use. NET 5,. NET 6, NET 7,. NET 8, NET Framework 4.6, NET Framework 4.61, NET Framework 4.7, NET Framework 4.72, NET Framework 4.8, NET Framework 4.81, and. NET Core 3.1 versions

Rect 结构

Represents a rectangular region with integer coordinates and dimensions 表示具有整数坐标和尺寸的矩形区域

Definition

命名空间: DeploySharp.Data
程序集: DeploySharp (在 DeploySharp.dll 中) 版本:0.0.4+6e8a2e904469617cd59619d666c0e272985c0e33
C#
public struct Rect : IEquatable<Rect>
Inheritance
Object    ValueType    Rect
Implements
IEquatableRect

备注

Provides functionality for geometric operations including intersection, union, containment checks, and coordinate transformations.

提供几何运算功能,包括交集、并集、包含检查和坐标转换。

示例

Basic usage:
C#
var rect = new Rect(10, 20, 100, 50);
var point = new Point(15, 25);
bool contains = rect.Contains(point);

构造函数

Rect(Point, Size) Initializes a new rectangle from location and size 从位置和大小初始化新矩形
Rect(Int32, Int32, Int32, Int32) Represents a rectangular region with integer coordinates and dimensions 表示具有整数坐标和尺寸的矩形区域

属性

Bottom Gets the bottom edge Y-coordinate (Y + Height) 获取下边缘Y坐标(Y + Height)
BottomRight Gets the bottom-right corner point 获取右下角点
Left Gets or sets the left edge X-coordinate 获取或设置左边缘X坐标
Location Gets or sets the top-left location of the rectangle 获取或设置矩形的左上角位置
Right Gets the right edge X-coordinate (X + Width) 获取右边缘X坐标(X + Width)
Size Gets or sets the size of the rectangle 获取或设置矩形的大小
Top Gets or sets the top edge Y-coordinate 获取或设置上边缘Y坐标
TopLeft Gets the top-left corner point 获取左上角点

方法

Add(Point) Translates the rectangle by adding point coordinates 通过添加点坐标平移矩形
Add(Size) Expands the rectangle by adding size dimensions 通过添加尺寸扩展矩形
Contains(Point) Determines if the rectangle contains a point 确定矩形是否包含点
Contains(Rect) Determines if the rectangle fully contains another rectangle 确定矩形是否完全包含另一个矩形
Contains(Int32, Int32) Determines if the rectangle contains a point with specified coordinates 确定矩形是否包含具有指定坐标的点
Equals Determines if two rectangles are equal 确定两个矩形是否相等
FromLTRB 
GetTypeGets the Type of the current instance.
(继承自 Object。)
Inflate(Size) Expands the rectangle by the specified size 按指定尺寸扩展矩形
Inflate(Int32, Int32) Expands the rectangle by the specified amount 按指定量扩展矩形
Inflate(Rect, Int32, Int32) Returns a new rectangle expanded by specified amounts 返回按指定量扩展的新矩形
Intersect(Rect) Computes intersection with another rectangle 计算与另一个矩形的交集
Intersect(Rect, Rect) Computes the intersection of two rectangles 计算两个矩形的交集
IntersectsWith Determines if this rectangle intersects with another 确定此矩形是否与另一个矩形相交
Subtract(Point) Translates the rectangle by subtracting point coordinates 通过减去点坐标平移矩形
Subtract(Size) Shrinks the rectangle by subtracting size dimensions 通过减去尺寸缩小矩形
ToString Returns a string representation of the rectangle 返回矩形的字符串表示形式
(重写 ValueTypeToString)
Union(Rect) Computes union with another rectangle 计算与另一个矩形的并集
Union(Rect, Rect) Computes the union of two rectangles 计算两个矩形的并集

运算符

Addition(Rect, Point) Translates a rectangle by adding point coordinates 通过添加点坐标平移矩形
Addition(Rect, Size) Expands a rectangle by adding size dimensions 通过添加尺寸扩展矩形
BitwiseAnd(Rect, Rect) Computes the intersection of two rectangles 计算两个矩形的交集
BitwiseOr(Rect, Rect) Computes the union of two rectangles 计算两个矩形的并集
Subtraction(Rect, Point) Translates a rectangle by subtracting point coordinates 通过减去点坐标平移矩形
Subtraction(Rect, Size) Shrinks a rectangle by subtracting size dimensions 通过减去尺寸缩小矩形

字段

Height 
Width 
X Gets or sets the X-coordinate of the rectangle's left edge 获取或设置矩形左边缘的X坐标
Y Gets or sets the Y-coordinate of the rectangle's top edge 获取或设置矩形上边缘的Y坐标

参见