@logicflow/core 2.2.0-alpha.7 → 2.2.1
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/package.json +6 -1
- package/.turbo/turbo-build$colon$dev.log +0 -10
- package/.turbo/turbo-build.log +0 -33
- package/CHANGELOG.md +0 -1901
- package/__tests__/algorithm/egde.test.ts +0 -131
- package/__tests__/algorithm/index.test.ts +0 -74
- package/__tests__/algorithm/outline.test.ts +0 -43
- package/__tests__/bugs/1545-spec.test.ts +0 -42
- package/__tests__/event/event.test.ts +0 -22
- package/__tests__/history/history.test.ts +0 -28
- package/__tests__/logicflow.test.ts +0 -575
- package/__tests__/model/graphmodel.test.ts +0 -87
- package/__tests__/util/compatible.test.ts +0 -48
- package/__tests__/util/edge.test.ts +0 -224
- package/__tests__/util/geometry.test.ts +0 -14
- package/__tests__/util/graph.test.ts +0 -16
- package/__tests__/util/matrix.test.ts +0 -41
- package/__tests__/util/node.test.ts +0 -68
- package/__tests__/util/sampling.test.ts +0 -12
- package/__tests__/util/vector.test.ts +0 -50
- package/__tests__/util/zIndex.test.ts +0 -10
- package/src/LogicFlow.tsx +0 -2017
- package/src/algorithm/edge.ts +0 -67
- package/src/algorithm/index.ts +0 -70
- package/src/algorithm/outline.ts +0 -77
- package/src/algorithm/rotate.ts +0 -55
- package/src/common/drag.ts +0 -219
- package/src/common/history.ts +0 -108
- package/src/common/index.ts +0 -6
- package/src/common/keyboard.ts +0 -108
- package/src/common/matrix.ts +0 -122
- package/src/common/vector.ts +0 -93
- package/src/constant/index.ts +0 -179
- package/src/constant/theme.ts +0 -708
- package/src/event/event.md +0 -66
- package/src/event/eventArgs.ts +0 -643
- package/src/event/eventEmitter.ts +0 -156
- package/src/history/index.ts +0 -119
- package/src/index.less +0 -1
- package/src/index.ts +0 -26
- package/src/keyboard/index.ts +0 -112
- package/src/keyboard/shortcut.ts +0 -200
- package/src/model/BaseModel.ts +0 -250
- package/src/model/EditConfigModel.ts +0 -334
- package/src/model/GraphModel.ts +0 -1824
- package/src/model/NestedTransformModel.ts +0 -121
- package/src/model/SnaplineModel.ts +0 -256
- package/src/model/TransformModel.ts +0 -258
- package/src/model/edge/BaseEdgeModel.ts +0 -785
- package/src/model/edge/BezierEdgeModel.ts +0 -197
- package/src/model/edge/LineEdgeModel.ts +0 -36
- package/src/model/edge/PolylineEdgeModel.ts +0 -817
- package/src/model/edge/index.ts +0 -4
- package/src/model/index.ts +0 -9
- package/src/model/node/BaseNodeModel.ts +0 -959
- package/src/model/node/CircleNodeModel.ts +0 -91
- package/src/model/node/DiamondNodeModel.ts +0 -132
- package/src/model/node/EllipseNodeModel.ts +0 -98
- package/src/model/node/HtmlNodeModel.ts +0 -64
- package/src/model/node/PolygonNodeModel.ts +0 -152
- package/src/model/node/RectNodeModel.ts +0 -69
- package/src/model/node/TextNodeModel.ts +0 -54
- package/src/model/node/index.ts +0 -8
- package/src/options.ts +0 -150
- package/src/style/index.less +0 -262
- package/src/style/raw.ts +0 -221
- package/src/tool/MultipleSelectTool.tsx +0 -140
- package/src/tool/TextEditTool.tsx +0 -193
- package/src/tool/index.ts +0 -101
- package/src/typings.d.ts +0 -5
- package/src/util/animation.ts +0 -29
- package/src/util/browser.ts +0 -4
- package/src/util/compatible.ts +0 -15
- package/src/util/drag.ts +0 -219
- package/src/util/edge.ts +0 -1094
- package/src/util/geometry.ts +0 -154
- package/src/util/graph.ts +0 -46
- package/src/util/index.ts +0 -17
- package/src/util/matrix.ts +0 -129
- package/src/util/mobx.ts +0 -23
- package/src/util/node.ts +0 -543
- package/src/util/raf.ts +0 -28
- package/src/util/resize.ts +0 -606
- package/src/util/sampling.ts +0 -85
- package/src/util/theme.ts +0 -84
- package/src/util/uuid.ts +0 -26
- package/src/util/vector.ts +0 -93
- package/src/util/zIndex.ts +0 -6
- package/src/view/Anchor.tsx +0 -462
- package/src/view/Control.tsx +0 -510
- package/src/view/Graph.tsx +0 -141
- package/src/view/Rotate.tsx +0 -113
- package/src/view/behavior/dnd.ts +0 -162
- package/src/view/behavior/index.ts +0 -2
- package/src/view/behavior/snapline.ts +0 -16
- package/src/view/edge/AdjustPoint.tsx +0 -425
- package/src/view/edge/Arrow.tsx +0 -54
- package/src/view/edge/BaseEdge.tsx +0 -660
- package/src/view/edge/BezierEdge.tsx +0 -101
- package/src/view/edge/LineEdge.tsx +0 -81
- package/src/view/edge/PolylineEdge.tsx +0 -311
- package/src/view/edge/index.ts +0 -6
- package/src/view/index.ts +0 -8
- package/src/view/node/BaseNode.tsx +0 -585
- package/src/view/node/CircleNode.tsx +0 -21
- package/src/view/node/DiamondNode.tsx +0 -24
- package/src/view/node/EllipseNode.tsx +0 -22
- package/src/view/node/HtmlNode.tsx +0 -112
- package/src/view/node/PolygonNode.tsx +0 -28
- package/src/view/node/RectNode.tsx +0 -30
- package/src/view/node/TextNode.tsx +0 -39
- package/src/view/node/index.ts +0 -8
- package/src/view/overlay/BackgroundOverlay.tsx +0 -34
- package/src/view/overlay/BezierAdjustOverlay.tsx +0 -150
- package/src/view/overlay/CanvasOverlay.tsx +0 -290
- package/src/view/overlay/Grid.tsx +0 -319
- package/src/view/overlay/ModificationOverlay.tsx +0 -31
- package/src/view/overlay/OutlineOverlay.tsx +0 -158
- package/src/view/overlay/SnaplineOverlay.tsx +0 -44
- package/src/view/overlay/ToolOverlay.tsx +0 -65
- package/src/view/overlay/getTransformHoc.tsx +0 -50
- package/src/view/overlay/gridConfig.ts +0 -103
- package/src/view/overlay/index.ts +0 -8
- package/src/view/shape/Circle.tsx +0 -41
- package/src/view/shape/Ellipse.tsx +0 -42
- package/src/view/shape/Line.tsx +0 -39
- package/src/view/shape/Path.tsx +0 -22
- package/src/view/shape/Polygon.tsx +0 -54
- package/src/view/shape/Polyline.tsx +0 -31
- package/src/view/shape/Rect.tsx +0 -44
- package/src/view/shape/Text.tsx +0 -168
- package/src/view/shape/index.ts +0 -8
- package/src/view/text/BaseText.tsx +0 -134
- package/src/view/text/LineText.tsx +0 -168
- package/src/view/text/index.ts +0 -2
- package/stats.html +0 -4842
- package/tsconfig.json +0 -18
package/src/util/geometry.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import LogicFlow from '../LogicFlow'
|
|
2
|
-
import PointTuple = LogicFlow.PointTuple
|
|
3
|
-
import Point = LogicFlow.Point
|
|
4
|
-
|
|
5
|
-
export function snapToGrid(point: number, gridSize: number, snapGrid: boolean) {
|
|
6
|
-
// 开启节网格对齐时才根据网格尺寸校准坐标
|
|
7
|
-
if (!snapGrid) return point
|
|
8
|
-
// 保证 x, y 的值为 gridSize 的整数倍
|
|
9
|
-
return gridSize * Math.round(point / gridSize) || point
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// 获取节点偏移时,产生的偏移量。当节点基于gridSize进行了偏移后,
|
|
13
|
-
// 节点上的文本可以基于此方法移动对应的距离来保持与节点相对位置不变。
|
|
14
|
-
export function getGridOffset(distance: number, gridSize: number) {
|
|
15
|
-
return distance % gridSize
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 多边形设置 points 后,坐标平移至原点 并 根据 width、height 缩放
|
|
20
|
-
* @param points
|
|
21
|
-
* @param width
|
|
22
|
-
* @param height
|
|
23
|
-
*/
|
|
24
|
-
export function normalizePolygon(
|
|
25
|
-
points?: PointTuple[],
|
|
26
|
-
width?: number,
|
|
27
|
-
height?: number,
|
|
28
|
-
): PointTuple[] {
|
|
29
|
-
if (!points) return []
|
|
30
|
-
|
|
31
|
-
// 计算边界框
|
|
32
|
-
const minX = Math.min(...points.map((p) => p[0]))
|
|
33
|
-
const maxX = Math.max(...points.map((p) => p[0]))
|
|
34
|
-
const minY = Math.min(...points.map((p) => p[1]))
|
|
35
|
-
const maxY = Math.max(...points.map((p) => p[1]))
|
|
36
|
-
|
|
37
|
-
// 平移至原点
|
|
38
|
-
const dx = -minX
|
|
39
|
-
const dy = -minY
|
|
40
|
-
const translatedPoints: PointTuple[] = points.map(([x, y]) => [
|
|
41
|
-
x + dx,
|
|
42
|
-
y + dy,
|
|
43
|
-
])
|
|
44
|
-
|
|
45
|
-
// 计算边界框的宽度和高度
|
|
46
|
-
const bboxWidth = maxX - minX
|
|
47
|
-
const bboxHeight = maxY - minY
|
|
48
|
-
|
|
49
|
-
// 计算缩放因子
|
|
50
|
-
const scaleX = width ? width / bboxWidth : 1
|
|
51
|
-
const scaleY = height ? height / bboxHeight : 1
|
|
52
|
-
const scaleFactor = Math.min(scaleX, scaleY)
|
|
53
|
-
|
|
54
|
-
// 缩放顶点
|
|
55
|
-
return translatedPoints.map(([x, y]) => [x * scaleFactor, y * scaleFactor])
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 通用圆角生成:为菱形、多边形、折线在转折处生成与矩形视觉一致的圆角
|
|
60
|
-
* - 圆角基于角平分线,切点距顶点的距离 t = r * tan(theta/2)
|
|
61
|
-
* - 半径会根据相邻边长度进行钳制,避免超过边长造成断裂
|
|
62
|
-
* - 多边形/菱形保持闭合;折线保持开口
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
export const generateRoundedCorners = (
|
|
66
|
-
points: Point[],
|
|
67
|
-
radius: number,
|
|
68
|
-
isClosedShape: boolean, // 是否是闭合图形
|
|
69
|
-
): Point[] => {
|
|
70
|
-
const n = points.length
|
|
71
|
-
if (n < 2 || radius <= 0) return points.slice()
|
|
72
|
-
|
|
73
|
-
const toVec = (a: Point, b: Point) => ({ x: b.x - a.x, y: b.y - a.y })
|
|
74
|
-
const len = (v: { x: number; y: number }) => Math.hypot(v.x, v.y)
|
|
75
|
-
const norm = (v: { x: number; y: number }) => {
|
|
76
|
-
const l = len(v) || 1
|
|
77
|
-
return { x: v.x / l, y: v.y / l }
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const result: Point[] = []
|
|
81
|
-
|
|
82
|
-
// 用二次贝塞尔近似圆角,控制点取角点,避免复杂圆心计算
|
|
83
|
-
const makeRoundCorner = (prev: Point, curr: Point, next: Point): Point[] => {
|
|
84
|
-
const vPrev = toVec(curr, prev)
|
|
85
|
-
const vNext = toVec(curr, next)
|
|
86
|
-
const dPrev = len(vPrev)
|
|
87
|
-
const dNext = len(vNext)
|
|
88
|
-
if (dPrev < 1e-6 || dNext < 1e-6) return [curr]
|
|
89
|
-
|
|
90
|
-
const uPrev = norm(vPrev)
|
|
91
|
-
const uNext = norm(vNext)
|
|
92
|
-
const t = Math.min(radius, dPrev * 0.45, dNext * 0.45)
|
|
93
|
-
|
|
94
|
-
const start = { x: curr.x + uPrev.x * t, y: curr.y + uPrev.y * t }
|
|
95
|
-
const end = { x: curr.x + uNext.x * t, y: curr.y + uNext.y * t }
|
|
96
|
-
|
|
97
|
-
// 二次贝塞尔采样:B(s) = (1-s)^2*start + 2(1-s)s*curr + s^2*end
|
|
98
|
-
const steps = 10 // 3段近似,简洁且效果稳定
|
|
99
|
-
const pts: Point[] = [start]
|
|
100
|
-
for (let k = 1; k < steps; k++) {
|
|
101
|
-
const s = k / steps
|
|
102
|
-
const a = 1 - s
|
|
103
|
-
pts.push({
|
|
104
|
-
x: a * a * start.x + 2 * a * s * curr.x + s * s * end.x,
|
|
105
|
-
y: a * a * start.y + 2 * a * s * curr.y + s * s * end.y,
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
pts.push(end)
|
|
109
|
-
return pts
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
for (let i = 0; i < n; i++) {
|
|
113
|
-
const prevIdx = i === 0 ? (isClosedShape ? n - 1 : 0) : i - 1
|
|
114
|
-
const nextIdx = i === n - 1 ? (isClosedShape ? 0 : n - 1) : i + 1
|
|
115
|
-
const prev = points[prevIdx]
|
|
116
|
-
const curr = points[i]
|
|
117
|
-
const next = points[nextIdx]
|
|
118
|
-
|
|
119
|
-
const isEndpoint = !isClosedShape && (i === 0 || i === n - 1)
|
|
120
|
-
if (isEndpoint) {
|
|
121
|
-
// 折线两端不处理圆角
|
|
122
|
-
result.push(curr)
|
|
123
|
-
} else {
|
|
124
|
-
const arc = makeRoundCorner(prev, curr, next)
|
|
125
|
-
arc.forEach((p) => result.push(p))
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// 去重处理:避免连续重复点
|
|
130
|
-
const dedup: Point[] = []
|
|
131
|
-
for (let i = 0; i < result.length; i++) {
|
|
132
|
-
const p = result[i]
|
|
133
|
-
if (
|
|
134
|
-
dedup.length === 0 ||
|
|
135
|
-
Math.hypot(
|
|
136
|
-
p.x - dedup[dedup.length - 1].x,
|
|
137
|
-
p.y - dedup[dedup.length - 1].y,
|
|
138
|
-
) > 1e-6
|
|
139
|
-
) {
|
|
140
|
-
dedup.push(p)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// 闭合图形:确保首尾不重复闭合
|
|
145
|
-
if (isClosedShape && dedup.length > 1) {
|
|
146
|
-
const first = dedup[0]
|
|
147
|
-
const last = dedup[dedup.length - 1]
|
|
148
|
-
if (Math.hypot(first.x - last.x, first.y - last.y) < 1e-6) {
|
|
149
|
-
dedup.pop()
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return dedup
|
|
154
|
-
}
|
package/src/util/graph.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import LogicFlow from '..'
|
|
2
|
-
import { EditConfigModel } from '..'
|
|
3
|
-
|
|
4
|
-
import PointTuple = LogicFlow.PointTuple
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 判断一个点是否在指定区域
|
|
8
|
-
* @param point 当前点
|
|
9
|
-
* @param leftTopPoint 区域左上角点
|
|
10
|
-
* @param rightBottomPoint 区域的右下角点
|
|
11
|
-
*/
|
|
12
|
-
export const isPointInArea = (
|
|
13
|
-
[x, y]: PointTuple,
|
|
14
|
-
[leftTopX, leftTopY]: PointTuple,
|
|
15
|
-
[rightBottomX, rightBottomY]: PointTuple,
|
|
16
|
-
): boolean =>
|
|
17
|
-
x > leftTopX && x < rightBottomX && y > leftTopY && y < rightBottomY
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 判断鼠标点击选中元素的时候,是否为多选
|
|
21
|
-
*/
|
|
22
|
-
export const isMultipleSelect = (
|
|
23
|
-
e: MouseEvent,
|
|
24
|
-
editConfigModel: EditConfigModel,
|
|
25
|
-
): boolean => {
|
|
26
|
-
const { multipleSelectKey } = editConfigModel
|
|
27
|
-
let isMultiple = false
|
|
28
|
-
switch (multipleSelectKey) {
|
|
29
|
-
case 'meta':
|
|
30
|
-
isMultiple = e.metaKey
|
|
31
|
-
break
|
|
32
|
-
case 'alt':
|
|
33
|
-
isMultiple = e.altKey
|
|
34
|
-
break
|
|
35
|
-
case 'shift':
|
|
36
|
-
isMultiple = e.shiftKey
|
|
37
|
-
break
|
|
38
|
-
case 'ctrl':
|
|
39
|
-
isMultiple = e.ctrlKey // Mac上ctrl + 点击节点会触发上下文菜单,所以ctrl尽量用在非Mac系统
|
|
40
|
-
break
|
|
41
|
-
default:
|
|
42
|
-
isMultiple = false
|
|
43
|
-
break
|
|
44
|
-
}
|
|
45
|
-
return isMultiple
|
|
46
|
-
}
|
package/src/util/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './animation'
|
|
2
|
-
export * from './browser'
|
|
3
|
-
export * from './compatible'
|
|
4
|
-
export * from './drag'
|
|
5
|
-
export * from './edge'
|
|
6
|
-
export * from './geometry'
|
|
7
|
-
export * from './graph'
|
|
8
|
-
export * from './matrix'
|
|
9
|
-
export * from './mobx'
|
|
10
|
-
export * from './node'
|
|
11
|
-
export * from './raf'
|
|
12
|
-
export * from './resize'
|
|
13
|
-
export * from './sampling'
|
|
14
|
-
export * from './theme'
|
|
15
|
-
export * from './uuid'
|
|
16
|
-
export * from './vector'
|
|
17
|
-
export * from './zIndex'
|
package/src/util/matrix.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { Vector, Point } from './vector'
|
|
2
|
-
|
|
3
|
-
export class Matrix extends Array {
|
|
4
|
-
rows: number
|
|
5
|
-
columns: number
|
|
6
|
-
|
|
7
|
-
constructor(...vectors: any[]) {
|
|
8
|
-
super(vectors.length)
|
|
9
|
-
this.fill(new Array(3))
|
|
10
|
-
vectors.forEach((v: any, index: number) => {
|
|
11
|
-
this[index] = v
|
|
12
|
-
})
|
|
13
|
-
this.columns = vectors[0].length
|
|
14
|
-
this.rows = vectors.length
|
|
15
|
-
Object.setPrototypeOf(this, Matrix.prototype)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
getRow(index: number) {
|
|
19
|
-
return this[index]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getColumn(index: number) {
|
|
23
|
-
return [...this.map((row: Vector) => row[index])]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 转置
|
|
27
|
-
transpose() {
|
|
28
|
-
const vectors: any[] = []
|
|
29
|
-
for (let i = 0; i < this.columns; i++) {
|
|
30
|
-
vectors.push(this.getColumn(i))
|
|
31
|
-
}
|
|
32
|
-
return new Matrix(...vectors)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 叉乘
|
|
36
|
-
cross(m1: Matrix) {
|
|
37
|
-
const arr = new Array(this.rows).fill('').map((): any => [])
|
|
38
|
-
if (this.columns === m1.rows) {
|
|
39
|
-
for (let i = 0; i < this.rows; i++) {
|
|
40
|
-
const row = this.getRow(i)
|
|
41
|
-
for (let j = 0; j < m1.columns; j++) {
|
|
42
|
-
const column = m1.getColumn(j)
|
|
43
|
-
// eslint-disable-next-line max-len
|
|
44
|
-
arr[i][j] = row.reduce(
|
|
45
|
-
(prev: number, r: number, index: number) =>
|
|
46
|
-
prev + r * column[index],
|
|
47
|
-
0,
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return new Matrix(...arr)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 返回二维坐标(降维)
|
|
56
|
-
to2D() {
|
|
57
|
-
return this.map((item: any) => [item[0], item[1]])
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
toPoints() {
|
|
61
|
-
return this.map((item: any) => new Point(item[0], item[1]))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
toString(): string {
|
|
65
|
-
const [a, b] = this[0]
|
|
66
|
-
const [c, d] = this[1]
|
|
67
|
-
const [e, f] = this[2]
|
|
68
|
-
return `matrix(${a} ${b} ${c} ${d} ${e} ${f})`
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
translate(tx: number, ty: number): Matrix {
|
|
72
|
-
return this.cross(new TranslateMatrix(tx, ty))
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
rotate(angle: number): Matrix {
|
|
76
|
-
return this.cross(new RotateMatrix(angle))
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
scale(sx: number, sy: number): Matrix {
|
|
80
|
-
return this.cross(new ScaleMatrix(sx, sy))
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export class RotateMatrix extends Matrix {
|
|
85
|
-
constructor(theta: number) {
|
|
86
|
-
super(
|
|
87
|
-
new Vector(+Math.cos(theta).toFixed(2), +Math.sin(theta).toFixed(2), 0),
|
|
88
|
-
new Vector(-Math.sin(theta).toFixed(2), +Math.cos(theta).toFixed(2), 0),
|
|
89
|
-
new Vector(0, 0, 1),
|
|
90
|
-
)
|
|
91
|
-
Object.setPrototypeOf(this, RotateMatrix.prototype)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
inverse() {
|
|
95
|
-
return this.transpose()
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export class ScaleMatrix extends Matrix {
|
|
100
|
-
private sx: number
|
|
101
|
-
private sy: number
|
|
102
|
-
|
|
103
|
-
constructor(sx: number, sy: number) {
|
|
104
|
-
super(new Vector(sx, 0, 0), new Vector(0, sy, 0), new Vector(0, 0, 1))
|
|
105
|
-
this.sx = sx
|
|
106
|
-
this.sy = sy
|
|
107
|
-
Object.setPrototypeOf(this, ScaleMatrix.prototype)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
inverse() {
|
|
111
|
-
return new ScaleMatrix(1 / this.sx, 1 / this.sy)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export class TranslateMatrix extends Matrix {
|
|
116
|
-
private tx: number
|
|
117
|
-
private ty: number
|
|
118
|
-
|
|
119
|
-
constructor(tx: number, ty: number) {
|
|
120
|
-
super(new Vector(1, 0, 0), new Vector(0, 1, 0), new Vector(tx, ty, 1))
|
|
121
|
-
this.tx = tx
|
|
122
|
-
this.ty = ty
|
|
123
|
-
Object.setPrototypeOf(this, TranslateMatrix.prototype)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
inverse() {
|
|
127
|
-
return new TranslateMatrix(-this.tx, -this.ty)
|
|
128
|
-
}
|
|
129
|
-
}
|
package/src/util/mobx.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
action,
|
|
3
|
-
observable,
|
|
4
|
-
computed,
|
|
5
|
-
toJS,
|
|
6
|
-
isObservable,
|
|
7
|
-
configure,
|
|
8
|
-
reaction,
|
|
9
|
-
IReactionDisposer,
|
|
10
|
-
} from 'mobx'
|
|
11
|
-
|
|
12
|
-
configure({ isolateGlobalState: true })
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
action,
|
|
16
|
-
observable,
|
|
17
|
-
computed,
|
|
18
|
-
isObservable,
|
|
19
|
-
toJS,
|
|
20
|
-
configure,
|
|
21
|
-
reaction,
|
|
22
|
-
IReactionDisposer,
|
|
23
|
-
}
|