customized-fabric 1.5.1 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/CurvedTextObject/constants.d.ts +11 -0
- package/lib/CurvedTextObject/constants.js +14 -0
- package/lib/CurvedTextObject/index.d.ts +58 -0
- package/lib/CurvedTextObject/index.js +225 -0
- package/lib/CurvedTextObject/interfaces.d.ts +27 -0
- package/lib/CurvedTextObject/interfaces.js +2 -0
- package/lib/ImagePlaceholderObject/index.js +2 -2
- package/lib/ImagePlaceholderObject/interfaces.d.ts +1 -0
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +8 -6
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +11 -0
- package/lib/utils/svg.util.d.ts +1 -0
- package/lib/utils/svg.util.js +11 -0
- package/package.json +1 -1
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PARENT_ATTRIBUTES = exports.CURVED_TEXT_OBJECT_ATTRIBUTES = void 0;
|
4
|
+
exports.CURVED_TEXT_OBJECT_ATTRIBUTES = {
|
5
|
+
name: "Curved text",
|
6
|
+
type: "CURVED_TEXT",
|
7
|
+
maxFontSize: 200,
|
8
|
+
stroke: {
|
9
|
+
stroke: "#000000",
|
10
|
+
strokeDashArray: [5, 5],
|
11
|
+
strokeWidth: 2,
|
12
|
+
},
|
13
|
+
};
|
14
|
+
exports.PARENT_ATTRIBUTES = ["top", "left", "width", "height", "angle"];
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { fabric } from "fabric";
|
2
|
+
import { ICurvedTextOptions } from "./interfaces";
|
3
|
+
import { ObjectId } from "../utils/objectId";
|
4
|
+
export declare const toCurvedTextObject: (object: CurvedText) => {
|
5
|
+
_id: ObjectId | undefined;
|
6
|
+
id: ObjectId | undefined;
|
7
|
+
personalizeId: number | undefined;
|
8
|
+
layerId: number | undefined;
|
9
|
+
name: string | undefined;
|
10
|
+
locked: boolean | undefined;
|
11
|
+
fontId: number | undefined;
|
12
|
+
fontCategoryId: string | undefined;
|
13
|
+
fontUrl: string | undefined;
|
14
|
+
isAdditional: boolean | undefined;
|
15
|
+
text: {
|
16
|
+
fontWeight: string | number | undefined;
|
17
|
+
fontSize: number | undefined;
|
18
|
+
textAlign: string | undefined;
|
19
|
+
text: string | undefined;
|
20
|
+
fill: string | fabric.Gradient | fabric.Pattern | undefined;
|
21
|
+
width: number | undefined;
|
22
|
+
height: number | undefined;
|
23
|
+
fontFamily: string | undefined;
|
24
|
+
maxFontSize: any;
|
25
|
+
stroke: string | undefined;
|
26
|
+
strokeWidth: number | undefined;
|
27
|
+
prefix: any;
|
28
|
+
infix: any;
|
29
|
+
suffix: any;
|
30
|
+
curvedWidth: any;
|
31
|
+
pathSide: any;
|
32
|
+
pathStartOffset: any;
|
33
|
+
};
|
34
|
+
};
|
35
|
+
export default class CurvedText extends fabric.Group {
|
36
|
+
_id?: ObjectId;
|
37
|
+
layerId?: number;
|
38
|
+
locked?: boolean;
|
39
|
+
textObject?: fabric.IText;
|
40
|
+
fontId?: number;
|
41
|
+
fontCategoryId?: string;
|
42
|
+
fontUrl?: string;
|
43
|
+
isAdditional?: boolean;
|
44
|
+
setText?: (text: string) => void;
|
45
|
+
setPrefix?: (text: string) => void;
|
46
|
+
setInfix?: (text: string) => void;
|
47
|
+
setSuffix?: (text: string) => void;
|
48
|
+
setMaxFontSize?: (fontSize: string) => void;
|
49
|
+
setFontFamily?: (fontName: string, fontUrl?: string) => void;
|
50
|
+
setTextAttributes?: (options: fabric.ITextOptions) => void;
|
51
|
+
getTextAttribute?: (attribute: string) => any;
|
52
|
+
getSettings?: (attribute: string) => any;
|
53
|
+
setSizes?: (options: {
|
54
|
+
width?: number;
|
55
|
+
height?: number;
|
56
|
+
}) => void;
|
57
|
+
constructor(options?: ICurvedTextOptions);
|
58
|
+
}
|
@@ -0,0 +1,225 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.toCurvedTextObject = void 0;
|
4
|
+
const fabric_1 = require("fabric");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
const utils_1 = require("../utils");
|
7
|
+
const objectId_1 = require("../utils/objectId");
|
8
|
+
const svg_util_1 = require("../utils/svg.util");
|
9
|
+
const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
10
|
+
initialize: function (options) {
|
11
|
+
const { text, ...rest } = options ?? {};
|
12
|
+
this.rectObject = new fabric_1.fabric.Rect({
|
13
|
+
width: options?.width,
|
14
|
+
height: options?.height,
|
15
|
+
fill: undefined,
|
16
|
+
originX: "center",
|
17
|
+
originY: "center",
|
18
|
+
objectCaching: false,
|
19
|
+
...constants_1.CURVED_TEXT_OBJECT_ATTRIBUTES.stroke,
|
20
|
+
});
|
21
|
+
this.textObject = new fabric_1.fabric.IText("", {
|
22
|
+
originX: "center",
|
23
|
+
originY: "center",
|
24
|
+
textAlign: "center",
|
25
|
+
objectCaching: false,
|
26
|
+
...text,
|
27
|
+
});
|
28
|
+
const group = new fabric_1.fabric.Group([this.rectObject, this.textObject]);
|
29
|
+
this.set(group);
|
30
|
+
this.on("scaling", () => {
|
31
|
+
let width = this.width * this.scaleX;
|
32
|
+
let height = this.height * this.scaleY;
|
33
|
+
const attributes = {
|
34
|
+
scaleX: 1,
|
35
|
+
scaleY: 1,
|
36
|
+
width,
|
37
|
+
height,
|
38
|
+
};
|
39
|
+
this.set(attributes);
|
40
|
+
this.rectObject.set(attributes);
|
41
|
+
this.calculateTextPath(width, height);
|
42
|
+
this.canvas?.renderAll?.();
|
43
|
+
});
|
44
|
+
this.set({
|
45
|
+
_id: new objectId_1.ObjectId().toString(),
|
46
|
+
name: constants_1.CURVED_TEXT_OBJECT_ATTRIBUTES.name,
|
47
|
+
type: constants_1.CURVED_TEXT_OBJECT_ATTRIBUTES.type,
|
48
|
+
...rest,
|
49
|
+
layerId: options?.personalizeId ?? options?.layerId,
|
50
|
+
objectCaching: false,
|
51
|
+
});
|
52
|
+
this.autoChangeFontSize(0.1);
|
53
|
+
this.calculateTextPath(this.width, this.height);
|
54
|
+
if (options?.isOriginal) {
|
55
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
if (options?.hideStroke) {
|
59
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
60
|
+
}
|
61
|
+
if (options?.fontUrl) {
|
62
|
+
(0, utils_1.loadFontFromUrl)(options?.fontUrl, text?.fontFamily ?? "").then(() => {
|
63
|
+
this.canvas?.renderAll?.();
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
},
|
68
|
+
autoChangeFontSize: function (changeSpeed) {
|
69
|
+
if (this.textObject.curvedWidth <= this.textObject.__lineWidths) {
|
70
|
+
while (this.textObject.curvedWidth <= this.textObject.__lineWidths) {
|
71
|
+
this.textObject.set({
|
72
|
+
fontSize: this.textObject.fontSize - changeSpeed,
|
73
|
+
});
|
74
|
+
this.canvas?.renderAll?.();
|
75
|
+
}
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
while (this.textObject.maxFontSize > this.textObject.fontSize &&
|
79
|
+
this.textObject.curvedWidth > this.textObject.__lineWidths) {
|
80
|
+
this.textObject.set({
|
81
|
+
fontSize: this.textObject.fontSize + changeSpeed,
|
82
|
+
});
|
83
|
+
this.canvas?.renderAll?.();
|
84
|
+
}
|
85
|
+
}
|
86
|
+
},
|
87
|
+
setText: function (text) {
|
88
|
+
this.textObject.set({
|
89
|
+
text,
|
90
|
+
});
|
91
|
+
this.canvas?.renderAll?.();
|
92
|
+
this.autoChangeFontSize(0.1);
|
93
|
+
},
|
94
|
+
setPrefix: function (text) {
|
95
|
+
this.textObject.set({
|
96
|
+
prefix: text,
|
97
|
+
});
|
98
|
+
this.getText();
|
99
|
+
},
|
100
|
+
setInfix: function (text) {
|
101
|
+
this.textObject.set({
|
102
|
+
infix: text,
|
103
|
+
});
|
104
|
+
this.getText();
|
105
|
+
},
|
106
|
+
setSuffix: function (text) {
|
107
|
+
this.textObject.set({
|
108
|
+
suffix: text,
|
109
|
+
});
|
110
|
+
this.getText();
|
111
|
+
},
|
112
|
+
getText: function () {
|
113
|
+
const { prefix = "", infix = "", suffix = "" } = this.textObject;
|
114
|
+
this.setText(infix?.length > 0 ? prefix + infix + suffix : "");
|
115
|
+
},
|
116
|
+
setMaxFontSize: function (fontSize) {
|
117
|
+
this.textObject.set({
|
118
|
+
fontSize,
|
119
|
+
});
|
120
|
+
this.canvas?.renderAll?.();
|
121
|
+
if (this.textObject.__lineWidths < this.textObject.curvedWidth) {
|
122
|
+
}
|
123
|
+
else {
|
124
|
+
this.autoChangeFontSize(1);
|
125
|
+
}
|
126
|
+
this.textObject.set({
|
127
|
+
maxFontSize: fontSize,
|
128
|
+
});
|
129
|
+
this.canvas?.renderAll?.();
|
130
|
+
},
|
131
|
+
setFontFamily: async function (fontName, fontUrl) {
|
132
|
+
if (!(0, utils_1.isFontLoaded)(fontName)) {
|
133
|
+
await (0, utils_1.loadFontFromUrl)(fontUrl ?? "", fontName);
|
134
|
+
}
|
135
|
+
this.textObject.set({ fontFamily: fontName });
|
136
|
+
this.canvas?.renderAll?.();
|
137
|
+
this.autoChangeFontSize(0.1);
|
138
|
+
this.canvas?.renderAll?.();
|
139
|
+
},
|
140
|
+
setSizes: function (options) {
|
141
|
+
const { width, height } = options;
|
142
|
+
if (width && width > this.textObject.__lineWidths) {
|
143
|
+
this.set({ width });
|
144
|
+
this.textObject.set({ width });
|
145
|
+
}
|
146
|
+
if (height && height > this.textObject.height) {
|
147
|
+
this.set({ height });
|
148
|
+
}
|
149
|
+
this.canvas?.renderAll?.();
|
150
|
+
},
|
151
|
+
setTextAttributes: function (options) {
|
152
|
+
this.textObject.set(options);
|
153
|
+
this.canvas?.renderAll?.();
|
154
|
+
},
|
155
|
+
getTextAttribute: function (attribute) {
|
156
|
+
return this.textObject.get(attribute);
|
157
|
+
},
|
158
|
+
getSettings: function (attribute) {
|
159
|
+
if (constants_1.PARENT_ATTRIBUTES.includes(attribute)) {
|
160
|
+
return this.get(attribute);
|
161
|
+
}
|
162
|
+
return this.textObject.get(attribute);
|
163
|
+
},
|
164
|
+
calculateTextPath: function (width, height) {
|
165
|
+
const pathSide = this.textObject.pathSide;
|
166
|
+
const textHeight = 0;
|
167
|
+
const rx = (width - textHeight) / 2;
|
168
|
+
const ry = (height - textHeight) / 2;
|
169
|
+
const path = new fabric_1.fabric.Path((0, svg_util_1.getEllipsePath)(rx, ry), {
|
170
|
+
fill: undefined,
|
171
|
+
stroke: "black",
|
172
|
+
objectCaching: false,
|
173
|
+
originX: "center",
|
174
|
+
originY: "center",
|
175
|
+
});
|
176
|
+
this.pathObject = path;
|
177
|
+
const pathInfo = fabric_1.fabric.util?.getPathSegmentsInfo?.(path.path);
|
178
|
+
this.textObject.set({
|
179
|
+
path,
|
180
|
+
pathLength: pathInfo?.[(pathInfo?.length ?? 0) - 1]?.length,
|
181
|
+
});
|
182
|
+
},
|
183
|
+
});
|
184
|
+
const toCurvedTextObject = (object) => {
|
185
|
+
const textObject = object.textObject;
|
186
|
+
return {
|
187
|
+
_id: object?._id,
|
188
|
+
id: object?._id,
|
189
|
+
personalizeId: object?.layerId,
|
190
|
+
layerId: object?.layerId,
|
191
|
+
name: object?.name,
|
192
|
+
locked: object?.locked,
|
193
|
+
fontId: object?.fontId,
|
194
|
+
fontCategoryId: object?.fontCategoryId,
|
195
|
+
fontUrl: object?.fontUrl,
|
196
|
+
isAdditional: object?.isAdditional,
|
197
|
+
text: {
|
198
|
+
fontWeight: textObject?.fontWeight,
|
199
|
+
fontSize: textObject?.fontSize,
|
200
|
+
textAlign: textObject?.textAlign,
|
201
|
+
text: textObject?.text,
|
202
|
+
fill: textObject?.fill,
|
203
|
+
width: textObject?.width,
|
204
|
+
height: textObject?.height,
|
205
|
+
fontFamily: textObject?.fontFamily,
|
206
|
+
maxFontSize: textObject?.maxFontSize,
|
207
|
+
stroke: textObject?.stroke,
|
208
|
+
strokeWidth: textObject?.strokeWidth,
|
209
|
+
prefix: textObject?.prefix,
|
210
|
+
infix: textObject?.infix,
|
211
|
+
suffix: textObject?.suffix,
|
212
|
+
curvedWidth: textObject?.curvedWidth,
|
213
|
+
pathSide: textObject?.pathSide,
|
214
|
+
pathStartOffset: textObject?.pathStartOffset,
|
215
|
+
},
|
216
|
+
};
|
217
|
+
};
|
218
|
+
exports.toCurvedTextObject = toCurvedTextObject;
|
219
|
+
class CurvedText extends fabric_1.fabric.Group {
|
220
|
+
constructor(options) {
|
221
|
+
super();
|
222
|
+
return new CurvedTextClass(options);
|
223
|
+
}
|
224
|
+
}
|
225
|
+
exports.default = CurvedText;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { ObjectId } from "../utils/objectId";
|
2
|
+
export interface ICurvedTextOptions extends fabric.IGroupOptions {
|
3
|
+
_id?: ObjectId;
|
4
|
+
personalizeId?: string;
|
5
|
+
layerId: number;
|
6
|
+
text: {
|
7
|
+
fontSize?: number;
|
8
|
+
fill?: string;
|
9
|
+
width?: number;
|
10
|
+
height?: number;
|
11
|
+
textAlign?: string;
|
12
|
+
fontWeight?: string;
|
13
|
+
text: string;
|
14
|
+
fontFamily?: string;
|
15
|
+
maxFontSize: number;
|
16
|
+
stroke?: string;
|
17
|
+
strokeWidth?: number;
|
18
|
+
prefix?: string;
|
19
|
+
infix?: string;
|
20
|
+
suffix?: string;
|
21
|
+
curvedWidth?: number;
|
22
|
+
};
|
23
|
+
fontUrl?: string;
|
24
|
+
isOriginal?: boolean;
|
25
|
+
isAdditional?: boolean;
|
26
|
+
hideStroke?: boolean;
|
27
|
+
}
|
@@ -230,9 +230,9 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
230
230
|
},
|
231
231
|
loadCustomizedImage: async function (image) {
|
232
232
|
if (image) {
|
233
|
-
const { url, data, clipPath } = image;
|
233
|
+
const { url, filteredUrl, data, clipPath } = image;
|
234
234
|
if (url && data && clipPath) {
|
235
|
-
const loadedImage = await (0, utils_1.loadImageFromUrl)(url);
|
235
|
+
const loadedImage = await (0, utils_1.loadImageFromUrl)(filteredUrl ?? url);
|
236
236
|
if (loadedImage) {
|
237
237
|
const mask = await this.getMask();
|
238
238
|
const { top, left, scaleX, width, angle, flipX, flipY, settings = {}, } = data;
|
package/lib/constants.d.ts
CHANGED
package/lib/constants.js
CHANGED
@@ -2,13 +2,15 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.OBJECT_TYPES = void 0;
|
4
4
|
const constants_1 = require("./ClipartObject/constants");
|
5
|
-
const constants_2 = require("./
|
6
|
-
const constants_3 = require("./
|
7
|
-
const constants_4 = require("./
|
5
|
+
const constants_2 = require("./CurvedTextObject/constants");
|
6
|
+
const constants_3 = require("./ImagePlaceholderObject/constants");
|
7
|
+
const constants_4 = require("./LayoutGroupObject/constants");
|
8
|
+
const constants_5 = require("./TextInputObject/constants");
|
8
9
|
exports.OBJECT_TYPES = {
|
9
|
-
textInput:
|
10
|
+
textInput: constants_5.TEXT_INPUT_OBJECT_ATTRIBUTES.type,
|
11
|
+
curvedText: constants_2.CURVED_TEXT_OBJECT_ATTRIBUTES.type,
|
10
12
|
clipart: constants_1.CLIPART_OBJECT_ATTRIBUTES.type,
|
11
|
-
imagePlaceHolder:
|
13
|
+
imagePlaceHolder: constants_3.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES.type,
|
12
14
|
activeSelection: "activeSelection",
|
13
|
-
layoutGroup:
|
15
|
+
layoutGroup: constants_4.LAYOUT_GROUP_OBJECT_ATTRIBUTES.type,
|
14
16
|
};
|
package/lib/index.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import TextInput from "./TextInputObject";
|
2
|
+
import CurvedText from "./CurvedTextObject";
|
2
3
|
import Clipart from "./ClipartObject";
|
3
4
|
import ImagePlaceholder from "./ImagePlaceholderObject";
|
4
5
|
import fabric, { lockObject, lockAllObjects, loadImageFromFile, loadImageFromUrl, getObject, asyncGetObject } from "./utils";
|
5
6
|
import { OBJECT_TYPES } from "./constants";
|
6
7
|
import { IMAGE_FILTER_TYPES } from "./ImagePlaceholderObject/constants";
|
7
8
|
import LayoutGroup from "./LayoutGroupObject";
|
8
|
-
export { fabric, TextInput, Clipart, ImagePlaceholder, LayoutGroup, lockObject, lockAllObjects, loadImageFromFile, loadImageFromUrl, getObject, asyncGetObject, OBJECT_TYPES, IMAGE_FILTER_TYPES, };
|
9
|
+
export { fabric, TextInput, Clipart, ImagePlaceholder, LayoutGroup, CurvedText, lockObject, lockAllObjects, loadImageFromFile, loadImageFromUrl, getObject, asyncGetObject, OBJECT_TYPES, IMAGE_FILTER_TYPES, };
|
package/lib/index.js
CHANGED
@@ -26,9 +26,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.IMAGE_FILTER_TYPES = exports.OBJECT_TYPES = exports.asyncGetObject = exports.getObject = exports.loadImageFromUrl = exports.loadImageFromFile = exports.lockAllObjects = exports.lockObject = exports.LayoutGroup = exports.ImagePlaceholder = exports.Clipart = exports.TextInput = exports.fabric = void 0;
|
29
|
+
exports.IMAGE_FILTER_TYPES = exports.OBJECT_TYPES = exports.asyncGetObject = exports.getObject = exports.loadImageFromUrl = exports.loadImageFromFile = exports.lockAllObjects = exports.lockObject = exports.CurvedText = exports.LayoutGroup = exports.ImagePlaceholder = exports.Clipart = exports.TextInput = exports.fabric = void 0;
|
30
30
|
const TextInputObject_1 = __importDefault(require("./TextInputObject"));
|
31
31
|
exports.TextInput = TextInputObject_1.default;
|
32
|
+
const CurvedTextObject_1 = __importDefault(require("./CurvedTextObject"));
|
33
|
+
exports.CurvedText = CurvedTextObject_1.default;
|
32
34
|
const ClipartObject_1 = __importDefault(require("./ClipartObject"));
|
33
35
|
exports.Clipart = ClipartObject_1.default;
|
34
36
|
const ImagePlaceholderObject_1 = __importDefault(require("./ImagePlaceholderObject"));
|
package/lib/utils/index.d.ts
CHANGED
@@ -3,6 +3,7 @@ import Clipart from "../ClipartObject";
|
|
3
3
|
import ImagePlaceholder from "../ImagePlaceholderObject";
|
4
4
|
import TextInput from "../TextInputObject";
|
5
5
|
import { ImageFilterType } from "../ImagePlaceholderObject/interfaces";
|
6
|
+
import CurvedText from "../CurvedTextObject";
|
6
7
|
export declare const loadFontFromUrl: (url: string, name: string) => Promise<void>;
|
7
8
|
export declare const isFontLoaded: (name: string) => boolean;
|
8
9
|
export declare const loadImageFromFile: (image: File) => Promise<fabric.Image>;
|
@@ -16,7 +17,7 @@ export declare const lockAllObjects: (canvas: fabric.Canvas, locked: boolean, se
|
|
16
17
|
export declare const getObject: (object: any, options?: {
|
17
18
|
isOriginal?: boolean;
|
18
19
|
hideStroke?: boolean;
|
19
|
-
}) => Clipart | ImagePlaceholder | TextInput | undefined;
|
20
|
+
}) => Clipart | ImagePlaceholder | CurvedText | TextInput | undefined;
|
20
21
|
export declare const asyncGetObject: (object: any, options?: {
|
21
22
|
isOriginal?: boolean;
|
22
23
|
}) => Promise<fabric.Image | Clipart | ImagePlaceholder | TextInput | undefined>;
|
package/lib/utils/index.js
CHANGED
@@ -29,6 +29,7 @@ const constants_1 = require("../constants");
|
|
29
29
|
const ClipartObject_1 = __importStar(require("../ClipartObject"));
|
30
30
|
const ImagePlaceholderObject_1 = __importStar(require("../ImagePlaceholderObject"));
|
31
31
|
const TextInputObject_1 = __importStar(require("../TextInputObject"));
|
32
|
+
const CurvedTextObject_1 = __importStar(require("../CurvedTextObject"));
|
32
33
|
const loadFontFromUrl = async (url, name) => {
|
33
34
|
if (!name || !url)
|
34
35
|
return;
|
@@ -148,6 +149,13 @@ const getObject = (object, options) => {
|
|
148
149
|
});
|
149
150
|
return imagePlaceHolderObject;
|
150
151
|
}
|
152
|
+
case constants_1.OBJECT_TYPES.curvedText: {
|
153
|
+
const curvedTextObject = new CurvedTextObject_1.default({
|
154
|
+
...object,
|
155
|
+
...options,
|
156
|
+
});
|
157
|
+
return curvedTextObject;
|
158
|
+
}
|
151
159
|
default:
|
152
160
|
return;
|
153
161
|
}
|
@@ -217,6 +225,9 @@ fabric_1.fabric.Object.prototype.toObject = (function (toObject) {
|
|
217
225
|
case constants_1.OBJECT_TYPES.imagePlaceHolder: {
|
218
226
|
return fabric_1.fabric.util.object.extend(toObject.call(this), (0, ImagePlaceholderObject_1.toImagePlaceholderObject)(this));
|
219
227
|
}
|
228
|
+
case constants_1.OBJECT_TYPES.curvedText: {
|
229
|
+
return fabric_1.fabric.util.object.extend(toObject.call(this), (0, CurvedTextObject_1.toCurvedTextObject)(this));
|
230
|
+
}
|
220
231
|
default: {
|
221
232
|
return {};
|
222
233
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getEllipsePath: (rx: number, ry: number) => string;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getEllipsePath = void 0;
|
4
|
+
const getEllipsePath = (rx, ry) => {
|
5
|
+
let output = `M 0,0`;
|
6
|
+
output += `a ${rx},${ry} 0 0,1 0,${ry * -2}`;
|
7
|
+
output += " ";
|
8
|
+
output += `a ${rx},${ry} 0 0,1 0,${ry * 2}`;
|
9
|
+
return output;
|
10
|
+
};
|
11
|
+
exports.getEllipsePath = getEllipsePath;
|