Point<T extends num> 类
表示二维位置的实用类。
示例
var leftTop = const Point(0, 0);
var rightBottom = const Point(200, 400);
遗留:不建议使用Point。
- 如果您正在使用
Point类与dart:html,我们建议迁移到package:web。要了解如何以及为何迁移,请参阅迁移指南。 - 如果您想合并一个
x和y坐标,请考虑使用一个记录。根据您如何使用它,这可能看起来像var point = (x, y)或var point = (x: x, y: y)。 - 如果您想执行矢量运算,例如矢量加法或标量乘法,请考虑使用专门的矢量数学库,例如
package:vector_math。 - 如果您正在开发Flutter应用程序或包,请考虑使用
dart:ui中的Offset类型。
构造函数
- Point(T x, T y)
- 创建一个具有提供的
x和y坐标的点。const
属性
方法
-
distanceTo(
Point< ) → doubleT> other - 返回
this和other之间的距离。 -
noSuchMethod(
Invocation invocation ) → dynamic - 当访问不存在的方法或属性时调用。inherited
-
squaredDistanceTo(
Point< ) → TT> other - 返回
this和other之间的平方距离。 -
toString(
) → String - 此对象的字符串表示形式。override
操作符
-
operator *(
num factor) → Point< T> - 按
factor缩放此点,仿佛它是一个向量。 -
operator +(
Point< T> other) → Point<T> - 将
other加到this上,仿佛两个点都是向量。 -
operator -(
Point< T> other) → Point<T> - 从
this减去other,仿佛两个点都是向量。 -
operator ==(
Object other) → bool - 判断
other是否与该点具有相同坐标的点。override