Rectangle 类
Summary: Stores a set of four integers that represent the location and size of a rectangle.
Module: aspose.imaging
Full Name: aspose.imaging.Rectangle
Constructors
| Name | 描述 |
|---|---|
| Rectangle() | 初始化 Rectangle 类的新实例 |
| Rectangle(location, size) | 使用指定的位置和大小初始化 Rectangle 结构的新实例。 |
| Rectangle(x, y, width, height) | 使用指定的位置和大小初始化 Rectangle 结构的新实例。 |
Properties
| Name | Type | Access | 描述 |
|---|---|---|---|
| bottom | int | r/w | 获取或设置此 Rectangle 结构的 y 坐标,该坐标为 Rectangle.y 与 Rectangle.height 属性值之和。 |
| empty [static] | Rectangle | r | 获取一个新的 Rectangle 结构实例,其 Rectangle.x、Rectangle.y、Rectangle.width 和 Rectangle.height 的值均为零。 |
| height | int | r/w | 获取或设置此 Rectangle 结构的高度。 |
| is_empty | bool | r | 获取一个值,指示此 Rectangle 的所有数值属性是否全部为零。 |
| left | int | r/w | 获取或设置此 Rectangle 结构左边缘的 x 坐标。 |
| location | Point | r/w | 获取或设置此 Rectangle 结构左上角的坐标。 |
| right | int | r/w | 获取或设置此 Rectangle 结构的 x 坐标,该坐标为 Rectangle.x 与 Rectangle.width 属性值之和。 |
| size | Size | r/w | 获取或设置此 Rectangle 的大小。 |
| top | int | r/w | 获取或设置此 Rectangle 结构顶部边缘的 y 坐标。 |
| width | int | r/w | 获取或设置此 Rectangle 结构的宽度。 |
| x | int | r/w | 获取或设置此 Rectangle 结构左上角的 x 坐标。 |
| y | int | r/w | 获取或设置此 Rectangle 结构左上角的 y 坐标。 |
Methods
Constructor: Rectangle()
Rectangle()
初始化 Rectangle 类的新实例
Constructor: Rectangle(location, size)
Rectangle(location, size)
使用指定的位置和大小初始化 Rectangle 结构的新实例。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| location | Point | 表示矩形区域左上角的 Point。 |
| size | Size | 表示矩形区域宽度和高度的 Size。 |
Constructor: Rectangle(x, y, width, height)
Rectangle(x, y, width, height)
使用指定的位置和大小初始化 Rectangle 结构的新实例。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| x | int | 矩形左上角的 x 坐标。 |
| y | int | 矩形左上角的 y 坐标。 |
| width | int | 矩形的宽度。 |
| height | int | 矩形的高度。 |
Method: ceiling(value) [static]
ceiling(value)
将指定的 RectangleF 结构转换为 Rectangle 结构,方法是将 RectangleF 的值向上取整为下一个整数。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| value | RectangleF | 待转换的 RectangleF 结构。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 返回一个 Rectangle。 |
Method: contains(point)
contains(point)
确定指定的点是否位于此 Rectangle 结构内部。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| point | Point | 待测试的 Point。 |
Returns
| Type | Description |
|---|---|
| bool | 如果由 point 表示的点位于此 Rectangle 结构内部,则此方法返回 true;否则返回 false。 |
Method: contains(rect)
contains(rect)
确定由 rect 表示的矩形区域是否完全包含在此 Rectangle 结构中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rect | Rectangle | 要测试的 Rectangle。 |
Returns
| Type | Description |
|---|---|
| bool | 如果由 rect 表示的矩形区域完全位于此 Rectangle 结构内部,则此方法返回 true;否则返回 false。 |
Method: contains(x, y)
contains(x, y)
确定指定的点是否位于此 Rectangle 结构内部。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| x | int | 要测试的点的 x 坐标。 |
| y | int | 要测试的点的 y 坐标。 |
Returns
| Type | Description |
|---|---|
| bool | 如果由 x 和 y 定义的点位于此 Rectangle 结构内部,则此方法返回 true;否则返回 false。 |
Method: contains_point(point)
contains_point(point)
确定指定的点是否位于此 Rectangle 结构内部。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| point | Point | 待测试的 Point。 |
Returns
| Type | Description |
|---|---|
| bool | 如果由 point 表示的点位于此 Rectangle 结构内部,则此方法返回 true;否则返回 false。 |
Method: contains_rect(rect)
contains_rect(rect)
确定由 rect 表示的矩形区域是否完全包含在此 Rectangle 结构中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rect | Rectangle | 要测试的 Rectangle。 |
Returns
| Type | Description |
|---|---|
| bool | 如果由 rect 表示的矩形区域完全位于此 Rectangle 结构内部,则此方法返回 true;否则返回 false。 |
Method: from_left_top_right_bottom(left, top, right, bottom) [static]
from_left_top_right_bottom(left, top, right, bottom)
使用指定的边缘位置创建一个 Rectangle 结构。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| left | int | 此 Rectangle 结构左上角的 x 坐标。 |
| top | int | 此 Rectangle 结构左上角的 y 坐标。 |
| right | int | 此 Rectangle 结构右下角的 x 坐标。 |
| bottom | int | 此 Rectangle 结构右下角的 y 坐标。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 此方法创建的新 Rectangle。 |
Method: from_points(point1, point2) [static]
from_points(point1, point2)
根据指定的两个点创建一个新的 Rectangle。创建的 Rectangle 的两个顶点将等于传入的 point1 和 point2,通常它们是相对的顶点。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| point1 | Point | 新矩形的第一个 Point。 |
| point2 | Point | 新矩形的第二个 Point。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 新创建的 Rectangle。 |
Method: inflate(rect, x, y) [static]
inflate(rect, x, y)
创建并返回指定的 Rectangle 结构的膨胀副本。该副本按指定的量进行膨胀,原始的 Rectangle 结构保持不变。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rect | Rectangle | 用于开始的 Rectangle。此矩形不会被修改。 |
| x | int | 水平膨胀此 Rectangle 的量。 |
| y | int | 垂直膨胀此 Rectangle 的量。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 膨胀后的 Rectangle。 |
Method: inflate(size)
inflate(size)
按指定的量膨胀此 Rectangle。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| size | Size | 膨胀此矩形的量。 |
Method: inflate(width, height)
inflate(width, height)
按指定的量膨胀此 Rectangle。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| width | int | 水平膨胀此 Rectangle 的量。 |
| height | int | 垂直膨胀此 Rectangle 的量。 |
Method: inflate_rect(rect, x, y) [static]
inflate_rect(rect, x, y)
创建并返回指定的 Rectangle 结构的膨胀副本。该副本按指定的量进行膨胀,原始的 Rectangle 结构保持不变。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rect | Rectangle | 用于开始的 Rectangle。此矩形不会被修改。 |
| x | int | 水平膨胀此 Rectangle 的量。 |
| y | int | 垂直膨胀此 Rectangle 的量。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 膨胀后的 Rectangle。 |
Method: intersect(a, b) [static]
intersect(a, b)
返回一个第三个 Rectangle 结构,表示另外两个 Rectangle 结构的交集。如果没有交集,则返回一个空的 Rectangle。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| a | Rectangle | 第一个要相交的矩形。 |
| b | Rectangle | 第二个要相交的矩形。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 表示 a 与 b 交集的 Rectangle。 |
Method: intersect(rect)
intersect(rect)
用自身与指定的 Rectangle 的交集替换此 Rectangle。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rect | Rectangle | 用于求交的 Rectangle。 |
Method: intersect_rects(a, b) [static]
intersect_rects(a, b)
返回一个第三个 Rectangle 结构,表示另外两个 Rectangle 结构的交集。如果没有交集,则返回一个空的 Rectangle。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| a | Rectangle | 第一个要相交的矩形。 |
| b | Rectangle | 第二个要相交的矩形。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 表示 a 与 b 交集的 Rectangle。 |
Method: intersects_with(rect)
intersects_with(rect)
确定此矩形是否与 rect 相交。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rect | Rectangle | 要测试的矩形。 |
Returns
| Type | Description |
|---|---|
| bool | 如果存在任何交集,则此方法返回 true;否则返回 false。 |
Method: offset(pos)
offset(pos)
按指定量调整此矩形的位置。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| pos | Point | 位置的偏移量。 |
Method: offset(x, y)
offset(x, y)
按指定量调整此矩形的位置。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| x | int | 水平偏移量。 |
| y | int | 垂直偏移量。 |
Method: round(value) [static]
round(value)
将指定的 RectangleF 转换为 Rectangle,方法是将 RectangleF 的值四舍五入到最近的整数。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| value | RectangleF | 要转换的 RectangleF。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 一个新的 Rectangle。 |
Method: truncate(value) [static]
truncate(value)
将指定的 RectangleF 转换为 Rectangle,方法是截断 RectangleF 的值。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| value | RectangleF | 要转换的 RectangleF。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 一个新的 Rectangle。 |
Method: union(a, b) [static]
union(a, b)
获取一个包含两个 Rectangle 结构并集的 Rectangle 结构。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| a | Rectangle | 第一个用于合并的矩形。 |
| b | Rectangle | 第二个用于合并的矩形。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 一个 Rectangle 结构,界定两个 Rectangle 结构的并集。 |