@idraw/core 0.3.1 → 0.4.0-alpha.3
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/index.d.ts +19 -55
- package/dist/esm/index.js +52 -188
- package/dist/esm/lib/cursor-image.d.ts +2 -0
- package/dist/esm/lib/cursor-image.js +2 -0
- package/dist/esm/lib/cursor.d.ts +16 -0
- package/dist/esm/lib/cursor.js +121 -0
- package/dist/esm/middleware/scaler/index.d.ts +2 -0
- package/dist/esm/middleware/scaler/index.js +22 -0
- package/dist/esm/middleware/scroller/config.d.ts +6 -0
- package/dist/esm/middleware/scroller/config.js +6 -0
- package/dist/esm/middleware/scroller/index.d.ts +2 -0
- package/dist/esm/middleware/scroller/index.js +97 -0
- package/dist/esm/middleware/scroller/util.d.ts +12 -0
- package/dist/esm/middleware/scroller/util.js +192 -0
- package/dist/esm/middleware/selector/config.d.ts +20 -0
- package/dist/esm/middleware/selector/config.js +20 -0
- package/dist/esm/middleware/selector/draw-wrapper.d.ts +22 -0
- package/dist/esm/middleware/selector/draw-wrapper.js +111 -0
- package/dist/esm/middleware/selector/index.d.ts +3 -0
- package/dist/esm/middleware/selector/index.js +454 -0
- package/dist/esm/middleware/selector/types.d.ts +40 -0
- package/dist/esm/middleware/selector/types.js +1 -0
- package/dist/esm/middleware/selector/util.d.ts +53 -0
- package/dist/esm/middleware/selector/util.js +789 -0
- package/dist/index.global.js +3825 -3991
- package/dist/index.global.min.js +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -21
- package/dist/esm/constant/element.d.ts +0 -2
- package/dist/esm/constant/element.js +0 -10
- package/dist/esm/constant/static.d.ts +0 -11
- package/dist/esm/constant/static.js +0 -13
- package/dist/esm/lib/calculate.d.ts +0 -5
- package/dist/esm/lib/calculate.js +0 -64
- package/dist/esm/lib/check.d.ts +0 -28
- package/dist/esm/lib/check.js +0 -115
- package/dist/esm/lib/config.d.ts +0 -3
- package/dist/esm/lib/config.js +0 -20
- package/dist/esm/lib/core-event.d.ts +0 -49
- package/dist/esm/lib/core-event.js +0 -50
- package/dist/esm/lib/diff.d.ts +0 -6
- package/dist/esm/lib/diff.js +0 -82
- package/dist/esm/lib/draw/base.d.ts +0 -5
- package/dist/esm/lib/draw/base.js +0 -90
- package/dist/esm/lib/draw/wrapper.d.ts +0 -4
- package/dist/esm/lib/draw/wrapper.js +0 -168
- package/dist/esm/lib/element.d.ts +0 -15
- package/dist/esm/lib/element.js +0 -442
- package/dist/esm/lib/engine-temp.d.ts +0 -22
- package/dist/esm/lib/engine-temp.js +0 -29
- package/dist/esm/lib/engine.d.ts +0 -47
- package/dist/esm/lib/engine.js +0 -323
- package/dist/esm/lib/helper.d.ts +0 -30
- package/dist/esm/lib/helper.js +0 -363
- package/dist/esm/lib/index.d.ts +0 -13
- package/dist/esm/lib/index.js +0 -13
- package/dist/esm/lib/is.d.ts +0 -26
- package/dist/esm/lib/is.js +0 -100
- package/dist/esm/lib/mapper.d.ts +0 -26
- package/dist/esm/lib/mapper.js +0 -89
- package/dist/esm/lib/parse.d.ts +0 -2
- package/dist/esm/lib/parse.js +0 -32
- package/dist/esm/lib/temp.d.ts +0 -11
- package/dist/esm/lib/temp.js +0 -19
- package/dist/esm/lib/transform.d.ts +0 -4
- package/dist/esm/lib/transform.js +0 -20
- package/dist/esm/lib/value.d.ts +0 -2
- package/dist/esm/lib/value.js +0 -7
- package/dist/esm/mixins/element.d.ts +0 -18
- package/dist/esm/mixins/element.js +0 -168
- package/dist/esm/plugins/helper.d.ts +0 -12
- package/dist/esm/plugins/helper.js +0 -16
- package/dist/esm/util/filter.d.ts +0 -1
- package/dist/esm/util/filter.js +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Point, BoardViewerFrameSnapshot, ViewContext2D, ElementSize } from '@idraw/types';
|
|
2
|
+
export type ScrollbarThumbType = 'X' | 'Y';
|
|
3
|
+
export declare function isPointInScrollThumb(helperContext: ViewContext2D, p: Point, opts: {
|
|
4
|
+
xThumbRect?: ElementSize | null;
|
|
5
|
+
yThumbRect?: ElementSize | null;
|
|
6
|
+
}): ScrollbarThumbType | null;
|
|
7
|
+
export declare function drawScroller(ctx: ViewContext2D, opts: {
|
|
8
|
+
snapshot: BoardViewerFrameSnapshot;
|
|
9
|
+
}): {
|
|
10
|
+
xThumbRect: ElementSize;
|
|
11
|
+
yThumbRect: ElementSize;
|
|
12
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from '@idraw/util';
|
|
2
|
+
import { keyActivePoint, keyActiveThumbType, keyPrevPoint, keyXThumbRect, keyYThumbRect } from './config';
|
|
3
|
+
const minScrollerWidth = 12;
|
|
4
|
+
const scrollerLineWidth = 16;
|
|
5
|
+
const scrollerAlpha = 0.12;
|
|
6
|
+
const scrollerThumbAlpha = 0.36;
|
|
7
|
+
const scrollConfig = {
|
|
8
|
+
width: minScrollerWidth,
|
|
9
|
+
color: '#000000',
|
|
10
|
+
showBackground: true
|
|
11
|
+
};
|
|
12
|
+
function isPointAtRect(helperContext, p, rect) {
|
|
13
|
+
const ctx = helperContext;
|
|
14
|
+
const { x, y, w, h } = rect;
|
|
15
|
+
ctx.beginPath();
|
|
16
|
+
ctx.rect(x, y, w, h);
|
|
17
|
+
ctx.closePath();
|
|
18
|
+
if (ctx.isPointInPath(p.x, p.y)) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
export function isPointInScrollThumb(helperContext, p, opts) {
|
|
24
|
+
let thumbType = null;
|
|
25
|
+
const { xThumbRect, yThumbRect } = opts;
|
|
26
|
+
if (xThumbRect && isPointAtRect(helperContext, p, xThumbRect)) {
|
|
27
|
+
thumbType = 'X';
|
|
28
|
+
}
|
|
29
|
+
else if (yThumbRect && isPointAtRect(helperContext, p, yThumbRect)) {
|
|
30
|
+
thumbType = 'Y';
|
|
31
|
+
}
|
|
32
|
+
return thumbType;
|
|
33
|
+
}
|
|
34
|
+
function getScrollInfoFromSnapshot(snapshot) {
|
|
35
|
+
const { sharedStore } = snapshot;
|
|
36
|
+
const info = {
|
|
37
|
+
activePoint: sharedStore[keyActivePoint] || null,
|
|
38
|
+
prevPoint: sharedStore[keyPrevPoint] || null,
|
|
39
|
+
activeThumbType: sharedStore[keyActiveThumbType] || null,
|
|
40
|
+
xThumbRect: sharedStore[keyXThumbRect] || null,
|
|
41
|
+
yThumbRect: sharedStore[keyYThumbRect] || null
|
|
42
|
+
};
|
|
43
|
+
return info;
|
|
44
|
+
}
|
|
45
|
+
function calcScrollerInfo(viewScaleInfo, viewSizeInfo) {
|
|
46
|
+
const { width, height } = viewSizeInfo;
|
|
47
|
+
const { offsetTop, offsetBottom, offsetLeft, offsetRight } = viewScaleInfo;
|
|
48
|
+
const sliderMinSize = scrollerLineWidth * 2.5;
|
|
49
|
+
const lineSize = scrollerLineWidth;
|
|
50
|
+
let xSize = 0;
|
|
51
|
+
let ySize = 0;
|
|
52
|
+
xSize = Math.max(sliderMinSize, width - (Math.abs(offsetLeft) + Math.abs(offsetRight)));
|
|
53
|
+
if (xSize >= width) {
|
|
54
|
+
xSize = width;
|
|
55
|
+
}
|
|
56
|
+
ySize = Math.max(sliderMinSize, height - (Math.abs(offsetTop) + Math.abs(offsetBottom)));
|
|
57
|
+
if (ySize >= height) {
|
|
58
|
+
ySize = height;
|
|
59
|
+
}
|
|
60
|
+
const xStart = lineSize / 2;
|
|
61
|
+
const xEnd = width - xSize - lineSize;
|
|
62
|
+
let translateX = xStart;
|
|
63
|
+
if (offsetLeft > 0) {
|
|
64
|
+
translateX = xStart;
|
|
65
|
+
}
|
|
66
|
+
else if (offsetRight > 0) {
|
|
67
|
+
translateX = xEnd;
|
|
68
|
+
}
|
|
69
|
+
else if (offsetLeft <= 0 && xSize > 0 && !(offsetLeft === 0 && offsetRight === 0)) {
|
|
70
|
+
translateX = xSize / 2 + ((width - xSize) * Math.abs(offsetLeft)) / (Math.abs(offsetLeft) + Math.abs(offsetRight));
|
|
71
|
+
translateX = Math.min(Math.max(0, translateX - xSize / 2), width - xSize);
|
|
72
|
+
}
|
|
73
|
+
const yStart = lineSize / 2;
|
|
74
|
+
const yEnd = height - ySize - lineSize;
|
|
75
|
+
let translateY = yStart;
|
|
76
|
+
if (offsetTop > 0) {
|
|
77
|
+
translateY = yStart;
|
|
78
|
+
}
|
|
79
|
+
else if (offsetBottom > 0) {
|
|
80
|
+
translateY = yEnd;
|
|
81
|
+
}
|
|
82
|
+
else if (offsetTop <= 0 && ySize > 0 && !(offsetTop === 0 && offsetBottom === 0)) {
|
|
83
|
+
translateY = ySize / 2 + ((height - ySize) * Math.abs(offsetTop)) / (Math.abs(offsetTop) + Math.abs(offsetBottom));
|
|
84
|
+
translateY = Math.min(Math.max(0, translateY - ySize / 2), height - ySize);
|
|
85
|
+
}
|
|
86
|
+
const xThumbRect = {
|
|
87
|
+
x: translateX,
|
|
88
|
+
y: height - lineSize,
|
|
89
|
+
w: xSize,
|
|
90
|
+
h: lineSize
|
|
91
|
+
};
|
|
92
|
+
const yThumbRect = {
|
|
93
|
+
x: width - lineSize,
|
|
94
|
+
y: translateY,
|
|
95
|
+
w: lineSize,
|
|
96
|
+
h: ySize
|
|
97
|
+
};
|
|
98
|
+
const scrollWrapper = {
|
|
99
|
+
lineSize,
|
|
100
|
+
xSize,
|
|
101
|
+
ySize,
|
|
102
|
+
translateY,
|
|
103
|
+
translateX,
|
|
104
|
+
color: '#0000007A',
|
|
105
|
+
xThumbRect,
|
|
106
|
+
yThumbRect
|
|
107
|
+
};
|
|
108
|
+
return scrollWrapper;
|
|
109
|
+
}
|
|
110
|
+
function drawScrollerThumb(ctx, opts) {
|
|
111
|
+
let { x, y, h, w } = opts;
|
|
112
|
+
const { color, axis } = opts;
|
|
113
|
+
if (axis === 'X') {
|
|
114
|
+
y = y + h / 4 + 0;
|
|
115
|
+
h = h / 2;
|
|
116
|
+
}
|
|
117
|
+
else if (axis === 'Y') {
|
|
118
|
+
x = x + w / 4 + 0;
|
|
119
|
+
w = w / 2;
|
|
120
|
+
}
|
|
121
|
+
let r = opts.r;
|
|
122
|
+
r = Math.min(r, w / 2, h / 2);
|
|
123
|
+
if (w < r * 2 || h < r * 2) {
|
|
124
|
+
r = 0;
|
|
125
|
+
}
|
|
126
|
+
ctx.globalAlpha = scrollerThumbAlpha;
|
|
127
|
+
ctx.beginPath();
|
|
128
|
+
ctx.moveTo(x + r, y);
|
|
129
|
+
ctx.arcTo(x + w, y, x + w, y + h, r);
|
|
130
|
+
ctx.arcTo(x + w, y + h, x, y + h, r);
|
|
131
|
+
ctx.arcTo(x, y + h, x, y, r);
|
|
132
|
+
ctx.arcTo(x, y, x + w, y, r);
|
|
133
|
+
ctx.closePath();
|
|
134
|
+
ctx.fillStyle = color;
|
|
135
|
+
ctx.fill();
|
|
136
|
+
ctx.globalAlpha = 1;
|
|
137
|
+
ctx.beginPath();
|
|
138
|
+
ctx.lineWidth = 1;
|
|
139
|
+
ctx.strokeStyle = color;
|
|
140
|
+
ctx.setLineDash([]);
|
|
141
|
+
ctx.moveTo(x + r, y);
|
|
142
|
+
ctx.arcTo(x + w, y, x + w, y + h, r);
|
|
143
|
+
ctx.arcTo(x + w, y + h, x, y + h, r);
|
|
144
|
+
ctx.arcTo(x, y + h, x, y, r);
|
|
145
|
+
ctx.arcTo(x, y, x + w, y, r);
|
|
146
|
+
ctx.closePath();
|
|
147
|
+
ctx.stroke();
|
|
148
|
+
}
|
|
149
|
+
function drawScrollerInfo(helperContext, opts) {
|
|
150
|
+
const ctx = helperContext;
|
|
151
|
+
const { viewScaleInfo, viewSizeInfo, scrollInfo } = opts;
|
|
152
|
+
const { activeThumbType, prevPoint, activePoint } = scrollInfo;
|
|
153
|
+
const { width, height } = viewSizeInfo;
|
|
154
|
+
const wrapper = calcScrollerInfo(viewScaleInfo, viewSizeInfo);
|
|
155
|
+
let xThumbRect = Object.assign({}, wrapper.xThumbRect);
|
|
156
|
+
let yThumbRect = Object.assign({}, wrapper.yThumbRect);
|
|
157
|
+
if (activeThumbType && prevPoint && activePoint) {
|
|
158
|
+
if (activeThumbType === 'X' && scrollInfo.xThumbRect) {
|
|
159
|
+
xThumbRect = Object.assign({}, scrollInfo.xThumbRect);
|
|
160
|
+
xThumbRect.x = xThumbRect.x + (activePoint.x - prevPoint.x);
|
|
161
|
+
}
|
|
162
|
+
else if (activeThumbType === 'Y' && scrollInfo.yThumbRect) {
|
|
163
|
+
yThumbRect = Object.assign({}, scrollInfo.yThumbRect);
|
|
164
|
+
yThumbRect.y = yThumbRect.y + (activePoint.y - prevPoint.y);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (scrollConfig.showBackground === true) {
|
|
168
|
+
ctx.globalAlpha = scrollerAlpha;
|
|
169
|
+
ctx.fillStyle = wrapper.color;
|
|
170
|
+
ctx.fillRect(0, height - wrapper.lineSize, width, wrapper.lineSize);
|
|
171
|
+
}
|
|
172
|
+
drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'X' }, xThumbRect), { r: wrapper.lineSize / 2, color: wrapper.color }));
|
|
173
|
+
if (scrollConfig.showBackground === true) {
|
|
174
|
+
ctx.globalAlpha = scrollerAlpha;
|
|
175
|
+
ctx.fillStyle = wrapper.color;
|
|
176
|
+
ctx.fillRect(width - wrapper.lineSize, 0, wrapper.lineSize, height);
|
|
177
|
+
}
|
|
178
|
+
drawScrollerThumb(ctx, Object.assign(Object.assign({ axis: 'Y' }, yThumbRect), { r: wrapper.lineSize / 2, color: wrapper.color }));
|
|
179
|
+
ctx.globalAlpha = 1;
|
|
180
|
+
return {
|
|
181
|
+
xThumbRect,
|
|
182
|
+
yThumbRect
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export function drawScroller(ctx, opts) {
|
|
186
|
+
const { snapshot } = opts;
|
|
187
|
+
const viewSizeInfo = getViewSizeInfoFromSnapshot(snapshot);
|
|
188
|
+
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
189
|
+
const scrollInfo = getScrollInfoFromSnapshot(snapshot);
|
|
190
|
+
const { xThumbRect, yThumbRect } = drawScrollerInfo(ctx, { viewSizeInfo, viewScaleInfo, scrollInfo });
|
|
191
|
+
return { xThumbRect, yThumbRect };
|
|
192
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const key = "SELECT";
|
|
2
|
+
export declare const keyActionType: unique symbol;
|
|
3
|
+
export declare const keyResizeType: unique symbol;
|
|
4
|
+
export declare const keyAreaStart: unique symbol;
|
|
5
|
+
export declare const keyAreaEnd: unique symbol;
|
|
6
|
+
export declare const keyHoverElement: unique symbol;
|
|
7
|
+
export declare const keyHoverElementVertexes: unique symbol;
|
|
8
|
+
export declare const keySelectedElementList: unique symbol;
|
|
9
|
+
export declare const keySelectedElementListVertexes: unique symbol;
|
|
10
|
+
export declare const keySelectedElementController: unique symbol;
|
|
11
|
+
export declare const keyGroupQueue: unique symbol;
|
|
12
|
+
export declare const keyGroupQueueVertexesList: unique symbol;
|
|
13
|
+
export declare const keyDebugElemCenter: unique symbol;
|
|
14
|
+
export declare const keyDebugStartVertical: unique symbol;
|
|
15
|
+
export declare const keyDebugEndVertical: unique symbol;
|
|
16
|
+
export declare const keyDebugStartHorizontal: unique symbol;
|
|
17
|
+
export declare const keyDebugEndHorizontal: unique symbol;
|
|
18
|
+
export declare const keyDebugEnd0: unique symbol;
|
|
19
|
+
export declare const resizeControllerBorderWidth = 2;
|
|
20
|
+
export declare const wrapperColor = "#1973ba";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const key = 'SELECT';
|
|
2
|
+
export const keyActionType = Symbol(`${key}_actionType`);
|
|
3
|
+
export const keyResizeType = Symbol(`${key}_resizeType`);
|
|
4
|
+
export const keyAreaStart = Symbol(`${key}_areaStart`);
|
|
5
|
+
export const keyAreaEnd = Symbol(`${key}_areaEnd`);
|
|
6
|
+
export const keyHoverElement = Symbol(`${key}_hoverElement`);
|
|
7
|
+
export const keyHoverElementVertexes = Symbol(`${key}_hoverElementVertexes`);
|
|
8
|
+
export const keySelectedElementList = Symbol(`${key}_selectedElementList`);
|
|
9
|
+
export const keySelectedElementListVertexes = Symbol(`${key}_selectedElementListVertexes`);
|
|
10
|
+
export const keySelectedElementController = Symbol(`${key}_selectedElementController`);
|
|
11
|
+
export const keyGroupQueue = Symbol(`${key}_groupQueue`);
|
|
12
|
+
export const keyGroupQueueVertexesList = Symbol(`${key}_groupQueueVertexesList`);
|
|
13
|
+
export const keyDebugElemCenter = Symbol(`${key}_debug_elemCenter`);
|
|
14
|
+
export const keyDebugStartVertical = Symbol(`${key}_debug_startVertical`);
|
|
15
|
+
export const keyDebugEndVertical = Symbol(`${key}_debug_endVertical`);
|
|
16
|
+
export const keyDebugStartHorizontal = Symbol(`${key}_debug_startHorizontal`);
|
|
17
|
+
export const keyDebugEndHorizontal = Symbol(`${key}_debug_endHorizontal`);
|
|
18
|
+
export const keyDebugEnd0 = Symbol(`${key}_debug_end0`);
|
|
19
|
+
export const resizeControllerBorderWidth = 2;
|
|
20
|
+
export const wrapperColor = '#1973ba';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Element, ElementType, PointSize, RendererDrawElementOptions, ViewContext2D, ViewRectVertexes, ViewScaleInfo, ViewSizeInfo, ElementSizeController } from '@idraw/types';
|
|
2
|
+
import type { AreaSize } from './types';
|
|
3
|
+
export declare function drawHoverVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {
|
|
4
|
+
viewScaleInfo: ViewScaleInfo;
|
|
5
|
+
viewSizeInfo: ViewSizeInfo;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function drawSelectedElementControllersVertexes(ctx: ViewContext2D, controller: ElementSizeController | null, opts: {
|
|
8
|
+
viewScaleInfo: ViewScaleInfo;
|
|
9
|
+
viewSizeInfo: ViewSizeInfo;
|
|
10
|
+
}): void;
|
|
11
|
+
export declare function drawElementListShadows(ctx: ViewContext2D, elements: Element<ElementType>[], opts?: Omit<RendererDrawElementOptions, 'loader'>): void;
|
|
12
|
+
export declare function drawArea(ctx: ViewContext2D, opts: {
|
|
13
|
+
start: PointSize;
|
|
14
|
+
end: PointSize;
|
|
15
|
+
}): void;
|
|
16
|
+
export declare function drawListArea(ctx: ViewContext2D, opts: {
|
|
17
|
+
areaSize: AreaSize;
|
|
18
|
+
}): void;
|
|
19
|
+
export declare function drawGroupQueueVertexesWrappers(ctx: ViewContext2D, vertexesList: ViewRectVertexes[], opts: {
|
|
20
|
+
viewScaleInfo: ViewScaleInfo;
|
|
21
|
+
viewSizeInfo: ViewSizeInfo;
|
|
22
|
+
}): void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { rotateElementVertexes, calcViewVertexes } from '@idraw/util';
|
|
2
|
+
import { resizeControllerBorderWidth, wrapperColor } from './config';
|
|
3
|
+
function drawVertexes(ctx, vertexes, opts) {
|
|
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
|
+
}
|
|
20
|
+
export function drawHoverVertexesWrapper(ctx, vertexes, opts) {
|
|
21
|
+
if (!vertexes) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const wrapperOpts = { borderColor: wrapperColor, borderWidth: 1, background: 'transparent', lineDash: [] };
|
|
25
|
+
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
26
|
+
}
|
|
27
|
+
export function drawSelectedElementControllersVertexes(ctx, controller, opts) {
|
|
28
|
+
if (!controller) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { elementWrapper, left, right, top, bottom, topLeft, topRight, bottomLeft, bottomRight } = controller;
|
|
32
|
+
const wrapperOpts = { borderColor: wrapperColor, borderWidth: 1, background: 'transparent', lineDash: [] };
|
|
33
|
+
const ctrlOpts = Object.assign(Object.assign({}, wrapperOpts), { borderWidth: resizeControllerBorderWidth, background: '#FFFFFF' });
|
|
34
|
+
drawVertexes(ctx, calcViewVertexes(elementWrapper, opts), wrapperOpts);
|
|
35
|
+
drawVertexes(ctx, calcViewVertexes(left.vertexes, opts), ctrlOpts);
|
|
36
|
+
drawVertexes(ctx, calcViewVertexes(right.vertexes, opts), ctrlOpts);
|
|
37
|
+
drawVertexes(ctx, calcViewVertexes(top.vertexes, opts), ctrlOpts);
|
|
38
|
+
drawVertexes(ctx, calcViewVertexes(bottom.vertexes, opts), ctrlOpts);
|
|
39
|
+
drawVertexes(ctx, calcViewVertexes(topLeft.vertexes, opts), ctrlOpts);
|
|
40
|
+
drawVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
|
|
41
|
+
drawVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
|
|
42
|
+
drawVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
|
|
43
|
+
}
|
|
44
|
+
export function drawElementListShadows(ctx, elements, opts) {
|
|
45
|
+
elements.forEach((elem) => {
|
|
46
|
+
let { x, y, w, h } = elem;
|
|
47
|
+
const { angle = 0 } = elem;
|
|
48
|
+
if (opts === null || opts === void 0 ? void 0 : opts.calculator) {
|
|
49
|
+
const { calculator } = opts;
|
|
50
|
+
const size = calculator.elementSize({ x, y, w, h }, opts.viewScaleInfo, opts.viewSizeInfo);
|
|
51
|
+
x = size.x;
|
|
52
|
+
y = size.y;
|
|
53
|
+
w = size.w;
|
|
54
|
+
h = size.h;
|
|
55
|
+
}
|
|
56
|
+
const vertexes = rotateElementVertexes({ x, y, w, h, angle });
|
|
57
|
+
if (vertexes.length >= 2) {
|
|
58
|
+
ctx.setLineDash([]);
|
|
59
|
+
ctx.lineWidth = 1;
|
|
60
|
+
ctx.strokeStyle = '#aaaaaa';
|
|
61
|
+
ctx.fillStyle = '#0000001A';
|
|
62
|
+
ctx.beginPath();
|
|
63
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
64
|
+
for (let i = 0; i < vertexes.length; i++) {
|
|
65
|
+
const p = vertexes[i];
|
|
66
|
+
ctx.lineTo(p.x, p.y);
|
|
67
|
+
}
|
|
68
|
+
ctx.closePath();
|
|
69
|
+
ctx.stroke();
|
|
70
|
+
ctx.fill();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function drawArea(ctx, opts) {
|
|
75
|
+
const { start, end } = opts;
|
|
76
|
+
ctx.setLineDash([]);
|
|
77
|
+
ctx.lineWidth = 1;
|
|
78
|
+
ctx.strokeStyle = wrapperColor;
|
|
79
|
+
ctx.fillStyle = '#1976d24f';
|
|
80
|
+
ctx.beginPath();
|
|
81
|
+
ctx.moveTo(start.x, start.y);
|
|
82
|
+
ctx.lineTo(end.x, start.y);
|
|
83
|
+
ctx.lineTo(end.x, end.y);
|
|
84
|
+
ctx.lineTo(start.x, end.y);
|
|
85
|
+
ctx.closePath();
|
|
86
|
+
ctx.stroke();
|
|
87
|
+
ctx.fill();
|
|
88
|
+
}
|
|
89
|
+
export function drawListArea(ctx, opts) {
|
|
90
|
+
const { areaSize } = opts;
|
|
91
|
+
const { x, y, w, h } = areaSize;
|
|
92
|
+
ctx.setLineDash([]);
|
|
93
|
+
ctx.lineWidth = 1;
|
|
94
|
+
ctx.strokeStyle = wrapperColor;
|
|
95
|
+
ctx.fillStyle = '#1976d21c';
|
|
96
|
+
ctx.beginPath();
|
|
97
|
+
ctx.moveTo(x, y);
|
|
98
|
+
ctx.lineTo(x + w, y);
|
|
99
|
+
ctx.lineTo(x + w, y + h);
|
|
100
|
+
ctx.lineTo(x, y + h);
|
|
101
|
+
ctx.closePath();
|
|
102
|
+
ctx.stroke();
|
|
103
|
+
ctx.fill();
|
|
104
|
+
}
|
|
105
|
+
export function drawGroupQueueVertexesWrappers(ctx, vertexesList, opts) {
|
|
106
|
+
for (let i = 0; i < vertexesList.length; i++) {
|
|
107
|
+
const vertexes = vertexesList[i];
|
|
108
|
+
const wrapperOpts = { borderColor: wrapperColor, borderWidth: 2, background: 'transparent', lineDash: [4, 4] };
|
|
109
|
+
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
110
|
+
}
|
|
111
|
+
}
|