Rectangle<T extends num> 类
表示二维矩形属性不可变的类。
过时: 不建议使用 Rectangle。
- 如果您正在使用与
dart:html一起的Rectangle类,我们建议迁移到package:web。要了解如何迁移以及为什么迁移,请参阅迁移指南。 - 如果您想在某个坐标系中存储矩形的边界,请考虑使用 record。根据您如何使用它,这可能看起来像
var boundaries = (mixX: x1, maxX: x2, minY: y1, maxY: y2)。 - 如果您需要执行交集计算或包含检查,请考虑使用专门的库,例如
package:vector_math。 - 如果您正在开发 Flutter 应用程序或包,请考虑使用
dart:ui中的Rect类型。
构造函数
- Rectangle(T left, T top, T width, T height)
- 创建一个由
(left, top)和(left+width, top+height)张开的矩形。const -
Rectangle.fromPoints(Point<
T> a, Point<T> b) - 创建一个由点
a和b张开的矩形;factory
属性
- bottom → T
- 底部边的 y 坐标。无设置器继承
-
bottomLeft → Point<
T> -
无设置器继承
-
bottomRight → Point<
T> -
无设置器继承
- hashCode → int
- 此对象的哈希码。无设置器继承
- height → T
- 矩形的宽度。final
- left → T
- 左边的 x 坐标。final
- right → T
- 右边的 x 坐标。无设置器继承
- runtimeType → Type
- 表示对象的运行时类型。无设置器继承
- top → T
- 顶边的 y 坐标。final
-
topLeft → Point<
T> -
无设置器继承
-
topRight → Point<
T> -
无设置器继承
- width → T
- 矩形的宽度。final
方法
-
boundingBox(
Rectangle< T> other) → Rectangle<T> - 返回一个新的矩形,该矩形完全包含
this和other。继承 -
containsPoint(
Point< num> another) → bool - 测试
another是否在this的内部或边缘上。继承 -
containsRectangle(
Rectangle< num> another) → bool - 测试
this是否完全包含another。继承 -
intersection(
Rectangle< T> other) → Rectangle<T> ? - 计算
this和other的交集。继承 -
intersects(
Rectangle< num> other) → bool - 如果
this与other交叉,则返回 true。继承 -
noSuchMethod(
Invocation invocation) → dynamic - 当访问不存在的方法或属性时被调用。继承
-
toString(
) → String - 该对象的字符串表示形式。继承
运算符
-
operator ==(
Object other) → bool - 相等运算符。继承