@fulate/share
v1.0.15
Published
`@fulate/share` 是 Fulate 最底层的无场景工具包,提供点、矩形、矩阵、颜色、渐变和相交计算。
Readme
@fulate/share
@fulate/share 是 Fulate 最底层的无场景工具包,提供点、矩形、矩阵、颜色、渐变和相交计算。
- 点:
PointView、MutablePointView、createPointView()、transformPoint()、距离判断; - 矩形:
Rect、BoundingBox、可变Bound及 points/rects 边界计算; - 矩阵和数学:Fulate 唯一的 2D 仿射矩阵
Matrix2D/ReadonlyMatrix2D、qrDecompose()、 角度/弧度换算、矩形边缘位置; - 几何:
Intersection、clipPolygonToRect(); - 颜色和渐变:颜色解析/格式化、alpha 合成、混色和 Canvas gradient 创建。
import {
Bound,
createPointView,
transformPoint,
colorWithAlpha
} from "@fulate/share";
const point = transformPoint(matrix, createPointView(10, 20));
const bounds = Bound.fromPoints([point]);
const overlay = colorWithAlpha("#6750a4", 0.12);函数直接消费声明类型,不为 Core/UI 建立 DTO、registry 或缓存。返回可变 Bound 的方法按普通对象
语义工作;调用方需要独立结果时使用明确的 copy() 或在自身 owner 内创建新值。