@idraw/core 0.4.0-beta.4 → 0.4.0-beta.41
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/dist/esm/board/index.d.ts +44 -0
- package/dist/esm/board/index.js +358 -0
- package/dist/esm/board/sharer.d.ts +21 -0
- package/dist/esm/board/sharer.js +101 -0
- package/dist/esm/board/viewer.d.ts +32 -0
- package/dist/esm/board/viewer.js +165 -0
- package/dist/esm/board/watcher.d.ts +15 -0
- package/dist/esm/board/watcher.js +218 -0
- package/dist/esm/config.d.ts +28 -0
- package/dist/esm/config.js +34 -0
- package/dist/esm/index.d.ts +37 -8
- package/dist/esm/index.js +265 -10
- package/dist/esm/lib/cursor-image.d.ts +1 -0
- package/dist/esm/lib/cursor-image.js +1 -0
- package/dist/esm/lib/cursor.d.ts +3 -12
- package/dist/esm/lib/cursor.js +137 -112
- package/dist/esm/middleware/dragger/index.d.ts +2 -2
- package/dist/esm/middleware/dragger/index.js +5 -3
- package/dist/esm/middleware/info/config.d.ts +5 -0
- package/dist/esm/middleware/info/config.js +9 -0
- package/dist/esm/middleware/info/draw-info.d.ts +29 -0
- package/dist/esm/middleware/info/draw-info.js +113 -0
- package/dist/esm/middleware/info/index.d.ts +9 -0
- package/dist/esm/middleware/info/index.js +131 -0
- package/dist/esm/middleware/info/types.d.ts +3 -0
- package/dist/esm/middleware/info/types.js +1 -0
- package/dist/esm/middleware/layout-selector/config.d.ts +11 -0
- package/dist/esm/middleware/layout-selector/config.js +12 -0
- package/dist/esm/middleware/layout-selector/index.d.ts +5 -0
- package/dist/esm/middleware/layout-selector/index.js +371 -0
- package/dist/esm/middleware/layout-selector/types.d.ts +17 -0
- package/dist/esm/middleware/layout-selector/types.js +2 -0
- package/dist/esm/middleware/layout-selector/util.d.ts +9 -0
- package/dist/esm/middleware/layout-selector/util.js +78 -0
- package/dist/esm/middleware/pointer/index.d.ts +3 -0
- package/dist/esm/middleware/pointer/index.js +42 -0
- package/dist/esm/middleware/pointer/types.d.ts +3 -0
- package/dist/esm/middleware/pointer/types.js +1 -0
- package/dist/esm/middleware/ruler/config.d.ts +7 -0
- package/dist/esm/middleware/ruler/config.js +21 -0
- package/dist/esm/middleware/ruler/index.d.ts +3 -3
- package/dist/esm/middleware/ruler/index.js +33 -14
- package/dist/esm/middleware/ruler/types.d.ts +3 -0
- package/dist/esm/middleware/ruler/types.js +1 -0
- package/dist/esm/middleware/ruler/util.d.ts +20 -4
- package/dist/esm/middleware/ruler/util.js +99 -26
- package/dist/esm/middleware/scaler/index.d.ts +2 -3
- package/dist/esm/middleware/scaler/index.js +3 -2
- package/dist/esm/middleware/scroller/config.d.ts +4 -0
- package/dist/esm/middleware/scroller/config.js +10 -0
- package/dist/esm/middleware/scroller/index.d.ts +3 -2
- package/dist/esm/middleware/scroller/index.js +48 -6
- package/dist/esm/middleware/scroller/types.d.ts +11 -0
- package/dist/esm/middleware/scroller/types.js +1 -0
- package/dist/esm/middleware/scroller/util.d.ts +3 -2
- package/dist/esm/middleware/scroller/util.js +33 -44
- package/dist/esm/middleware/selector/config.d.ts +9 -1
- package/dist/esm/middleware/selector/config.js +17 -1
- package/dist/esm/middleware/selector/draw-auxiliary.d.ts +1 -0
- package/dist/esm/middleware/selector/draw-auxiliary.js +12 -0
- package/dist/esm/middleware/selector/draw-base.d.ts +30 -0
- package/dist/esm/middleware/selector/draw-base.js +100 -0
- package/dist/esm/middleware/selector/draw-debug.d.ts +5 -0
- package/dist/esm/middleware/selector/draw-debug.js +30 -0
- package/dist/esm/middleware/selector/draw-reference.d.ts +7 -0
- package/dist/esm/middleware/selector/draw-reference.js +31 -0
- package/dist/esm/middleware/selector/draw-wrapper.d.ts +16 -1
- package/dist/esm/middleware/selector/draw-wrapper.js +70 -38
- package/dist/esm/middleware/selector/index.d.ts +11 -4
- package/dist/esm/middleware/selector/index.js +450 -70
- package/dist/esm/middleware/selector/pattern/icon-rotate.d.ts +4 -0
- package/dist/esm/middleware/selector/pattern/icon-rotate.js +88 -0
- package/dist/esm/middleware/selector/pattern/index.d.ts +8 -0
- package/dist/esm/middleware/selector/pattern/index.js +38 -0
- package/dist/esm/middleware/selector/reference.d.ts +13 -0
- package/dist/esm/middleware/selector/reference.js +267 -0
- package/dist/esm/middleware/selector/types.d.ts +11 -5
- package/dist/esm/middleware/selector/types.js +2 -1
- package/dist/esm/middleware/selector/util.d.ts +14 -7
- package/dist/esm/middleware/selector/util.js +45 -43
- package/dist/esm/middleware/text-editor/index.d.ts +20 -3
- package/dist/esm/middleware/text-editor/index.js +168 -28
- package/dist/esm/record.d.ts +5 -0
- package/dist/esm/record.js +38 -0
- package/dist/index.global.js +5729 -1519
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -6
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function getViewBoxInfo(rectInfo) {
|
|
2
|
+
const boxInfo = {
|
|
3
|
+
minX: rectInfo.topLeft.x,
|
|
4
|
+
minY: rectInfo.topLeft.y,
|
|
5
|
+
maxX: rectInfo.bottomRight.x,
|
|
6
|
+
maxY: rectInfo.bottomRight.y,
|
|
7
|
+
midX: rectInfo.center.x,
|
|
8
|
+
midY: rectInfo.center.y
|
|
9
|
+
};
|
|
10
|
+
return boxInfo;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PointSize, ViewContext2D, ViewRectVertexes } from '@idraw/types';
|
|
2
|
+
export declare function drawVertexes(ctx: ViewContext2D, vertexes: ViewRectVertexes, opts: {
|
|
3
|
+
borderColor: string;
|
|
4
|
+
borderWidth: number;
|
|
5
|
+
background: string;
|
|
6
|
+
lineDash: number[];
|
|
7
|
+
}): void;
|
|
8
|
+
export declare function drawLine(ctx: ViewContext2D, start: PointSize, end: PointSize, opts: {
|
|
9
|
+
borderColor: string;
|
|
10
|
+
borderWidth: number;
|
|
11
|
+
lineDash: number[];
|
|
12
|
+
}): void;
|
|
13
|
+
export declare function drawCircleController(ctx: ViewContext2D, circleCenter: PointSize, opts: {
|
|
14
|
+
borderColor: string;
|
|
15
|
+
borderWidth: number;
|
|
16
|
+
background: string;
|
|
17
|
+
lineDash: number[];
|
|
18
|
+
size: number;
|
|
19
|
+
}): void;
|
|
20
|
+
export declare function drawCrossVertexes(ctx: ViewContext2D, vertexes: ViewRectVertexes, opts: {
|
|
21
|
+
borderColor: string;
|
|
22
|
+
borderWidth: number;
|
|
23
|
+
lineDash: number[];
|
|
24
|
+
}): void;
|
|
25
|
+
export declare function drawCrossByCenter(ctx: ViewContext2D, center: PointSize, opts: {
|
|
26
|
+
size: number;
|
|
27
|
+
borderColor: string;
|
|
28
|
+
borderWidth: number;
|
|
29
|
+
lineDash: number[];
|
|
30
|
+
}): void;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export function drawVertexes(ctx, vertexes, opts) {
|
|
2
|
+
const { borderColor, borderWidth, background, lineDash } = opts;
|
|
3
|
+
ctx.setLineDash([]);
|
|
4
|
+
ctx.lineWidth = borderWidth;
|
|
5
|
+
ctx.strokeStyle = borderColor;
|
|
6
|
+
ctx.fillStyle = background;
|
|
7
|
+
ctx.setLineDash(lineDash);
|
|
8
|
+
ctx.beginPath();
|
|
9
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
10
|
+
ctx.lineTo(vertexes[1].x, vertexes[1].y);
|
|
11
|
+
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
12
|
+
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
13
|
+
ctx.lineTo(vertexes[0].x, vertexes[0].y);
|
|
14
|
+
ctx.closePath();
|
|
15
|
+
ctx.stroke();
|
|
16
|
+
ctx.fill('nonzero');
|
|
17
|
+
}
|
|
18
|
+
export function drawLine(ctx, start, end, opts) {
|
|
19
|
+
const { borderColor, borderWidth, lineDash } = opts;
|
|
20
|
+
ctx.setLineDash([]);
|
|
21
|
+
ctx.lineWidth = borderWidth;
|
|
22
|
+
ctx.strokeStyle = borderColor;
|
|
23
|
+
ctx.setLineDash(lineDash);
|
|
24
|
+
ctx.beginPath();
|
|
25
|
+
ctx.moveTo(start.x, start.y);
|
|
26
|
+
ctx.lineTo(end.x, end.y);
|
|
27
|
+
ctx.closePath();
|
|
28
|
+
ctx.stroke();
|
|
29
|
+
}
|
|
30
|
+
export function drawCircleController(ctx, circleCenter, opts) {
|
|
31
|
+
const { size, borderColor, borderWidth, background } = opts;
|
|
32
|
+
const center = circleCenter;
|
|
33
|
+
const r = size / 2;
|
|
34
|
+
const a = r;
|
|
35
|
+
const b = r;
|
|
36
|
+
if (a >= 0 && b >= 0) {
|
|
37
|
+
if (typeof borderWidth === 'number' && borderWidth > 0) {
|
|
38
|
+
const ba = borderWidth / 2 + a;
|
|
39
|
+
const bb = borderWidth / 2 + b;
|
|
40
|
+
ctx.beginPath();
|
|
41
|
+
ctx.strokeStyle = borderColor;
|
|
42
|
+
ctx.lineWidth = borderWidth;
|
|
43
|
+
ctx.circle(center.x, center.y, ba, bb, 0, 0, 2 * Math.PI);
|
|
44
|
+
ctx.closePath();
|
|
45
|
+
ctx.stroke();
|
|
46
|
+
}
|
|
47
|
+
ctx.beginPath();
|
|
48
|
+
ctx.fillStyle = background;
|
|
49
|
+
ctx.circle(center.x, center.y, a, b, 0, 0, 2 * Math.PI);
|
|
50
|
+
ctx.closePath();
|
|
51
|
+
ctx.fill('nonzero');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function drawCrossVertexes(ctx, vertexes, opts) {
|
|
55
|
+
const { borderColor, borderWidth, lineDash } = opts;
|
|
56
|
+
ctx.setLineDash([]);
|
|
57
|
+
ctx.lineWidth = borderWidth;
|
|
58
|
+
ctx.strokeStyle = borderColor;
|
|
59
|
+
ctx.setLineDash(lineDash);
|
|
60
|
+
ctx.beginPath();
|
|
61
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
62
|
+
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
63
|
+
ctx.closePath();
|
|
64
|
+
ctx.stroke();
|
|
65
|
+
ctx.beginPath();
|
|
66
|
+
ctx.moveTo(vertexes[1].x, vertexes[1].y);
|
|
67
|
+
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
68
|
+
ctx.closePath();
|
|
69
|
+
ctx.stroke();
|
|
70
|
+
}
|
|
71
|
+
export function drawCrossByCenter(ctx, center, opts) {
|
|
72
|
+
const { size, borderColor, borderWidth, lineDash } = opts;
|
|
73
|
+
const minX = center.x - size / 2;
|
|
74
|
+
const maxX = center.x + size / 2;
|
|
75
|
+
const minY = center.y - size / 2;
|
|
76
|
+
const maxY = center.y + size / 2;
|
|
77
|
+
const vertexes = [
|
|
78
|
+
{
|
|
79
|
+
x: minX,
|
|
80
|
+
y: minY
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
x: maxX,
|
|
84
|
+
y: minY
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
x: maxX,
|
|
88
|
+
y: maxY
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
x: minX,
|
|
92
|
+
y: maxY
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
drawCrossVertexes(ctx, vertexes, {
|
|
96
|
+
borderColor,
|
|
97
|
+
borderWidth,
|
|
98
|
+
lineDash
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ElementSizeController, ViewContext2D, ViewSizeInfo, ViewScaleInfo } from '@idraw/types';
|
|
2
|
+
export declare function drawDebugStoreSelectedElementController(ctx: ViewContext2D, controller: ElementSizeController | null, opts: {
|
|
3
|
+
viewSizeInfo: ViewSizeInfo;
|
|
4
|
+
viewScaleInfo: ViewScaleInfo;
|
|
5
|
+
}): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { calcViewPointSize } from '@idraw/util';
|
|
2
|
+
function drawDebugControllerVertexes(opts) {
|
|
3
|
+
const { ctx, viewScaleInfo, vertexes } = opts;
|
|
4
|
+
const v0 = calcViewPointSize(vertexes[0], { viewScaleInfo });
|
|
5
|
+
const v1 = calcViewPointSize(vertexes[1], { viewScaleInfo });
|
|
6
|
+
const v2 = calcViewPointSize(vertexes[2], { viewScaleInfo });
|
|
7
|
+
const v3 = calcViewPointSize(vertexes[3], { viewScaleInfo });
|
|
8
|
+
ctx.beginPath();
|
|
9
|
+
ctx.fillStyle = '#FF0000A1';
|
|
10
|
+
ctx.moveTo(v0.x, v0.y);
|
|
11
|
+
ctx.lineTo(v1.x, v1.y);
|
|
12
|
+
ctx.lineTo(v2.x, v2.y);
|
|
13
|
+
ctx.lineTo(v3.x, v3.y);
|
|
14
|
+
ctx.lineTo(v0.x, v0.y);
|
|
15
|
+
ctx.closePath();
|
|
16
|
+
ctx.fill('nonzero');
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
export function drawDebugStoreSelectedElementController(ctx, controller, opts) {
|
|
20
|
+
if (!controller) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const { viewSizeInfo, viewScaleInfo } = opts;
|
|
24
|
+
const { left, right, top, bottom, topLeft, topRight, bottomLeft, bottomRight, rotate } = controller;
|
|
25
|
+
const ctrls = [left, right, top, bottom, topLeft, topRight, bottomLeft, bottomRight, rotate];
|
|
26
|
+
for (let i = 0; i < ctrls.length; i++) {
|
|
27
|
+
const ctrl = ctrls[i];
|
|
28
|
+
drawDebugControllerVertexes({ ctx, vertexes: ctrl.vertexes, viewSizeInfo, viewScaleInfo });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ViewContext2D, PointSize } from '@idraw/types';
|
|
2
|
+
import { MiddlewareSelectorStyle } from './types';
|
|
3
|
+
export declare function drawReferenceLines(ctx: ViewContext2D, opts: {
|
|
4
|
+
xLines?: Array<PointSize[]>;
|
|
5
|
+
yLines?: Array<PointSize[]>;
|
|
6
|
+
style: MiddlewareSelectorStyle;
|
|
7
|
+
}): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { drawLine, drawCrossByCenter } from './draw-base';
|
|
2
|
+
export function drawReferenceLines(ctx, opts) {
|
|
3
|
+
const { xLines, yLines, style } = opts;
|
|
4
|
+
const { referenceColor } = style;
|
|
5
|
+
const lineOpts = {
|
|
6
|
+
borderColor: referenceColor,
|
|
7
|
+
borderWidth: 1,
|
|
8
|
+
lineDash: []
|
|
9
|
+
};
|
|
10
|
+
const crossOpts = Object.assign(Object.assign({}, lineOpts), { size: 6 });
|
|
11
|
+
if (xLines) {
|
|
12
|
+
xLines.forEach((line) => {
|
|
13
|
+
line.forEach((p, pIdx) => {
|
|
14
|
+
drawCrossByCenter(ctx, p, crossOpts);
|
|
15
|
+
if (line[pIdx + 1]) {
|
|
16
|
+
drawLine(ctx, line[pIdx], line[pIdx + 1], lineOpts);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (yLines) {
|
|
22
|
+
yLines.forEach((line) => {
|
|
23
|
+
line.forEach((p, pIdx) => {
|
|
24
|
+
drawCrossByCenter(ctx, p, crossOpts);
|
|
25
|
+
if (line[pIdx + 1]) {
|
|
26
|
+
drawLine(ctx, line[pIdx], line[pIdx + 1], lineOpts);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,22 +1,37 @@
|
|
|
1
|
-
import type { Element, ElementType, PointSize, RendererDrawElementOptions, ViewContext2D, ViewRectVertexes, ViewScaleInfo, ViewSizeInfo, ElementSizeController } from '@idraw/types';
|
|
1
|
+
import type { Element, ElementType, PointSize, RendererDrawElementOptions, ViewContext2D, ViewRectVertexes, ViewScaleInfo, ViewSizeInfo, ElementSizeController, ViewCalculator, MiddlewareSelectorStyle } from '@idraw/types';
|
|
2
2
|
import type { AreaSize } from './types';
|
|
3
3
|
export declare function drawHoverVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {
|
|
4
4
|
viewScaleInfo: ViewScaleInfo;
|
|
5
5
|
viewSizeInfo: ViewSizeInfo;
|
|
6
|
+
style: MiddlewareSelectorStyle;
|
|
7
|
+
}): void;
|
|
8
|
+
export declare function drawLockedVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {
|
|
9
|
+
viewScaleInfo: ViewScaleInfo;
|
|
10
|
+
viewSizeInfo: ViewSizeInfo;
|
|
11
|
+
controller?: ElementSizeController | null;
|
|
12
|
+
style: MiddlewareSelectorStyle;
|
|
6
13
|
}): void;
|
|
7
14
|
export declare function drawSelectedElementControllersVertexes(ctx: ViewContext2D, controller: ElementSizeController | null, opts: {
|
|
15
|
+
hideControllers: boolean;
|
|
8
16
|
viewScaleInfo: ViewScaleInfo;
|
|
9
17
|
viewSizeInfo: ViewSizeInfo;
|
|
18
|
+
element: Element | null;
|
|
19
|
+
calculator: ViewCalculator;
|
|
20
|
+
style: MiddlewareSelectorStyle;
|
|
21
|
+
rotateControllerPattern: ViewContext2D;
|
|
10
22
|
}): void;
|
|
11
23
|
export declare function drawElementListShadows(ctx: ViewContext2D, elements: Element<ElementType>[], opts?: Omit<RendererDrawElementOptions, 'loader'>): void;
|
|
12
24
|
export declare function drawArea(ctx: ViewContext2D, opts: {
|
|
13
25
|
start: PointSize;
|
|
14
26
|
end: PointSize;
|
|
27
|
+
style: MiddlewareSelectorStyle;
|
|
15
28
|
}): void;
|
|
16
29
|
export declare function drawListArea(ctx: ViewContext2D, opts: {
|
|
17
30
|
areaSize: AreaSize;
|
|
31
|
+
style: MiddlewareSelectorStyle;
|
|
18
32
|
}): void;
|
|
19
33
|
export declare function drawGroupQueueVertexesWrappers(ctx: ViewContext2D, vertexesList: ViewRectVertexes[], opts: {
|
|
20
34
|
viewScaleInfo: ViewScaleInfo;
|
|
21
35
|
viewSizeInfo: ViewSizeInfo;
|
|
36
|
+
style: MiddlewareSelectorStyle;
|
|
22
37
|
}): void;
|
|
@@ -1,49 +1,72 @@
|
|
|
1
|
-
import { rotateElementVertexes, calcViewVertexes } from '@idraw/util';
|
|
2
|
-
import { resizeControllerBorderWidth, areaBorderWidth,
|
|
3
|
-
|
|
4
|
-
const { borderColor, borderWidth, background, lineDash } = opts;
|
|
5
|
-
ctx.setLineDash([]);
|
|
6
|
-
ctx.lineWidth = borderWidth;
|
|
7
|
-
ctx.strokeStyle = borderColor;
|
|
8
|
-
ctx.fillStyle = background;
|
|
9
|
-
ctx.setLineDash(lineDash);
|
|
10
|
-
ctx.beginPath();
|
|
11
|
-
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
12
|
-
ctx.lineTo(vertexes[1].x, vertexes[1].y);
|
|
13
|
-
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
14
|
-
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
15
|
-
ctx.lineTo(vertexes[0].x, vertexes[0].y);
|
|
16
|
-
ctx.closePath();
|
|
17
|
-
ctx.stroke();
|
|
18
|
-
ctx.fill();
|
|
19
|
-
}
|
|
1
|
+
import { rotateElementVertexes, calcViewPointSize, calcViewVertexes, calcViewElementSize } from '@idraw/util';
|
|
2
|
+
import { resizeControllerBorderWidth, areaBorderWidth, selectWrapperBorderWidth } from './config';
|
|
3
|
+
import { drawVertexes, drawCircleController, drawCrossVertexes } from './draw-base';
|
|
20
4
|
export function drawHoverVertexesWrapper(ctx, vertexes, opts) {
|
|
21
5
|
if (!vertexes) {
|
|
22
6
|
return;
|
|
23
7
|
}
|
|
24
|
-
const
|
|
8
|
+
const { style } = opts;
|
|
9
|
+
const { activeColor } = style;
|
|
10
|
+
const wrapperOpts = { borderColor: activeColor, borderWidth: 1, background: 'transparent', lineDash: [] };
|
|
25
11
|
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
26
12
|
}
|
|
13
|
+
export function drawLockedVertexesWrapper(ctx, vertexes, opts) {
|
|
14
|
+
if (!vertexes) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const { style } = opts;
|
|
18
|
+
const { lockedColor } = style;
|
|
19
|
+
const wrapperOpts = { borderColor: lockedColor, borderWidth: 1, background: 'transparent', lineDash: [] };
|
|
20
|
+
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
21
|
+
const { controller } = opts;
|
|
22
|
+
if (controller) {
|
|
23
|
+
const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, bottomMiddle, leftMiddle, rightMiddle } = controller;
|
|
24
|
+
const ctrlOpts = Object.assign(Object.assign({}, wrapperOpts), { borderWidth: 1, background: lockedColor });
|
|
25
|
+
drawCrossVertexes(ctx, calcViewVertexes(topMiddle.vertexes, opts), ctrlOpts);
|
|
26
|
+
drawCrossVertexes(ctx, calcViewVertexes(bottomMiddle.vertexes, opts), ctrlOpts);
|
|
27
|
+
drawCrossVertexes(ctx, calcViewVertexes(leftMiddle.vertexes, opts), ctrlOpts);
|
|
28
|
+
drawCrossVertexes(ctx, calcViewVertexes(rightMiddle.vertexes, opts), ctrlOpts);
|
|
29
|
+
drawCrossVertexes(ctx, calcViewVertexes(topLeft.vertexes, opts), ctrlOpts);
|
|
30
|
+
drawCrossVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
|
|
31
|
+
drawCrossVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
|
|
32
|
+
drawCrossVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
27
35
|
export function drawSelectedElementControllersVertexes(ctx, controller, opts) {
|
|
36
|
+
var _a;
|
|
28
37
|
if (!controller) {
|
|
29
38
|
return;
|
|
30
39
|
}
|
|
31
|
-
const {
|
|
32
|
-
const
|
|
40
|
+
const { hideControllers, style, rotateControllerPattern, viewSizeInfo, element } = opts;
|
|
41
|
+
const { devicePixelRatio = 1 } = viewSizeInfo;
|
|
42
|
+
const { activeColor } = style;
|
|
43
|
+
const { elementWrapper, topLeft, topRight, bottomLeft, bottomRight, rotate } = controller;
|
|
44
|
+
const wrapperOpts = {
|
|
45
|
+
borderColor: activeColor,
|
|
46
|
+
borderWidth: selectWrapperBorderWidth,
|
|
47
|
+
background: 'transparent',
|
|
48
|
+
lineDash: []
|
|
49
|
+
};
|
|
33
50
|
const ctrlOpts = Object.assign(Object.assign({}, wrapperOpts), { borderWidth: resizeControllerBorderWidth, background: '#FFFFFF' });
|
|
34
51
|
drawVertexes(ctx, calcViewVertexes(elementWrapper, opts), wrapperOpts);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
if (!hideControllers) {
|
|
53
|
+
drawVertexes(ctx, calcViewVertexes(topLeft.vertexes, opts), ctrlOpts);
|
|
54
|
+
drawVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
|
|
55
|
+
drawVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
|
|
56
|
+
drawVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
|
|
57
|
+
if (((_a = element === null || element === void 0 ? void 0 : element.operations) === null || _a === void 0 ? void 0 : _a.rotatable) !== false) {
|
|
58
|
+
drawCircleController(ctx, calcViewPointSize(rotate.center, opts), Object.assign(Object.assign({}, ctrlOpts), { size: rotate.size, borderWidth: 0 }));
|
|
59
|
+
const rotateCenter = calcViewPointSize(rotate.center, opts);
|
|
60
|
+
ctx.drawImage(rotateControllerPattern.canvas, 0, 0, rotateControllerPattern.canvas.width / devicePixelRatio, rotateControllerPattern.canvas.height / devicePixelRatio, rotateCenter.x - rotate.size / 2, rotateCenter.y - rotate.size / 2, rotate.size, rotate.size);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
39
63
|
}
|
|
40
64
|
export function drawElementListShadows(ctx, elements, opts) {
|
|
41
65
|
elements.forEach((elem) => {
|
|
42
66
|
let { x, y, w, h } = elem;
|
|
43
67
|
const { angle = 0 } = elem;
|
|
44
68
|
if (opts === null || opts === void 0 ? void 0 : opts.calculator) {
|
|
45
|
-
const {
|
|
46
|
-
const size = calculator.elementSize({ x, y, w, h }, opts.viewScaleInfo, opts.viewSizeInfo);
|
|
69
|
+
const size = calcViewElementSize({ x, y, w, h }, opts);
|
|
47
70
|
x = size.x;
|
|
48
71
|
y = size.y;
|
|
49
72
|
w = size.w;
|
|
@@ -63,16 +86,17 @@ export function drawElementListShadows(ctx, elements, opts) {
|
|
|
63
86
|
}
|
|
64
87
|
ctx.closePath();
|
|
65
88
|
ctx.stroke();
|
|
66
|
-
ctx.fill();
|
|
89
|
+
ctx.fill('nonzero');
|
|
67
90
|
}
|
|
68
91
|
});
|
|
69
92
|
}
|
|
70
93
|
export function drawArea(ctx, opts) {
|
|
71
|
-
const { start, end } = opts;
|
|
94
|
+
const { start, end, style } = opts;
|
|
95
|
+
const { activeColor, activeAreaColor } = style;
|
|
72
96
|
ctx.setLineDash([]);
|
|
73
97
|
ctx.lineWidth = areaBorderWidth;
|
|
74
|
-
ctx.strokeStyle =
|
|
75
|
-
ctx.fillStyle =
|
|
98
|
+
ctx.strokeStyle = activeColor;
|
|
99
|
+
ctx.fillStyle = activeAreaColor;
|
|
76
100
|
ctx.beginPath();
|
|
77
101
|
ctx.moveTo(start.x, start.y);
|
|
78
102
|
ctx.lineTo(end.x, start.y);
|
|
@@ -80,15 +104,16 @@ export function drawArea(ctx, opts) {
|
|
|
80
104
|
ctx.lineTo(start.x, end.y);
|
|
81
105
|
ctx.closePath();
|
|
82
106
|
ctx.stroke();
|
|
83
|
-
ctx.fill();
|
|
107
|
+
ctx.fill('nonzero');
|
|
84
108
|
}
|
|
85
109
|
export function drawListArea(ctx, opts) {
|
|
86
|
-
const { areaSize } = opts;
|
|
110
|
+
const { areaSize, style } = opts;
|
|
111
|
+
const { activeColor, activeAreaColor } = style;
|
|
87
112
|
const { x, y, w, h } = areaSize;
|
|
88
113
|
ctx.setLineDash([]);
|
|
89
114
|
ctx.lineWidth = areaBorderWidth;
|
|
90
|
-
ctx.strokeStyle =
|
|
91
|
-
ctx.fillStyle =
|
|
115
|
+
ctx.strokeStyle = activeColor;
|
|
116
|
+
ctx.fillStyle = activeAreaColor;
|
|
92
117
|
ctx.beginPath();
|
|
93
118
|
ctx.moveTo(x, y);
|
|
94
119
|
ctx.lineTo(x + w, y);
|
|
@@ -96,12 +121,19 @@ export function drawListArea(ctx, opts) {
|
|
|
96
121
|
ctx.lineTo(x, y + h);
|
|
97
122
|
ctx.closePath();
|
|
98
123
|
ctx.stroke();
|
|
99
|
-
ctx.fill();
|
|
124
|
+
ctx.fill('nonzero');
|
|
100
125
|
}
|
|
101
126
|
export function drawGroupQueueVertexesWrappers(ctx, vertexesList, opts) {
|
|
127
|
+
const { style } = opts;
|
|
128
|
+
const { activeColor } = style;
|
|
102
129
|
for (let i = 0; i < vertexesList.length; i++) {
|
|
103
130
|
const vertexes = vertexesList[i];
|
|
104
|
-
const wrapperOpts = {
|
|
131
|
+
const wrapperOpts = {
|
|
132
|
+
borderColor: activeColor,
|
|
133
|
+
borderWidth: selectWrapperBorderWidth,
|
|
134
|
+
background: 'transparent',
|
|
135
|
+
lineDash: [4, 4]
|
|
136
|
+
};
|
|
105
137
|
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
106
138
|
}
|
|
107
139
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { CoreEventMap, MiddlewareSelectorConfig } from '@idraw/types';
|
|
2
|
+
import type { Middleware, ActionType, DeepSelectorSharedStorage } from './types';
|
|
3
|
+
import { keyActionType, keyResizeType, keyGroupQueue, keyHoverElement, keySelectedElementList } from './config';
|
|
4
|
+
import { MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE } from '../info';
|
|
5
|
+
export { keySelectedElementList, keyHoverElement, keyActionType, keyResizeType, keyGroupQueue };
|
|
6
|
+
export type { DeepSelectorSharedStorage, ActionType };
|
|
7
|
+
export declare const MiddlewareSelector: Middleware<DeepSelectorSharedStorage, CoreEventMap & {
|
|
8
|
+
[MIDDLEWARE_INTERNAL_EVENT_SHOW_INFO_ANGLE]: {
|
|
9
|
+
show: boolean;
|
|
10
|
+
};
|
|
11
|
+
}, MiddlewareSelectorConfig>;
|