@hprint/plugins 0.0.7 → 0.0.9-alpha.0
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/index.js +44 -44
- package/dist/index.mjs +6957 -6550
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/plugins/ActualContentLayoutPlugin.d.ts +29 -0
- package/dist/src/plugins/ActualContentLayoutPlugin.d.ts.map +1 -0
- package/dist/src/plugins/CopyPlugin.d.ts.map +1 -1
- package/dist/src/plugins/ImageTextListPlugin.d.ts +68 -0
- package/dist/src/plugins/ImageTextListPlugin.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/assets/style/resizePlugin.css +27 -27
- package/src/index.ts +11 -5
- package/src/objects/Arrow.js +47 -47
- package/src/objects/ThinTailArrow.js +50 -50
- package/src/plugins/ActualContentLayoutPlugin.ts +276 -0
- package/src/plugins/ControlsPlugin.ts +413 -413
- package/src/plugins/ControlsRotatePlugin.ts +111 -111
- package/src/plugins/CopyPlugin.ts +260 -258
- package/src/plugins/DeleteHotKeyPlugin.ts +57 -57
- package/src/plugins/DrawLinePlugin.ts +162 -162
- package/src/plugins/DrawPolygonPlugin.ts +205 -205
- package/src/plugins/DringPlugin.ts +125 -125
- package/src/plugins/FlipPlugin.ts +59 -59
- package/src/plugins/FontPlugin.ts +165 -165
- package/src/plugins/FreeDrawPlugin.ts +49 -49
- package/src/plugins/GroupPlugin.ts +82 -82
- package/src/plugins/GroupTextEditorPlugin.ts +198 -198
- package/src/plugins/HistoryPlugin.ts +181 -181
- package/src/plugins/ImageStroke.ts +121 -121
- package/src/plugins/ImageTextListPlugin.ts +540 -0
- package/src/plugins/LayerPlugin.ts +108 -108
- package/src/plugins/MaskPlugin.ts +155 -155
- package/src/plugins/MaterialPlugin.ts +224 -224
- package/src/plugins/MiddleMousePlugin.ts +45 -45
- package/src/plugins/MoveHotKeyPlugin.ts +46 -46
- package/src/plugins/PathTextPlugin.ts +89 -89
- package/src/plugins/PolygonModifyPlugin.ts +224 -224
- package/src/plugins/PrintPlugin.ts +81 -81
- package/src/plugins/PsdPlugin.ts +52 -52
- package/src/plugins/SimpleClipImagePlugin.ts +244 -244
- package/src/types/eventType.ts +11 -11
- package/src/utils/psd.js +432 -432
- package/src/utils/ruler/guideline.ts +145 -145
- package/src/utils/ruler/index.ts +91 -91
- package/src/utils/ruler/utils.ts +162 -162
- package/tsconfig.json +10 -10
- package/vite.config.ts +29 -29
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA0C5D,QAAA,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAuCjD,CAAC;AAGF,QAAA,MAAM,WAAW,EAAE,YAAY,EAuC9B,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { fabric, IEditor, IPluginTempl } from '@hprint/core';
|
|
2
|
+
export interface ActualContentLayoutSettings {
|
|
3
|
+
actualContentLayout?: boolean;
|
|
4
|
+
overflowMode?: 'clip' | 'expand';
|
|
5
|
+
}
|
|
6
|
+
type IPlugin = Pick<ActualContentLayoutPlugin, 'applyActualContentLayout'>;
|
|
7
|
+
declare module '@hprint/core' {
|
|
8
|
+
interface IEditor extends IPlugin {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
declare class ActualContentLayoutPlugin implements IPluginTempl {
|
|
12
|
+
canvas: fabric.Canvas;
|
|
13
|
+
editor: IEditor;
|
|
14
|
+
static pluginName: string;
|
|
15
|
+
static apis: string[];
|
|
16
|
+
constructor(canvas: fabric.Canvas, editor: IEditor);
|
|
17
|
+
private layoutOrigins;
|
|
18
|
+
hookTransformObjectEnd(...args: unknown[]): Promise<void>;
|
|
19
|
+
applyActualContentLayout(templateContent: any, templateHeight: number): number;
|
|
20
|
+
private getOriginalTop;
|
|
21
|
+
private getOriginalHeight;
|
|
22
|
+
private getOriginMmValue;
|
|
23
|
+
private preparePrintLayoutObject;
|
|
24
|
+
private isPrintableObject;
|
|
25
|
+
private isEmptyLayoutObject;
|
|
26
|
+
private getActualLayoutHeight;
|
|
27
|
+
}
|
|
28
|
+
export default ActualContentLayoutPlugin;
|
|
29
|
+
//# sourceMappingURL=ActualContentLayoutPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActualContentLayoutPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/ActualContentLayoutPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,WAAW,2BAA2B;IACxC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CACpC;AAED,KAAK,OAAO,GAAG,IAAI,CAAC,yBAAyB,EAAE,0BAA0B,CAAC,CAAC;AAE3E,OAAO,QAAQ,cAAc,CAAC;IAC1B,UAAU,OAAQ,SAAQ,OAAO;KAAG;CACvC;AASD,cAAM,yBAA0B,YAAW,YAAY;IAKxC,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,MAAM,EAAE,OAAO;IAL1B,MAAM,CAA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AM,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"CopyPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/CopyPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE1D,KAAK,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAEzC,OAAO,QAAQ,cAAc,CAAC;IAE1B,UAAU,OAAQ,SAAQ,OAAO;KAAG;CACvC;AAED,cAAM,UAAW,YAAW,YAAY;IAMzB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,MAAM,EAAE,OAAO;IAN1B,MAAM,CAAC,UAAU,SAAgB;IACjC,MAAM,CAAC,IAAI,WAAa;IACxB,OAAO,EAAE,MAAM,EAAE,CAAwB;IACzC,OAAO,CAAC,KAAK,CAAuD;gBAEzD,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,MAAM,EAAE,OAAO;IAM1B,oBAAoB,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM;IAiChD,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM;IA8BvC,KAAK,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC,MAAM;IAYlE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa;IAiB/C,WAAW;;;;;;IAcX,OAAO;IAKP,SAAS;IAIH,aAAa,CAAC,KAAK,EAAE,GAAG;CAwHjC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { fabric, IEditor, IPluginTempl } from '@hprint/core';
|
|
2
|
+
export type ImageTextListLayout = 'item-vertical' | 'icon-text-split' | 'icon-only' | 'text-only';
|
|
3
|
+
export interface ImageTextListItem {
|
|
4
|
+
src: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ImageTextListOptions {
|
|
8
|
+
items?: ImageTextListItem[];
|
|
9
|
+
_renderItems?: ImageTextListItem[];
|
|
10
|
+
_clipContent?: boolean;
|
|
11
|
+
layout?: ImageTextListLayout;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
iconSize?: number;
|
|
15
|
+
horizontalGap?: number;
|
|
16
|
+
verticalGap?: number;
|
|
17
|
+
itemGap?: number;
|
|
18
|
+
fontFamily?: string;
|
|
19
|
+
fontSize?: number;
|
|
20
|
+
fontWeight?: string;
|
|
21
|
+
fontStyle?: string;
|
|
22
|
+
underline?: boolean | string;
|
|
23
|
+
linethrough?: boolean | string;
|
|
24
|
+
textAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
25
|
+
textWrap?: boolean;
|
|
26
|
+
lineHeight?: number;
|
|
27
|
+
charSpacing?: number;
|
|
28
|
+
color?: string;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
type ImageTextListGroup = fabric.Group & {
|
|
32
|
+
extensionType?: string;
|
|
33
|
+
extension?: ImageTextListOptions;
|
|
34
|
+
_originSize?: Record<string, any>;
|
|
35
|
+
setExtension?: (fields: Record<string, any>) => Promise<void>;
|
|
36
|
+
setExtensionByUnit?: (fields: Record<string, any>) => Promise<void>;
|
|
37
|
+
setByUnit?: (field: string, value: any) => Promise<any>;
|
|
38
|
+
__imageTextListModified?: () => void;
|
|
39
|
+
};
|
|
40
|
+
type IPlugin = Pick<ImageTextListPlugin, 'createImageTextList' | 'initImageTextListEvents' | 'refreshImageTextList'>;
|
|
41
|
+
declare module '@hprint/core' {
|
|
42
|
+
interface IEditor extends IPlugin {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
declare class ImageTextListPlugin implements IPluginTempl {
|
|
46
|
+
canvas: fabric.Canvas;
|
|
47
|
+
editor: IEditor;
|
|
48
|
+
static pluginName: string;
|
|
49
|
+
static apis: string[];
|
|
50
|
+
constructor(canvas: fabric.Canvas, editor: IEditor);
|
|
51
|
+
hookTransform(object: any): Promise<void>;
|
|
52
|
+
hookTransformObjectEnd(...args: unknown[]): Promise<void>;
|
|
53
|
+
createImageTextList(items: ImageTextListItem[], options?: ImageTextListOptions): Promise<ImageTextListGroup>;
|
|
54
|
+
initImageTextListEvents(group: ImageTextListGroup): void;
|
|
55
|
+
refreshImageTextList(group: ImageTextListGroup): Promise<void>;
|
|
56
|
+
private normalizeOptions;
|
|
57
|
+
private toPx;
|
|
58
|
+
private getItems;
|
|
59
|
+
private createText;
|
|
60
|
+
private loadImage;
|
|
61
|
+
private buildGroup;
|
|
62
|
+
private createGroup;
|
|
63
|
+
private flowRows;
|
|
64
|
+
private updateOriginSize;
|
|
65
|
+
destroy(): void;
|
|
66
|
+
}
|
|
67
|
+
export default ImageTextListPlugin;
|
|
68
|
+
//# sourceMappingURL=ImageTextListPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageTextListPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/ImageTextListPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG1D,MAAM,MAAM,mBAAmB,GACzB,eAAe,GACf,iBAAiB,GACjB,WAAW,GACX,WAAW,CAAC;AAElB,MAAM,WAAW,iBAAiB;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACjC,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MA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|
"qs": "~6.12.3",
|
|
23
23
|
"socket.io-client": "^4.8.1",
|
|
24
24
|
"uuid": "~8.3.2",
|
|
25
|
-
"@hprint/core": "0.0.
|
|
26
|
-
"@hprint/shared": "0.0.
|
|
25
|
+
"@hprint/core": "0.0.9-alpha.0",
|
|
26
|
+
"@hprint/shared": "0.0.9-alpha.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/bwip-js": "^3.2.3",
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
.resize-bar {
|
|
2
|
-
border-radius: 3px;
|
|
3
|
-
background-color: rgba(160, 160, 160, 0.6);
|
|
4
|
-
position: absolute;
|
|
5
|
-
}
|
|
6
|
-
.resize-bar:hover {
|
|
7
|
-
background-color: #328cff;
|
|
8
|
-
}
|
|
9
|
-
.resize-bar.horizontal {
|
|
10
|
-
width: 6px;
|
|
11
|
-
height: 30px;
|
|
12
|
-
}
|
|
13
|
-
.resize-bar.vertical {
|
|
14
|
-
width: 30px;
|
|
15
|
-
height: 6px;
|
|
16
|
-
}
|
|
17
|
-
.resize-bar.active {
|
|
18
|
-
background-color: #328cff;
|
|
19
|
-
}
|
|
20
|
-
#resize-left-bar,
|
|
21
|
-
#resize-right-bar {
|
|
22
|
-
cursor: ew-resize;
|
|
23
|
-
}
|
|
24
|
-
#resize-top-bar,
|
|
25
|
-
#resize-bottom-bar {
|
|
26
|
-
cursor: ns-resize;
|
|
27
|
-
}
|
|
1
|
+
.resize-bar {
|
|
2
|
+
border-radius: 3px;
|
|
3
|
+
background-color: rgba(160, 160, 160, 0.6);
|
|
4
|
+
position: absolute;
|
|
5
|
+
}
|
|
6
|
+
.resize-bar:hover {
|
|
7
|
+
background-color: #328cff;
|
|
8
|
+
}
|
|
9
|
+
.resize-bar.horizontal {
|
|
10
|
+
width: 6px;
|
|
11
|
+
height: 30px;
|
|
12
|
+
}
|
|
13
|
+
.resize-bar.vertical {
|
|
14
|
+
width: 30px;
|
|
15
|
+
height: 6px;
|
|
16
|
+
}
|
|
17
|
+
.resize-bar.active {
|
|
18
|
+
background-color: #328cff;
|
|
19
|
+
}
|
|
20
|
+
#resize-left-bar,
|
|
21
|
+
#resize-right-bar {
|
|
22
|
+
cursor: ew-resize;
|
|
23
|
+
}
|
|
24
|
+
#resize-top-bar,
|
|
25
|
+
#resize-bottom-bar {
|
|
26
|
+
cursor: ns-resize;
|
|
27
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -36,7 +36,9 @@ import ResizePlugin from './plugins/ResizePlugin';
|
|
|
36
36
|
import LockPlugin from './plugins/LockPlugin';
|
|
37
37
|
import AddBaseTypePlugin from './plugins/AddBaseTypePlugin';
|
|
38
38
|
import PrintPlugin from './plugins/PrintPlugin';
|
|
39
|
-
import CreateElementPlugin from './plugins/CreateElementPlugin';
|
|
39
|
+
import CreateElementPlugin from './plugins/CreateElementPlugin';
|
|
40
|
+
import ImageTextListPlugin from './plugins/ImageTextListPlugin';
|
|
41
|
+
import ActualContentLayoutPlugin from './plugins/ActualContentLayoutPlugin';
|
|
40
42
|
|
|
41
43
|
// 对象形式导出所有插件
|
|
42
44
|
const pluginsObject: { [key: string]: IPluginTempl } = {
|
|
@@ -75,8 +77,10 @@ const pluginsObject: { [key: string]: IPluginTempl } = {
|
|
|
75
77
|
LockPlugin,
|
|
76
78
|
AddBaseTypePlugin,
|
|
77
79
|
PrintPlugin,
|
|
78
|
-
CreateElementPlugin,
|
|
79
|
-
|
|
80
|
+
CreateElementPlugin,
|
|
81
|
+
ImageTextListPlugin,
|
|
82
|
+
ActualContentLayoutPlugin,
|
|
83
|
+
};
|
|
80
84
|
|
|
81
85
|
// 数组形式导出所有插件
|
|
82
86
|
const pluginsList: IPluginTempl[] = [
|
|
@@ -115,7 +119,9 @@ const pluginsList: IPluginTempl[] = [
|
|
|
115
119
|
LockPlugin,
|
|
116
120
|
AddBaseTypePlugin,
|
|
117
121
|
PrintPlugin,
|
|
118
|
-
CreateElementPlugin,
|
|
119
|
-
|
|
122
|
+
CreateElementPlugin,
|
|
123
|
+
ImageTextListPlugin,
|
|
124
|
+
ActualContentLayoutPlugin,
|
|
125
|
+
];
|
|
120
126
|
|
|
121
127
|
export { pluginsObject, pluginsList, SelectEvent, SelectMode };
|
package/src/objects/Arrow.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { fabric } from '@hprint/core';
|
|
2
|
-
|
|
3
|
-
fabric.Arrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
-
type: 'arrow',
|
|
5
|
-
superType: 'drawing',
|
|
6
|
-
initialize(points, options) {
|
|
7
|
-
if (!points) {
|
|
8
|
-
const { x1, x2, y1, y2 } = options;
|
|
9
|
-
points = [x1, y1, x2, y2];
|
|
10
|
-
}
|
|
11
|
-
options = options || {};
|
|
12
|
-
this.callSuper('initialize', points, options);
|
|
13
|
-
},
|
|
14
|
-
_render(ctx) {
|
|
15
|
-
this.callSuper('_render', ctx);
|
|
16
|
-
ctx.save();
|
|
17
|
-
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
18
|
-
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
19
|
-
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
20
|
-
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
21
|
-
const angle = Math.atan2(yDiff, xDiff);
|
|
22
|
-
ctx.translate(
|
|
23
|
-
((this.x2 - this.x1) / 2) * this.scaleX,
|
|
24
|
-
((this.y2 - this.y1) / 2) * this.scaleY
|
|
25
|
-
);
|
|
26
|
-
ctx.rotate(angle);
|
|
27
|
-
ctx.beginPath();
|
|
28
|
-
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
29
|
-
ctx.moveTo(0, 0);
|
|
30
|
-
ctx.lineTo(-10, 5);
|
|
31
|
-
ctx.lineTo(-10, -5);
|
|
32
|
-
ctx.closePath();
|
|
33
|
-
ctx.lineWidth = this.lineWidth;
|
|
34
|
-
ctx.strokeStyle = this.stroke;
|
|
35
|
-
ctx.fillStyle = this.fill;
|
|
36
|
-
ctx.stroke();
|
|
37
|
-
ctx.fill();
|
|
38
|
-
ctx.restore();
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
fabric.Arrow.fromObject = (options, callback) => {
|
|
43
|
-
const { x1, x2, y1, y2 } = options;
|
|
44
|
-
return callback(new fabric.Arrow([x1, y1, x2, y2], options));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default fabric.Arrow;
|
|
1
|
+
import { fabric } from '@hprint/core';
|
|
2
|
+
|
|
3
|
+
fabric.Arrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
+
type: 'arrow',
|
|
5
|
+
superType: 'drawing',
|
|
6
|
+
initialize(points, options) {
|
|
7
|
+
if (!points) {
|
|
8
|
+
const { x1, x2, y1, y2 } = options;
|
|
9
|
+
points = [x1, y1, x2, y2];
|
|
10
|
+
}
|
|
11
|
+
options = options || {};
|
|
12
|
+
this.callSuper('initialize', points, options);
|
|
13
|
+
},
|
|
14
|
+
_render(ctx) {
|
|
15
|
+
this.callSuper('_render', ctx);
|
|
16
|
+
ctx.save();
|
|
17
|
+
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
18
|
+
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
19
|
+
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
20
|
+
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
21
|
+
const angle = Math.atan2(yDiff, xDiff);
|
|
22
|
+
ctx.translate(
|
|
23
|
+
((this.x2 - this.x1) / 2) * this.scaleX,
|
|
24
|
+
((this.y2 - this.y1) / 2) * this.scaleY
|
|
25
|
+
);
|
|
26
|
+
ctx.rotate(angle);
|
|
27
|
+
ctx.beginPath();
|
|
28
|
+
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
29
|
+
ctx.moveTo(0, 0);
|
|
30
|
+
ctx.lineTo(-10, 5);
|
|
31
|
+
ctx.lineTo(-10, -5);
|
|
32
|
+
ctx.closePath();
|
|
33
|
+
ctx.lineWidth = this.lineWidth;
|
|
34
|
+
ctx.strokeStyle = this.stroke;
|
|
35
|
+
ctx.fillStyle = this.fill;
|
|
36
|
+
ctx.stroke();
|
|
37
|
+
ctx.fill();
|
|
38
|
+
ctx.restore();
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
fabric.Arrow.fromObject = (options, callback) => {
|
|
43
|
+
const { x1, x2, y1, y2 } = options;
|
|
44
|
+
return callback(new fabric.Arrow([x1, y1, x2, y2], options));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default fabric.Arrow;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { fabric } from '@hprint/core';
|
|
2
|
-
|
|
3
|
-
fabric.ThinTailArrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
-
type: 'thinTailArrow',
|
|
5
|
-
superType: 'drawing',
|
|
6
|
-
initialize(points, options) {
|
|
7
|
-
if (!points) {
|
|
8
|
-
const { x1, x2, y1, y2 } = options;
|
|
9
|
-
points = [x1, y1, x2, y2];
|
|
10
|
-
}
|
|
11
|
-
options = options || {};
|
|
12
|
-
this.callSuper('initialize', points, options);
|
|
13
|
-
},
|
|
14
|
-
_render(ctx) {
|
|
15
|
-
ctx.save();
|
|
16
|
-
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
17
|
-
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
18
|
-
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
19
|
-
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
20
|
-
ctx.translate(-xDiff / 2, -yDiff / 2);
|
|
21
|
-
// 箭头方位角
|
|
22
|
-
const angle = Math.atan2(yDiff, xDiff);
|
|
23
|
-
ctx.rotate(angle);
|
|
24
|
-
// 箭头总长(最小长度是20)
|
|
25
|
-
let length = Math.hypot(xDiff, yDiff);
|
|
26
|
-
length = length < 20 ? 20 : length;
|
|
27
|
-
// 绘制箭头
|
|
28
|
-
ctx.beginPath();
|
|
29
|
-
ctx.moveTo(0, 0);
|
|
30
|
-
ctx.lineTo(length - 18, -5);
|
|
31
|
-
ctx.lineTo(length - 20, -12);
|
|
32
|
-
ctx.lineTo(length, 0);
|
|
33
|
-
ctx.lineTo(length - 20, 12);
|
|
34
|
-
ctx.lineTo(length - 18, 5);
|
|
35
|
-
ctx.lineTo(0, 0);
|
|
36
|
-
ctx.lineWidth = this.strokeWidth;
|
|
37
|
-
ctx.strokeStyle = this.stroke;
|
|
38
|
-
ctx.fillStyle = this.fill;
|
|
39
|
-
ctx.stroke();
|
|
40
|
-
ctx.fill();
|
|
41
|
-
ctx.restore();
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
fabric.ThinTailArrow.fromObject = (options, callback) => {
|
|
46
|
-
const { x1, x2, y1, y2 } = options;
|
|
47
|
-
return callback(new fabric.ThinTailArrow([x1, y1, x2, y2], options));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default fabric.ThinTailArrow;
|
|
1
|
+
import { fabric } from '@hprint/core';
|
|
2
|
+
|
|
3
|
+
fabric.ThinTailArrow = fabric.util.createClass(fabric.Line, {
|
|
4
|
+
type: 'thinTailArrow',
|
|
5
|
+
superType: 'drawing',
|
|
6
|
+
initialize(points, options) {
|
|
7
|
+
if (!points) {
|
|
8
|
+
const { x1, x2, y1, y2 } = options;
|
|
9
|
+
points = [x1, y1, x2, y2];
|
|
10
|
+
}
|
|
11
|
+
options = options || {};
|
|
12
|
+
this.callSuper('initialize', points, options);
|
|
13
|
+
},
|
|
14
|
+
_render(ctx) {
|
|
15
|
+
ctx.save();
|
|
16
|
+
// 乘或除对应的scaleX(Y),抵消元素放缩造成的影响,使箭头不会变形
|
|
17
|
+
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
|
|
18
|
+
const xDiff = (this.x2 - this.x1) * this.scaleX;
|
|
19
|
+
const yDiff = (this.y2 - this.y1) * this.scaleY;
|
|
20
|
+
ctx.translate(-xDiff / 2, -yDiff / 2);
|
|
21
|
+
// 箭头方位角
|
|
22
|
+
const angle = Math.atan2(yDiff, xDiff);
|
|
23
|
+
ctx.rotate(angle);
|
|
24
|
+
// 箭头总长(最小长度是20)
|
|
25
|
+
let length = Math.hypot(xDiff, yDiff);
|
|
26
|
+
length = length < 20 ? 20 : length;
|
|
27
|
+
// 绘制箭头
|
|
28
|
+
ctx.beginPath();
|
|
29
|
+
ctx.moveTo(0, 0);
|
|
30
|
+
ctx.lineTo(length - 18, -5);
|
|
31
|
+
ctx.lineTo(length - 20, -12);
|
|
32
|
+
ctx.lineTo(length, 0);
|
|
33
|
+
ctx.lineTo(length - 20, 12);
|
|
34
|
+
ctx.lineTo(length - 18, 5);
|
|
35
|
+
ctx.lineTo(0, 0);
|
|
36
|
+
ctx.lineWidth = this.strokeWidth;
|
|
37
|
+
ctx.strokeStyle = this.stroke;
|
|
38
|
+
ctx.fillStyle = this.fill;
|
|
39
|
+
ctx.stroke();
|
|
40
|
+
ctx.fill();
|
|
41
|
+
ctx.restore();
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
fabric.ThinTailArrow.fromObject = (options, callback) => {
|
|
46
|
+
const { x1, x2, y1, y2 } = options;
|
|
47
|
+
return callback(new fabric.ThinTailArrow([x1, y1, x2, y2], options));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default fabric.ThinTailArrow;
|