@fulate/share 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  - 点:`PointView`、`MutablePointView`、`createPointView()`、`transformPoint()`、距离判断;
6
6
  - 矩形:`Rect`、`BoundingBox`、可变 `Bound` 及 points/rects 边界计算;
7
- - 矩阵和数学:`qrDecompose()`、角度/弧度换算、矩形边缘位置;
7
+ - 矩阵和数学:`isIdentityMatrix()`、`qrDecompose()`、角度/弧度换算、矩形边缘位置;
8
8
  - 几何:`Intersection`、`clipPolygonToRect()`;
9
9
  - 颜色和渐变:颜色解析/格式化、alpha 合成、混色和 Canvas gradient 创建。
10
10
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { transformPoint, createPointView, isPointWithinDistance } from "./point";
2
2
  export type { MutablePointView, PointView } from "./point";
3
- export { Bound, makeBoundingBoxFromPoints, makeBoundsFromPoints, makeBoundingBoxFromRects } from "./rect";
3
+ export { Bound, makeBoundingBoxFromRects } from "./rect";
4
4
  export type { Rect, RectWithCenter, BoundingBox } from "./rect";
5
- export { qrDecompose } from "./matrix";
5
+ export { isIdentityMatrix, qrDecompose } from "./matrix";
6
6
  export { degreesToRadians, radiansToDegrees, rectEdgePosition } from "./math";
7
7
  export type { Edge } from "./math";
8
8
  export { Intersection, clipPolygonToRect } from "./Intersection";
package/dist/index.js CHANGED
@@ -39,15 +39,6 @@ function pointBounds(points) {
39
39
  maxY
40
40
  };
41
41
  }
42
- function makeBoundingBoxFromPoints(points) {
43
- const { minX, minY, maxX, maxY } = pointBounds(points);
44
- return {
45
- left: minX,
46
- top: minY,
47
- width: maxX - minX,
48
- height: maxY - minY
49
- };
50
- }
51
42
  var Bound = class Bound {
52
43
  minX;
53
44
  minY;
@@ -118,9 +109,6 @@ var Bound = class Bound {
118
109
  return new Bound(minX, minY, maxX, maxY);
119
110
  }
120
111
  };
121
- function makeBoundsFromPoints(points) {
122
- return pointBounds(points);
123
- }
124
112
  function makeBoundingBoxFromRects(rects) {
125
113
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
126
114
  for (let i = 0; i < rects.length; i++) {
@@ -176,6 +164,9 @@ function rectEdgePosition(w, h, edge, ratio) {
176
164
  }
177
165
  //#endregion
178
166
  //#region packages/share/src/matrix.ts
167
+ function isIdentityMatrix(matrix) {
168
+ return matrix.a === 1 && matrix.b === 0 && matrix.c === 0 && matrix.d === 1 && matrix.e === 0 && matrix.f === 0;
169
+ }
179
170
  function qrDecompose(matrix) {
180
171
  const { a, b, c, d } = matrix;
181
172
  const angleRad = Math.atan2(b, a);
@@ -462,4 +453,4 @@ function createCanvasGradient(ctx, gradient, width, height) {
462
453
  return result;
463
454
  }
464
455
  //#endregion
465
- export { Bound, Intersection, blendColor, clipPolygonToRect, colorWithAlpha, createCanvasGradient, createPointView, degreesToRadians, formatColor, formatPremultipliedColor, isGradient, isPointWithinDistance, makeBoundingBoxFromPoints, makeBoundingBoxFromRects, makeBoundsFromPoints, parseColor, parsePremultipliedColor, qrDecompose, radiansToDegrees, rectEdgePosition, transformPoint };
456
+ export { Bound, Intersection, blendColor, clipPolygonToRect, colorWithAlpha, createCanvasGradient, createPointView, degreesToRadians, formatColor, formatPremultipliedColor, isGradient, isIdentityMatrix, isPointWithinDistance, makeBoundingBoxFromRects, parseColor, parsePremultipliedColor, qrDecompose, radiansToDegrees, rectEdgePosition, transformPoint };
package/dist/matrix.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare function isIdentityMatrix(matrix: DOMMatrixReadOnly): boolean;
1
2
  export declare function qrDecompose(matrix: DOMMatrixReadOnly): {
2
3
  angle: number;
3
4
  scaleX: number;
package/dist/rect.d.ts CHANGED
@@ -15,7 +15,6 @@ export interface BoundingBox {
15
15
  maxX: number;
16
16
  maxY: number;
17
17
  }
18
- export declare function makeBoundingBoxFromPoints(points: readonly PointView[]): Rect;
19
18
  export declare class Bound implements RectWithCenter {
20
19
  minX: number;
21
20
  minY: number;
@@ -34,5 +33,4 @@ export declare class Bound implements RectWithCenter {
34
33
  includePoint(x: number, y: number, padding?: number): this;
35
34
  static fromPoints(points: readonly PointView[]): Bound;
36
35
  }
37
- export declare function makeBoundsFromPoints(points: readonly PointView[]): BoundingBox;
38
36
  export declare function makeBoundingBoxFromRects(rects: readonly Rect[]): Rect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fulate/share",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",