1 |
|
2 |
|
3 |
|
4 | export as namespace fabric;
|
5 |
|
6 | export const isLikelyNode: boolean;
|
7 | export const isTouchSupported: boolean;
|
8 | export const version: string;
|
9 | export const iMatrix: number[];
|
10 | export let textureSize: number;
|
11 | export let copiedText: string;
|
12 | export let copiedTextStyle: any[];
|
13 | export let charWidthsCache: {
|
14 | [key: string]: {
|
15 | [key: string]: {
|
16 | [key: string]: number;
|
17 | }
|
18 | }
|
19 | };
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | export function createCanvasForNode(width: number, height: number): Canvas;
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export function createSVGRefElementsMarkup(canvas: StaticCanvas): string;
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | export function createSVGFontFacesMarkup(objects: Object[]): string;
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | export function loadSVGFromString(
|
44 | string: string,
|
45 | callback: (results: Object[], options: any) => void,
|
46 | reviver?: Function,
|
47 | ): void;
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | export function loadSVGFromURL(
|
59 | url: string,
|
60 | callback: (results: Object[], options: any) => void,
|
61 | reviver?: Function,
|
62 | options?: { crossOrigin?: string | undefined },
|
63 | ): void;
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | export function getCSSRules(doc: SVGElement): any;
|
69 |
|
70 | export function parseElements(elements: any[], callback: Function, options: any, reviver?: Function): void;
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | export function parsePointsAttribute(points: string): any[];
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | export function parseStyleAttribute(element: SVGElement): any;
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | export function parseElements(elements: SVGElement[], callback: Function, options?: any, reviver?: Function): void;
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | export function parseAttributes(element: HTMLElement, attributes: string[], svgUid?: string): { [key: string]: string };
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | export function getGradientDefs(doc: SVGElement): { [key: string]: any };
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | export function parseFontDeclaration(value: string, oStyle: any): void;
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | export function parseSVGDocument(
|
114 | doc: SVGElement,
|
115 | callback: (results: Object[], options: any) => void,
|
116 | reviver?: Function,
|
117 | ): void;
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | export function parseTransformAttribute(attributeValue: string): number[];
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | export function log(...values: any[]): void;
|
130 |
|
131 |
|
132 |
|
133 | export function warn(...values: any[]): void;
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | interface IDataURLOptions {
|
140 | |
141 |
|
142 |
|
143 | format?: string | undefined;
|
144 | |
145 |
|
146 |
|
147 | quality?: number | undefined;
|
148 | |
149 |
|
150 |
|
151 | multiplier?: number | undefined;
|
152 | |
153 |
|
154 |
|
155 | left?: number | undefined;
|
156 | |
157 |
|
158 |
|
159 | top?: number | undefined;
|
160 | |
161 |
|
162 |
|
163 | width?: number | undefined;
|
164 | |
165 |
|
166 |
|
167 | height?: number | undefined;
|
168 | enableRetinaScaling?: boolean | undefined;
|
169 | withoutTransform?: boolean | undefined;
|
170 | withoutShadow?: boolean | undefined;
|
171 | }
|
172 |
|
173 | interface IEvent {
|
174 | e: Event;
|
175 | target?: Object | undefined;
|
176 | subTargets?: Object[] | undefined;
|
177 | button?: number | undefined;
|
178 | isClick?: boolean | undefined;
|
179 | pointer?: Point | undefined;
|
180 | absolutePointer?: Point | undefined;
|
181 | transform?: { corner: string; original: Object; originX: string; originY: string; width: number } | undefined;
|
182 | }
|
183 |
|
184 | interface IFillOptions {
|
185 | |
186 |
|
187 |
|
188 | source: string | HTMLImageElement;
|
189 | |
190 |
|
191 |
|
192 | repeat?: string | undefined;
|
193 | |
194 |
|
195 |
|
196 | offsetX?: number | undefined;
|
197 | |
198 |
|
199 |
|
200 | offsetY?: number | undefined;
|
201 | }
|
202 |
|
203 | interface IToSVGOptions {
|
204 | |
205 |
|
206 |
|
207 | suppressPreamble?: boolean | undefined;
|
208 | |
209 |
|
210 |
|
211 | viewBox?: IViewBox | undefined;
|
212 | |
213 |
|
214 |
|
215 | encoding?: string | undefined;
|
216 | |
217 |
|
218 |
|
219 | width?: number | string | undefined;
|
220 | |
221 |
|
222 |
|
223 | height?: number | string | undefined;
|
224 | }
|
225 |
|
226 | interface IViewBox {
|
227 | |
228 |
|
229 |
|
230 | x: number;
|
231 | |
232 |
|
233 |
|
234 | y: number;
|
235 | |
236 |
|
237 |
|
238 | width: number;
|
239 | |
240 |
|
241 |
|
242 | height: number;
|
243 | }
|
244 |
|
245 |
|
246 |
|
247 |
|
248 | interface ICollection<T> {
|
249 | _objects: Object[];
|
250 |
|
251 | |
252 |
|
253 |
|
254 |
|
255 |
|
256 | add(...object: Object[]): T;
|
257 |
|
258 | |
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 | insertAt(object: Object, index: number, nonSplicing: boolean): T;
|
268 |
|
269 | |
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 | remove(...object: Object[]): T;
|
276 |
|
277 | |
278 |
|
279 |
|
280 |
|
281 |
|
282 | forEachObject(callback: (element: Object, index: number, array: Object[]) => void, context?: any): T;
|
283 |
|
284 | |
285 |
|
286 |
|
287 |
|
288 |
|
289 | getObjects(type?: string): Object[];
|
290 |
|
291 | |
292 |
|
293 |
|
294 |
|
295 | item(index: number): T;
|
296 |
|
297 | |
298 |
|
299 |
|
300 |
|
301 | isEmpty(): boolean;
|
302 |
|
303 | |
304 |
|
305 |
|
306 |
|
307 | size(): number;
|
308 |
|
309 | |
310 |
|
311 |
|
312 |
|
313 |
|
314 | contains(object: Object): boolean;
|
315 |
|
316 | |
317 |
|
318 |
|
319 |
|
320 | complexity(): number;
|
321 | }
|
322 |
|
323 | interface IObservable<T> {
|
324 | |
325 |
|
326 |
|
327 |
|
328 |
|
329 | on(eventName: string, handler: (e: IEvent) => void): T;
|
330 |
|
331 | |
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 | off(eventName?: string | any, handler?: (e: IEvent) => void): T;
|
338 |
|
339 | |
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 | fire(eventName: string, options?: any): T;
|
348 | }
|
349 |
|
350 | interface Callbacks {
|
351 |
|
352 | onComplete?: Function | undefined;
|
353 |
|
354 | onChange?: Function | undefined;
|
355 | }
|
356 |
|
357 |
|
358 |
|
359 | interface ICanvasAnimation<T> {
|
360 | FX_DURATION: number;
|
361 | |
362 |
|
363 |
|
364 |
|
365 | fxCenterObjectH(object: Object, callbacks?: Callbacks): T;
|
366 |
|
367 | |
368 |
|
369 |
|
370 |
|
371 | fxCenterObjectV(object: Object, callbacks?: Callbacks): T;
|
372 |
|
373 | |
374 |
|
375 |
|
376 |
|
377 |
|
378 | fxRemove(object: Object): T;
|
379 |
|
380 | |
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 | fxStraightenObject(object: Object): T;
|
387 | }
|
388 | interface IObjectAnimation<T> {
|
389 | |
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 | animate(property: string, value: number | string, options?: IAnimationOptions): Object;
|
397 | |
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 | animate(properties: { [key: string]: number | string }, options?: IAnimationOptions): Object;
|
404 | }
|
405 | interface IAnimationOptions {
|
406 | |
407 |
|
408 |
|
409 | from?: string | number | undefined;
|
410 | |
411 |
|
412 |
|
413 | duration?: number | undefined;
|
414 | |
415 |
|
416 |
|
417 | onChange?: Function | undefined;
|
418 | |
419 |
|
420 |
|
421 | onComplete?: Function | undefined;
|
422 |
|
423 | |
424 |
|
425 |
|
426 | easing?: Function | undefined;
|
427 | |
428 |
|
429 |
|
430 | by?: number | undefined;
|
431 | }
|
432 |
|
433 |
|
434 |
|
435 |
|
436 | export class Color {
|
437 | |
438 |
|
439 |
|
440 |
|
441 |
|
442 | constructor(color?: string);
|
443 |
|
444 | /**
|
445 | * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])
|
446 | */
|
447 | getSource(): number[];
|
448 |
|
449 | /**
|
450 | * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
|
451 | */
|
452 | setSource(source: number[]): void;
|
453 |
|
454 | /**
|
455 | * Returns color represenation in RGB format ex: rgb(0-255,0-255,0-255)
|
456 | */
|
457 | toRgb(): string;
|
458 |
|
459 | /**
|
460 | * Returns color represenation in RGBA format ex: rgba(0-255,0-255,0-255,0-1)
|
461 | */
|
462 | toRgba(): string;
|
463 |
|
464 | /**
|
465 | * Returns color represenation in HSL format ex: hsl(0-360,0%-100%,0%-100%)
|
466 | */
|
467 | toHsl(): string;
|
468 |
|
469 | /**
|
470 | * Returns color represenation in HSLA format ex: hsla(0-360,0%-100%,0%-100%,0-1)
|
471 | */
|
472 | toHsla(): string;
|
473 |
|
474 | /**
|
475 | * Returns color represenation in HEX format ex: FF5555
|
476 | */
|
477 | toHex(): string;
|
478 |
|
479 | /**
|
480 | * Returns color representation in HEXA format
|
481 | * @return {String} ex: FF5555CC
|
482 | */
|
483 | toHexa(): string;
|
484 |
|
485 | |
486 |
|
487 |
|
488 | getAlpha(): number;
|
489 |
|
490 | |
491 |
|
492 |
|
493 |
|
494 | setAlpha(alpha: number): void;
|
495 |
|
496 | |
497 |
|
498 |
|
499 | toGrayscale(): Color;
|
500 |
|
501 | |
502 |
|
503 |
|
504 | toBlackWhite(threshold: number): Color;
|
505 | |
506 |
|
507 |
|
508 | overlayWith(otherColor: string | Color): Color;
|
509 |
|
510 | |
511 |
|
512 |
|
513 |
|
514 | static fromRgb(color: string): Color;
|
515 | |
516 |
|
517 |
|
518 |
|
519 | static fromRgba(color: string): Color;
|
520 | |
521 |
|
522 |
|
523 |
|
524 | static sourceFromRgb(color: string): number[];
|
525 | |
526 |
|
527 |
|
528 |
|
529 | static fromHsl(color: string): Color;
|
530 | |
531 |
|
532 |
|
533 |
|
534 | static fromHsla(color: string): Color;
|
535 | |
536 |
|
537 |
|
538 |
|
539 | static sourceFromHsl(color: string): number[];
|
540 | |
541 |
|
542 |
|
543 |
|
544 | static fromHex(color: string): Color;
|
545 |
|
546 | |
547 |
|
548 |
|
549 |
|
550 | static sourceFromHex(color: string): number[];
|
551 | |
552 |
|
553 |
|
554 | static fromSource(source: number[]): Color;
|
555 | |
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 | static reHex: RegExp;
|
562 | |
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 | static reHSLa: RegExp;
|
569 | |
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 | static reRGBa: RegExp;
|
576 | }
|
577 |
|
578 | interface IGradientOptionsCoords {
|
579 | x1?: number | undefined;
|
580 | y1?: number | undefined;
|
581 | x2?: number | undefined;
|
582 | y2?: number | undefined;
|
583 | r1?: number | undefined;
|
584 | r2?: number | undefined;
|
585 | }
|
586 |
|
587 | type IGradientOptionsColorStops = Array<{
|
588 | offset: number;
|
589 | color: string;
|
590 | }>;
|
591 |
|
592 | interface IGradientOptions {
|
593 | |
594 |
|
595 |
|
596 |
|
597 | offsetX?: number | undefined;
|
598 | |
599 |
|
600 |
|
601 |
|
602 | offsetY?: number | undefined;
|
603 | type?: string | undefined;
|
604 | coords?: IGradientOptionsCoords | undefined;
|
605 | |
606 |
|
607 |
|
608 | colorStops?: IGradientOptionsColorStops | undefined;
|
609 | gradientTransform?: any;
|
610 | }
|
611 |
|
612 | interface OGradientOptions {
|
613 | type?: string | undefined;
|
614 | x1?: number | undefined;
|
615 | y1?: number | undefined;
|
616 | x2?: number | undefined;
|
617 | y2?: number | undefined;
|
618 | r1?: number | undefined;
|
619 | r2?: number | undefined;
|
620 | colorStops?: {
|
621 | [key: string]: string;
|
622 | } | undefined;
|
623 | gradientTransform?: any;
|
624 | }
|
625 |
|
626 | export interface Gradient extends IGradientOptions {}
|
627 | export class Gradient {
|
628 | |
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 | constructor(options: {
|
646 | type?: string | undefined;
|
647 | gradientUnits?: any;
|
648 | offsetX?: any;
|
649 | offsetY?: any;
|
650 | colorStops?: IGradientOptionsColorStops | undefined;
|
651 | coords?: IGradientOptionsCoords | undefined;
|
652 | });
|
653 | /**
|
654 | * Adds another colorStop
|
655 | * @param colorStop Object with offset and color
|
656 | */
|
657 | addColorStop(colorStop: any): Gradient;
|
658 | /**
|
659 | * Returns object representation of a gradient
|
660 | */
|
661 | toObject(propertiesToInclude?: any): any;
|
662 | /**
|
663 | * Returns SVG representation of an gradient
|
664 | * @param {Object} object Object to create a gradient for
|
665 | * @return {String} SVG representation of an gradient (linear/radial)
|
666 | */
|
667 | toSVG(object: any): string;
|
668 | |
669 |
|
670 |
|
671 |
|
672 | toLive(ctx: CanvasRenderingContext2D): CanvasGradient;
|
673 | |
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | static fromElement(el: SVGGradientElement, instance: Object): Gradient;
|
684 | }
|
685 | export class Intersection {
|
686 | constructor(status?: string);
|
687 | /**
|
688 | * Appends a point to intersection
|
689 | */
|
690 | appendPoint(point: Point): Intersection;
|
691 | /**
|
692 | * Appends points to intersection
|
693 | */
|
694 | appendPoints(points: Point[]): Intersection;
|
695 | /**
|
696 | * Checks if one line intersects another
|
697 | */
|
698 | static intersectLineLine(a1: Point, a2: Point, b1: Point, b2: Point): Intersection;
|
699 | /**
|
700 | * Checks if line intersects polygon
|
701 | */
|
702 | static intersectLinePolygon(a1: Point, a2: Point, points: Point[]): Intersection;
|
703 | /**
|
704 | * Checks if polygon intersects another polygon
|
705 | */
|
706 | static intersectPolygonPolygon(points1: Point[], points2: Point[]): Intersection;
|
707 | /**
|
708 | * Checks if polygon intersects rectangle
|
709 | */
|
710 | static intersectPolygonRectangle(points: Point[], r1: number, r2: number): Intersection;
|
711 | }
|
712 |
|
713 | interface IPatternOptions {
|
714 | |
715 |
|
716 |
|
717 | repeat?: string | undefined;
|
718 |
|
719 | |
720 |
|
721 |
|
722 | offsetX?: number | undefined;
|
723 |
|
724 | |
725 |
|
726 |
|
727 | offsetY?: number | undefined;
|
728 | |
729 |
|
730 |
|
731 |
|
732 |
|
733 | crossOrigin?: '' | 'anonymous' | 'use-credentials' | undefined;
|
734 | |
735 |
|
736 |
|
737 | patternTransform?: number[] | undefined;
|
738 | |
739 |
|
740 |
|
741 | source: string | HTMLImageElement;
|
742 | }
|
743 | export interface Pattern extends IPatternOptions {}
|
744 | export class Pattern {
|
745 | |
746 |
|
747 |
|
748 | id: number;
|
749 |
|
750 | constructor(options?: IPatternOptions);
|
751 | /**
|
752 | * Returns object representation of a pattern
|
753 | * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output
|
754 | * @return {Object} Object representation of a pattern instance
|
755 | */
|
756 | toObject(propertiesToInclude: any): any;
|
757 | |
758 |
|
759 |
|
760 |
|
761 |
|
762 | toSVG(object: Object): string;
|
763 | setOptions(options: IPatternOptions): void;
|
764 | |
765 |
|
766 |
|
767 |
|
768 |
|
769 | toLive(ctx: CanvasRenderingContext2D): CanvasPattern;
|
770 | }
|
771 | export class Point {
|
772 | x: number;
|
773 | y: number;
|
774 | type: string;
|
775 | constructor(x: number, y: number);
|
776 | /**
|
777 | * Adds another point to this one and returns another one
|
778 | * @param {fabric.Point} that
|
779 | * @return {fabric.Point} new Point instance with added values
|
780 | */
|
781 | add(that: Point): Point;
|
782 | |
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 | addEquals(that: Point): Point;
|
789 | |
790 |
|
791 |
|
792 |
|
793 |
|
794 | scalarAdd(scalar: number): Point;
|
795 | |
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 | scalarAddEquals(scalar: number): Point;
|
802 | |
803 |
|
804 |
|
805 |
|
806 |
|
807 | subtract(that: Point): Point;
|
808 | |
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 | subtractEquals(that: Point): Point;
|
815 | |
816 |
|
817 |
|
818 |
|
819 |
|
820 | scalarSubtract(scalar: number): Point;
|
821 | |
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 | scalarSubtractEquals(scalar: number): Point;
|
828 | |
829 |
|
830 |
|
831 |
|
832 |
|
833 | multiply(scalar: number): Point;
|
834 | |
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 | multiplyEquals(scalar: number): Point;
|
841 | |
842 |
|
843 |
|
844 |
|
845 |
|
846 | divide(scalar: number): Point;
|
847 | |
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 | divideEquals(scalar: number): Point;
|
854 | |
855 |
|
856 |
|
857 |
|
858 |
|
859 | eq(that: Point): Point;
|
860 | |
861 |
|
862 |
|
863 |
|
864 |
|
865 | lt(that: Point): Point;
|
866 | |
867 |
|
868 |
|
869 |
|
870 |
|
871 | lte(that: Point): Point;
|
872 | |
873 |
|
874 |
|
875 |
|
876 |
|
877 | gt(that: Point): Point;
|
878 | |
879 |
|
880 |
|
881 |
|
882 |
|
883 | gte(that: Point): Point;
|
884 | |
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 | lerp(that: Point, t: number): Point;
|
891 | |
892 |
|
893 |
|
894 |
|
895 |
|
896 | distanceFrom(that: Point): number;
|
897 | |
898 |
|
899 |
|
900 |
|
901 |
|
902 | midPointFrom(that: Point): Point;
|
903 | |
904 |
|
905 |
|
906 |
|
907 |
|
908 | min(that: Point): Point;
|
909 | |
910 |
|
911 |
|
912 |
|
913 |
|
914 | max(that: Point): Point;
|
915 | |
916 |
|
917 |
|
918 |
|
919 | toString(): string;
|
920 | |
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 | setXY(x: number, y: number): Point;
|
927 | |
928 |
|
929 |
|
930 |
|
931 |
|
932 | setX(x: number): Point;
|
933 | |
934 |
|
935 |
|
936 |
|
937 |
|
938 | setY(y: number): Point;
|
939 | |
940 |
|
941 |
|
942 |
|
943 |
|
944 | setFromPoint(that: Point): Point;
|
945 | |
946 |
|
947 |
|
948 |
|
949 | swap(that: Point): Point;
|
950 | |
951 |
|
952 |
|
953 |
|
954 | clone(): Point;
|
955 | }
|
956 | interface IShadowOptions {
|
957 | |
958 |
|
959 |
|
960 | color?: string | undefined;
|
961 | |
962 |
|
963 |
|
964 | blur?: number | undefined;
|
965 | |
966 |
|
967 |
|
968 | offsetX?: number | undefined;
|
969 | |
970 |
|
971 |
|
972 | offsetY?: number | undefined;
|
973 | |
974 |
|
975 |
|
976 | affectStroke?: boolean | undefined;
|
977 | |
978 |
|
979 |
|
980 | includeDefaultValues?: boolean | undefined;
|
981 | |
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 | nonScaling?: boolean | undefined;
|
989 | }
|
990 | export interface Shadow extends IShadowOptions {}
|
991 | export class Shadow {
|
992 | constructor(options?: IShadowOptions | string);
|
993 | initialize(options?: IShadowOptions | string): Shadow;
|
994 | /**
|
995 | * Returns a string representation of an instance
|
996 | * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow
|
997 | * @return {String} Returns CSS3 text-shadow declaration
|
998 | */
|
999 | toString(): string;
|
1000 | |
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 | toSVG(object: Object): string;
|
1006 | |
1007 |
|
1008 |
|
1009 |
|
1010 | toObject(): any;
|
1011 | |
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 | static reOffsetsAndBlur: RegExp;
|
1018 | }
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 | interface ICanvasDimensions {
|
1024 | |
1025 |
|
1026 |
|
1027 | width: number | string;
|
1028 | |
1029 |
|
1030 |
|
1031 | height: number | string;
|
1032 | }
|
1033 | interface ICanvasDimensionsOptions {
|
1034 | |
1035 |
|
1036 |
|
1037 | backstoreOnly?: boolean | undefined;
|
1038 | |
1039 |
|
1040 |
|
1041 | cssOnly?: boolean | undefined;
|
1042 | }
|
1043 |
|
1044 | interface IStaticCanvasOptions {
|
1045 | |
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 | backgroundColor?: string | Pattern | undefined;
|
1051 | |
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 | backgroundImage?: Image | string | undefined;
|
1063 | |
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 | overlayColor?: string | Pattern | undefined;
|
1070 | |
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 | overlayImage?: Image | undefined;
|
1082 | |
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 | includeDefaultValues?: boolean | undefined;
|
1088 | |
1089 |
|
1090 |
|
1091 |
|
1092 | stateful?: boolean | undefined;
|
1093 | |
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 | renderOnAddRemove?: boolean | undefined;
|
1103 | |
1104 |
|
1105 |
|
1106 |
|
1107 | controlsAboveOverlay?: boolean | undefined;
|
1108 | |
1109 |
|
1110 |
|
1111 |
|
1112 | allowTouchScrolling?: boolean | undefined;
|
1113 | |
1114 |
|
1115 |
|
1116 | imageSmoothingEnabled?: boolean | undefined;
|
1117 | |
1118 |
|
1119 |
|
1120 | viewportTransform?: number[] | undefined;
|
1121 | |
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 | backgroundVpt?: boolean | undefined;
|
1127 | |
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 | overlayVpt?: boolean | undefined;
|
1133 | |
1134 |
|
1135 |
|
1136 |
|
1137 | enableRetinaScaling?: boolean | undefined;
|
1138 | |
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 | vptCoords?: {
|
1148 | tl: { x: number; y: number };
|
1149 | tr: { x: number; y: number };
|
1150 | bl: { x: number; y: number };
|
1151 | br: { x: number; y: number };
|
1152 | } | undefined;
|
1153 | |
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 | skipOffscreen?: boolean | undefined;
|
1163 | |
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 | clipPath?: Object | undefined;
|
1171 | |
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 | svgViewportTransformation?: boolean | undefined;
|
1177 | }
|
1178 |
|
1179 | export interface FreeDrawingBrush {
|
1180 | |
1181 |
|
1182 |
|
1183 | color: string;
|
1184 |
|
1185 | |
1186 |
|
1187 |
|
1188 | width: number;
|
1189 | }
|
1190 |
|
1191 | export interface StaticCanvas
|
1192 | extends IObservable<StaticCanvas>,
|
1193 | IStaticCanvasOptions,
|
1194 | ICollection<StaticCanvas>,
|
1195 | ICanvasAnimation<StaticCanvas> {}
|
1196 | export class StaticCanvas {
|
1197 | |
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 | constructor(element: HTMLCanvasElement | string | null, options?: ICanvasOptions);
|
1204 |
|
1205 | _activeObject?: Object | Group | undefined;
|
1206 |
|
1207 | freeDrawingBrush: FreeDrawingBrush;
|
1208 |
|
1209 | /**
|
1210 | * Calculates canvas element offset relative to the document
|
1211 | * This method is also attached as "resize" event handler of window
|
1212 | * @return {fabric.Canvas} instance
|
1213 | * @chainable
|
1214 | */
|
1215 | calcOffset(): Canvas;
|
1216 |
|
1217 | |
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 | setOverlayImage(image: Image | string, callback: Function, options?: IImageOptions): Canvas;
|
1226 |
|
1227 | |
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 | setBackgroundImage(image: Image | string, callback: Function, options?: IImageOptions): Canvas;
|
1236 |
|
1237 | |
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 | setOverlayColor(overlayColor: string | Pattern, callback: Function): Canvas;
|
1245 |
|
1246 | |
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 | setBackgroundColor(backgroundColor: string | Pattern | Gradient, callback: Function): Canvas;
|
1254 |
|
1255 | |
1256 |
|
1257 |
|
1258 |
|
1259 | getWidth(): number;
|
1260 |
|
1261 | |
1262 |
|
1263 |
|
1264 |
|
1265 | getHeight(): number;
|
1266 |
|
1267 | |
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 | setWidth(value: number | string, options?: ICanvasDimensionsOptions): Canvas;
|
1275 |
|
1276 | |
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 | setHeight(value: number | string, options?: ICanvasDimensionsOptions): Canvas;
|
1284 |
|
1285 | |
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 | setDimensions(dimensions: ICanvasDimensions, options?: ICanvasDimensionsOptions): Canvas;
|
1293 |
|
1294 | |
1295 |
|
1296 |
|
1297 | getZoom(): number;
|
1298 |
|
1299 | |
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 | setViewportTransform(vpt: number[]): Canvas;
|
1306 |
|
1307 | |
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 | zoomToPoint(point: Point, value: number): Canvas;
|
1315 |
|
1316 | |
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 | setZoom(value: number): Canvas;
|
1323 |
|
1324 | |
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 | absolutePan(point: Point): Canvas;
|
1331 |
|
1332 | |
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 | relativePan(point: Point): Canvas;
|
1339 |
|
1340 | |
1341 |
|
1342 |
|
1343 |
|
1344 | getElement(): HTMLCanvasElement;
|
1345 |
|
1346 | |
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 | clearContext(ctx: CanvasRenderingContext2D): Canvas;
|
1352 |
|
1353 | |
1354 |
|
1355 |
|
1356 |
|
1357 | getContext(): CanvasRenderingContext2D;
|
1358 |
|
1359 | |
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 | clear(): Canvas;
|
1365 |
|
1366 | |
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 | renderAll(): Canvas;
|
1372 |
|
1373 | |
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 | renderAndReset(): Canvas;
|
1384 |
|
1385 | |
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 | requestRenderAll(): Canvas;
|
1393 |
|
1394 | |
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 | calcViewportBoundaries(): { tl: Point; br: Point; tr: Point; bl: Point };
|
1402 |
|
1403 | |
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 | renderCanvas(ctx: CanvasRenderingContext2D, objects: Object[]): Canvas;
|
1411 |
|
1412 | |
1413 |
|
1414 |
|
1415 |
|
1416 | drawClipPathOnCanvas(ctx: CanvasRenderingContext2D): void;
|
1417 |
|
1418 | |
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 | getCenter(): { top: number; left: number };
|
1424 |
|
1425 | |
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 | centerObjectH(object: Object): Canvas;
|
1431 |
|
1432 | |
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 | centerObjectV(object: Object): Canvas;
|
1439 |
|
1440 | |
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 | centerObject(object: Object): Canvas;
|
1447 |
|
1448 | |
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 | viewportCenterObject(object: Object): Canvas;
|
1455 |
|
1456 | |
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 | viewportCenterObjectH(object: Object): Canvas;
|
1463 |
|
1464 | |
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 | viewportCenterObjectV(object: Object): Canvas;
|
1471 |
|
1472 | |
1473 |
|
1474 |
|
1475 |
|
1476 | getVpCenter(): Point;
|
1477 |
|
1478 | |
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 | toDatalessJSON(propertiesToInclude?: string[]): string;
|
1484 |
|
1485 | |
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 | toJSON(propertiesToInclude?: string[]): string;
|
1491 |
|
1492 | |
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 | toObject(propertiesToInclude?: string[]): any;
|
1498 |
|
1499 | |
1500 |
|
1501 |
|
1502 |
|
1503 |
|
1504 | toDatalessObject(propertiesToInclude?: string[]): any;
|
1505 |
|
1506 | |
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 | toSVG(options?: IToSVGOptions, reviver?: Function): string;
|
1513 |
|
1514 | |
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 | sendToBack(object: Object): Canvas;
|
1522 |
|
1523 | |
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 | bringToFront(object: Object): Canvas;
|
1531 |
|
1532 | |
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 | sendBackwards(object: Object, intersecting?: boolean): Canvas;
|
1544 |
|
1545 | |
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 | bringForward(object: Object, intersecting?: boolean): Canvas;
|
1557 |
|
1558 | |
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 | moveTo(object: Object, index: number): Canvas;
|
1566 |
|
1567 | |
1568 |
|
1569 |
|
1570 |
|
1571 | dispose(): Canvas;
|
1572 |
|
1573 | |
1574 |
|
1575 |
|
1576 |
|
1577 | toString(): string;
|
1578 |
|
1579 | |
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 | static EMPTY_JSON: string;
|
1585 |
|
1586 | |
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 | static supports(methodName: 'getImageData' | 'toDataURL' | 'toDataURLWithQuality' | 'setLineDash'): boolean;
|
1596 |
|
1597 | |
1598 |
|
1599 |
|
1600 |
|
1601 | toDataURL(options?: IDataURLOptions): string;
|
1602 |
|
1603 | |
1604 |
|
1605 |
|
1606 |
|
1607 | static toJSON(propertiesToInclude?: string[]): string;
|
1608 |
|
1609 | |
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 | clone(callback?: any, properties?: string[]): void;
|
1615 |
|
1616 | |
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 | cloneWithoutData(callback?: any): void;
|
1623 |
|
1624 | |
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 | loadFromJSON(json: any, callback: Function, reviver?: Function): Canvas;
|
1635 |
|
1636 | |
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 | createSVGFontFacesMarkup(objects: any[]): string;
|
1645 | |
1646 |
|
1647 |
|
1648 |
|
1649 |
|
1650 | createSVGRefElementsMarkup(): string;
|
1651 | |
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 | straightenObject(object: Object): Canvas;
|
1659 | }
|
1660 |
|
1661 | interface ICanvasOptions extends IStaticCanvasOptions {
|
1662 | |
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 | uniformScaling?: boolean | undefined;
|
1670 |
|
1671 | |
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 | uniScaleKey?: string | undefined;
|
1680 |
|
1681 | |
1682 |
|
1683 |
|
1684 |
|
1685 | centeredScaling?: boolean | undefined;
|
1686 |
|
1687 | |
1688 |
|
1689 |
|
1690 |
|
1691 | centeredRotation?: boolean | undefined;
|
1692 |
|
1693 | |
1694 |
|
1695 |
|
1696 | fill?: string | Pattern | Gradient | undefined;
|
1697 |
|
1698 | |
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 | centeredKey?: string | undefined;
|
1708 |
|
1709 | |
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 |
|
1718 | altActionKey?: string | undefined;
|
1719 |
|
1720 | |
1721 |
|
1722 |
|
1723 | interactive?: boolean | undefined;
|
1724 |
|
1725 | |
1726 |
|
1727 |
|
1728 | selection?: boolean | undefined;
|
1729 |
|
1730 | |
1731 |
|
1732 |
|
1733 |
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 | selectionKey?: string | string[] | undefined;
|
1741 |
|
1742 | |
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 | altSelectionKey?: string | null | undefined;
|
1755 |
|
1756 | |
1757 |
|
1758 |
|
1759 | selectionColor?: string | undefined;
|
1760 |
|
1761 | |
1762 |
|
1763 |
|
1764 |
|
1765 | selectionDashArray?: number[] | undefined;
|
1766 |
|
1767 | |
1768 |
|
1769 |
|
1770 | selectionBorderColor?: string | undefined;
|
1771 |
|
1772 | |
1773 |
|
1774 |
|
1775 | selectionLineWidth?: number | undefined;
|
1776 |
|
1777 | |
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 | selectionFullyContained?: boolean | undefined;
|
1783 |
|
1784 | |
1785 |
|
1786 |
|
1787 | hoverCursor?: string | undefined;
|
1788 |
|
1789 | |
1790 |
|
1791 |
|
1792 | moveCursor?: string | undefined;
|
1793 |
|
1794 | |
1795 |
|
1796 |
|
1797 | defaultCursor?: string | undefined;
|
1798 |
|
1799 | |
1800 |
|
1801 |
|
1802 | freeDrawingCursor?: string | undefined;
|
1803 |
|
1804 | |
1805 |
|
1806 |
|
1807 | rotationCursor?: string | undefined;
|
1808 |
|
1809 | |
1810 |
|
1811 |
|
1812 |
|
1813 |
|
1814 |
|
1815 | notAllowedCursor?: string | undefined;
|
1816 |
|
1817 | |
1818 |
|
1819 |
|
1820 | containerClass?: string | undefined;
|
1821 |
|
1822 | |
1823 |
|
1824 |
|
1825 | perPixelTargetFind?: boolean | undefined;
|
1826 |
|
1827 | |
1828 |
|
1829 |
|
1830 | targetFindTolerance?: number | undefined;
|
1831 |
|
1832 | |
1833 |
|
1834 |
|
1835 | skipTargetFind?: boolean | undefined;
|
1836 |
|
1837 | |
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 | isDrawingMode?: boolean | undefined;
|
1843 |
|
1844 | |
1845 |
|
1846 |
|
1847 |
|
1848 |
|
1849 | preserveObjectStacking?: boolean | undefined;
|
1850 |
|
1851 | |
1852 |
|
1853 |
|
1854 |
|
1855 |
|
1856 | snapAngle?: number | undefined;
|
1857 |
|
1858 | |
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 |
|
1864 |
|
1865 | snapThreshold?: null | number | undefined;
|
1866 |
|
1867 | |
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 | stopContextMenu?: boolean | undefined;
|
1874 |
|
1875 | |
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 | fireRightClick?: boolean | undefined;
|
1882 |
|
1883 | |
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 |
|
1889 | fireMiddleClick?: boolean | undefined;
|
1890 |
|
1891 | |
1892 |
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 | targets?: Object[] | undefined;
|
1898 |
|
1899 | |
1900 |
|
1901 |
|
1902 |
|
1903 |
|
1904 | width?: number | undefined;
|
1905 |
|
1906 | |
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 | height?: number | undefined;
|
1912 | }
|
1913 | export interface Canvas extends StaticCanvas {}
|
1914 | export interface Canvas extends ICanvasOptions {}
|
1915 | export class Canvas {
|
1916 | |
1917 |
|
1918 |
|
1919 |
|
1920 |
|
1921 | constructor(element: HTMLCanvasElement | string | null, options?: ICanvasOptions);
|
1922 |
|
1923 | /**
|
1924 | * When true, target detection is skipped when hovering over canvas. This can be used to improve performance.
|
1925 | * @type Boolean
|
1926 | * @default
|
1927 | */
|
1928 | skipTargetFind: boolean;
|
1929 | _activeObject: Object;
|
1930 | _objects: Object[];
|
1931 | targets: Object[];
|
1932 | /**
|
1933 | * Indicates which key enable alternative selection
|
1934 | * in case of target overlapping with active object
|
1935 | * values: 'altKey', 'shiftKey', 'ctrlKey'.
|
1936 | * For a series of reason that come from the general expectations on how
|
1937 | * things should work, this feature works only for preserveObjectStacking true.
|
1938 | * If `null` or 'none' or any other string that is not a modifier key
|
1939 | * feature is disabled.
|
1940 | * @since 1.6.5
|
1941 | * @type null|String
|
1942 | * @default
|
1943 | */
|
1944 | altSelectionKey?: string | undefined;
|
1945 |
|
1946 | /**
|
1947 | * Renders both the top canvas and the secondary container canvas.
|
1948 | * @return {fabric.Canvas} instance
|
1949 | * @chainable
|
1950 | */
|
1951 | renderAll(): Canvas;
|
1952 | |
1953 |
|
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 | renderTop(): Canvas;
|
1959 | |
1960 |
|
1961 |
|
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 | containsPoint(e: Event, target: Object, point?: { x: number; y: number }): boolean;
|
1967 | |
1968 |
|
1969 |
|
1970 |
|
1971 |
|
1972 |
|
1973 |
|
1974 | isTargetTransparent(target: Object, x: number, y: number): boolean;
|
1975 | |
1976 |
|
1977 |
|
1978 |
|
1979 |
|
1980 | setCursor(value: string): void;
|
1981 | |
1982 |
|
1983 |
|
1984 |
|
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 |
|
1990 | findTarget(e: Event, skipGroup: boolean): Object | undefined;
|
1991 | |
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 | restorePointerVpt(pointer: Point): any;
|
1997 | |
1998 |
|
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 |
|
2014 |
|
2015 | getPointer(e: Event, ignoreZoom?: boolean): { x: number; y: number };
|
2016 | |
2017 |
|
2018 |
|
2019 |
|
2020 | getSelectionContext(): CanvasRenderingContext2D;
|
2021 | |
2022 |
|
2023 |
|
2024 |
|
2025 | getSelectionElement(): HTMLCanvasElement;
|
2026 | |
2027 |
|
2028 |
|
2029 |
|
2030 | getActiveObject(): Object;
|
2031 | |
2032 |
|
2033 |
|
2034 |
|
2035 | getActiveObjects(): Object[];
|
2036 | |
2037 |
|
2038 |
|
2039 |
|
2040 |
|
2041 |
|
2042 |
|
2043 | setActiveObject(object: Object, e?: Event): Canvas;
|
2044 | |
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 |
|
2052 |
|
2053 | discardActiveObject(e?: Event): Canvas;
|
2054 | |
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 | dispose(): Canvas;
|
2060 | |
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 | clear(): Canvas;
|
2066 | |
2067 |
|
2068 |
|
2069 |
|
2070 | drawControls(ctx: CanvasRenderingContext2D): void;
|
2071 | |
2072 |
|
2073 |
|
2074 |
|
2075 | _setObjectScale(
|
2076 | localMouse: Point,
|
2077 | transform: any,
|
2078 | lockScalingX: boolean,
|
2079 | lockScalingY: boolean,
|
2080 | by: 'x' | 'y' | 'equally' | undefined,
|
2081 | lockScalingFlip: boolean,
|
2082 | _dim: Point,
|
2083 | ): boolean;
|
2084 | |
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 | _scaleObject(x: number, y: number, by?: 'x' | 'y' | 'equally'): boolean;
|
2094 | |
2095 |
|
2096 |
|
2097 |
|
2098 | _onObjectRemoved(obj: Object): void;
|
2099 | |
2100 |
|
2101 |
|
2102 |
|
2103 | _onObjectAdded(obj: Object): void;
|
2104 | |
2105 |
|
2106 |
|
2107 |
|
2108 | _resetCurrentTransform(): void;
|
2109 | |
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 | _fireSelectionEvents(oldObjects: Object[], e?: Event): void;
|
2115 | |
2116 |
|
2117 |
|
2118 |
|
2119 |
|
2120 |
|
2121 | _setActiveObject(object: fabric.Object, e?: Event): boolean;
|
2122 | |
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 | getPointer(e: Event, ignoreZoom: boolean): { x: number; y: number };
|
2141 | |
2142 |
|
2143 |
|
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 | _searchPossibleTargets(objects: Object[], pointer: { x: number; y: number }): Object;
|
2149 |
|
2150 | static EMPTY_JSON: string;
|
2151 | |
2152 |
|
2153 |
|
2154 |
|
2155 |
|
2156 | static supports(methodName: 'getImageData' | 'toDataURL' | 'toDataURLWithQuality' | 'setLineDash'): boolean;
|
2157 | |
2158 |
|
2159 |
|
2160 |
|
2161 | static toJSON(propertiesToInclude?: string[]): string;
|
2162 | |
2163 |
|
2164 |
|
2165 | removeListeners(): void;
|
2166 | }
|
2167 |
|
2168 |
|
2169 |
|
2170 |
|
2171 |
|
2172 | interface ICircleOptions extends IObjectOptions {
|
2173 | |
2174 |
|
2175 |
|
2176 | radius?: number | undefined;
|
2177 | |
2178 |
|
2179 |
|
2180 | startAngle?: number | undefined;
|
2181 | |
2182 |
|
2183 |
|
2184 | endAngle?: number | undefined;
|
2185 | }
|
2186 | export interface Circle extends Object, ICircleOptions {}
|
2187 | export class Circle {
|
2188 | constructor(options?: ICircleOptions);
|
2189 | /**
|
2190 | * Returns horizontal radius of an object (according to how an object is scaled)
|
2191 | */
|
2192 | getRadiusX(): number;
|
2193 | /**
|
2194 | * Returns vertical radius of an object (according to how an object is scaled)
|
2195 | */
|
2196 | getRadiusY(): number;
|
2197 | /**
|
2198 | * Sets radius of an object (and updates width accordingly)
|
2199 | */
|
2200 | setRadius(value: number): number;
|
2201 | /**
|
2202 | * Returns svg representation of an instance
|
2203 | * @return {Array} an array of strings with the specific svg representation
|
2204 | * of the instance
|
2205 | */
|
2206 | _toSVG(): string;
|
2207 | |
2208 |
|
2209 |
|
2210 | static ATTRIBUTE_NAMES: string[];
|
2211 | |
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 | static fromElement(element: SVGElement, options: ICircleOptions): Circle;
|
2217 | |
2218 |
|
2219 |
|
2220 |
|
2221 | static fromObject(object: any): Circle;
|
2222 | }
|
2223 |
|
2224 | interface IEllipseOptions extends IObjectOptions {
|
2225 | |
2226 |
|
2227 |
|
2228 | rx?: number | undefined;
|
2229 | |
2230 |
|
2231 |
|
2232 | ry?: number | undefined;
|
2233 | }
|
2234 | export interface Ellipse extends Object, IEllipseOptions {}
|
2235 | export class Ellipse {
|
2236 | constructor(options?: IEllipseOptions);
|
2237 | /**
|
2238 | * Returns horizontal radius of an object (according to how an object is scaled)
|
2239 | */
|
2240 | getRx(): number;
|
2241 | /**
|
2242 | * Returns Vertical radius of an object (according to how an object is scaled)
|
2243 | */
|
2244 | getRy(): number;
|
2245 | /**
|
2246 | * Returns svg representation of an instance
|
2247 | * @return {Array} an array of strings with the specific svg representation
|
2248 | * of the instance
|
2249 | */
|
2250 | _toSVG(): string;
|
2251 | |
2252 |
|
2253 |
|
2254 | static ATTRIBUTE_NAMES: string[];
|
2255 | |
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 | static fromElement(element: SVGElement, options?: IEllipseOptions): Ellipse;
|
2261 | |
2262 |
|
2263 |
|
2264 |
|
2265 | static fromObject(object: any): Ellipse;
|
2266 | }
|
2267 | interface IGroupOptions extends IObjectOptions {
|
2268 | |
2269 |
|
2270 |
|
2271 |
|
2272 | subTargetCheck?: boolean | undefined;
|
2273 | |
2274 |
|
2275 |
|
2276 |
|
2277 |
|
2278 |
|
2279 |
|
2280 | useSetOnGroup?: boolean | undefined;
|
2281 | }
|
2282 | export interface Group extends Object, ICollection<Group>, IGroupOptions {}
|
2283 | export class Group {
|
2284 | |
2285 |
|
2286 |
|
2287 |
|
2288 |
|
2289 | constructor(objects?: Object[], options?: IGroupOptions, isAlreadyGrouped?: boolean);
|
2290 | /**
|
2291 | * Adds an object to a group; Then recalculates group's dimension, position.
|
2292 | * @param [Object] object
|
2293 | * @return thisArg
|
2294 | * @chainable
|
2295 | */
|
2296 | addWithUpdate(object?: Object): Group;
|
2297 | /**
|
2298 | * Removes an object from a group; Then recalculates group's dimension, position.
|
2299 | * @return thisArg
|
2300 | * @chainable
|
2301 | */
|
2302 | removeWithUpdate(object: Object): Group;
|
2303 | /**
|
2304 | * Renders instance on a given context
|
2305 | * @param ctx context to render instance on
|
2306 | */
|
2307 | render(ctx: CanvasRenderingContext2D): void;
|
2308 | /**
|
2309 | * Decide if the object should cache or not. Create its own cache level
|
2310 | * objectCaching is a global flag, wins over everything
|
2311 | * needsItsOwnCache should be used when the object drawing method requires
|
2312 | * a cache step. None of the fabric classes requires it.
|
2313 | * Generally you do not cache objects in groups because the group outside is cached.
|
2314 | * @return {Boolean}
|
2315 | */
|
2316 | shouldCache(): boolean;
|
2317 | |
2318 |
|
2319 |
|
2320 |
|
2321 | willDrawShadow(): boolean;
|
2322 | |
2323 |
|
2324 |
|
2325 |
|
2326 | isOnACache(): boolean;
|
2327 | |
2328 |
|
2329 |
|
2330 |
|
2331 | drawObject(ctx: CanvasRenderingContext2D): void;
|
2332 | |
2333 |
|
2334 |
|
2335 | isCacheDirty(skipCanvas?: boolean): boolean;
|
2336 | |
2337 |
|
2338 |
|
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 | realizeTransform(object: Object): Object;
|
2345 | |
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 | destroy(): Group;
|
2351 | |
2352 |
|
2353 |
|
2354 |
|
2355 |
|
2356 |
|
2357 | toActiveSelection(): ActiveSelection;
|
2358 | |
2359 |
|
2360 |
|
2361 |
|
2362 |
|
2363 | ungroupOnCanvas(): Group;
|
2364 | |
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 | setObjectsCoords(): Group;
|
2370 | |
2371 |
|
2372 |
|
2373 |
|
2374 |
|
2375 | toSVG(reviver?: Function): string;
|
2376 | |
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 | toClipPathSVG(reviver?: Function): string;
|
2382 | |
2383 |
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 | addWithUpdate(object: Object): Group;
|
2389 | |
2390 |
|
2391 |
|
2392 |
|
2393 |
|
2394 |
|
2395 | _restoreObjectsState(): Group;
|
2396 | |
2397 |
|
2398 |
|
2399 | _calcBounds(onlyWidthHeight?: boolean): void;
|
2400 | |
2401 |
|
2402 |
|
2403 |
|
2404 | _updateObjectsCoords(center?: Point): void;
|
2405 | |
2406 |
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 | _restoreObjectsState(): Group;
|
2412 | |
2413 |
|
2414 |
|
2415 | _onObjectRemoved(object: Object): void;
|
2416 | |
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 | static fromObject(object: any, callback: (group: Group) => any): void;
|
2422 | }
|
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 | export interface ActiveSelection extends Group, ICollection<Group> {}
|
2428 | export class ActiveSelection {
|
2429 | |
2430 |
|
2431 |
|
2432 |
|
2433 |
|
2434 | constructor(objects?: Object[], options?: IObjectOptions);
|
2435 | /**
|
2436 | * Constructor
|
2437 | * @param {Object} objects ActiveSelection objects
|
2438 | * @param {Object} [options] Options object
|
2439 | * @return {Object} thisArg
|
2440 | */
|
2441 | initialize(objects: ActiveSelection, options?: IObjectOptions): Object;
|
2442 | |
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 | toGroup(): Group;
|
2448 | |
2449 |
|
2450 |
|
2451 |
|
2452 |
|
2453 |
|
2454 | static fromObject(object: any, callback: Function): void;
|
2455 | }
|
2456 |
|
2457 | interface IImageOptions extends IObjectOptions {
|
2458 | |
2459 |
|
2460 |
|
2461 | crossOrigin?: string | undefined;
|
2462 | |
2463 |
|
2464 |
|
2465 |
|
2466 |
|
2467 |
|
2468 | srcFromAttribute?: boolean | undefined;
|
2469 | |
2470 |
|
2471 |
|
2472 |
|
2473 |
|
2474 |
|
2475 | minimumScaleTrigger?: number | undefined;
|
2476 | |
2477 |
|
2478 |
|
2479 |
|
2480 |
|
2481 | cacheKey?: string | undefined;
|
2482 | |
2483 |
|
2484 |
|
2485 |
|
2486 |
|
2487 | cropX?: number | undefined;
|
2488 | |
2489 |
|
2490 |
|
2491 |
|
2492 |
|
2493 | cropY?: number | undefined;
|
2494 | |
2495 |
|
2496 |
|
2497 | filters?: IBaseFilter[] | undefined;
|
2498 | }
|
2499 | interface Image extends Object, IImageOptions {}
|
2500 | export class Image {
|
2501 | |
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 | constructor(element?: string | HTMLImageElement | HTMLVideoElement, options?: IImageOptions);
|
2507 | /**
|
2508 | * Returns image or video element which this instance is based on
|
2509 | * @return Image or Video element
|
2510 | */
|
2511 | getElement(): HTMLImageElement | HTMLVideoElement;
|
2512 | /**
|
2513 | * Sets image or video element for this instance to a specified one.
|
2514 | * If filters defined they are applied to new image.
|
2515 | * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.
|
2516 | * @param element image element
|
2517 | * @param [options] Options object
|
2518 | */
|
2519 | setElement(element: HTMLImageElement | HTMLVideoElement, options?: IImageOptions): Image;
|
2520 | /**
|
2521 | * Delete a single texture if in webgl mode
|
2522 | */
|
2523 | removeTexture(key: any): void;
|
2524 | /**
|
2525 | * Delete textures, reference to elements and eventually JSDOM cleanup
|
2526 | */
|
2527 | dispose(): void;
|
2528 | /**
|
2529 | * Returns original size of an image
|
2530 | * @return Object with "width" and "height" properties
|
2531 | */
|
2532 | getOriginalSize(): { width: number; height: number };
|
2533 | |
2534 |
|
2535 |
|
2536 |
|
2537 | hasCrop(): boolean;
|
2538 | |
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 | _toSVG(): string;
|
2544 | |
2545 |
|
2546 |
|
2547 |
|
2548 | getSrc(): string;
|
2549 | |
2550 |
|
2551 |
|
2552 |
|
2553 |
|
2554 |
|
2555 |
|
2556 |
|
2557 | setSrc(src: string, callback?: Function, options?: IImageOptions): Image;
|
2558 | applyResizeFilters(): void;
|
2559 | |
2560 |
|
2561 |
|
2562 |
|
2563 |
|
2564 |
|
2565 | applyFilters(filters?: IBaseFilter[]): Image;
|
2566 | |
2567 |
|
2568 |
|
2569 |
|
2570 |
|
2571 |
|
2572 | parsePreserveAspectRatioAttribute(): any;
|
2573 | |
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 |
|
2579 | static fromURL(url: string, callback?: (image: Image) => void, imgOptions?: IImageOptions): Image;
|
2580 | |
2581 |
|
2582 |
|
2583 |
|
2584 |
|
2585 |
|
2586 | static fromElement(element: SVGElement, callback: Function, options?: IImageOptions): Image;
|
2587 | |
2588 |
|
2589 |
|
2590 | static CSS_CANVAS: string;
|
2591 | static filters: IAllFilters;
|
2592 | static ATTRIBUTE_NAMES: string[];
|
2593 | }
|
2594 |
|
2595 | interface ILineOptions extends IObjectOptions {
|
2596 | |
2597 |
|
2598 |
|
2599 | x1?: number | undefined;
|
2600 | |
2601 |
|
2602 |
|
2603 | x2?: number | undefined;
|
2604 | |
2605 |
|
2606 |
|
2607 | y1?: number | undefined;
|
2608 | |
2609 |
|
2610 |
|
2611 | y2?: number | undefined;
|
2612 | }
|
2613 | export interface Line extends Object, ILineOptions {}
|
2614 | export class Line {
|
2615 | |
2616 |
|
2617 |
|
2618 |
|
2619 |
|
2620 | constructor(points?: number[], objObjects?: ILineOptions);
|
2621 | /**
|
2622 | * Returns svg representation of an instance
|
2623 | * @return {Array} an array of strings with the specific svg representation
|
2624 | * of the instance
|
2625 | */
|
2626 | _toSVG(): string;
|
2627 | |
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 |
|
2634 |
|
2635 | static fromElement(element: SVGElement, callback?: Function, options?: ILineOptions): Line;
|
2636 | |
2637 |
|
2638 |
|
2639 |
|
2640 | static fromObject(object: any): Line;
|
2641 | static ATTRIBUTE_NAMES: string[];
|
2642 | |
2643 |
|
2644 |
|
2645 | makeEdgeToOriginGetter(
|
2646 | propertyNames: { origin: number; axis1: any; axis2: any; dimension: any },
|
2647 | originValues: { nearest: any; center: any; farthest: any },
|
2648 | ): Function;
|
2649 | |
2650 |
|
2651 |
|
2652 |
|
2653 | calcLinePoints(): { x1: number; x2: number; y1: number; y2: number };
|
2654 | }
|
2655 |
|
2656 | interface IObjectOptions {
|
2657 | |
2658 |
|
2659 |
|
2660 |
|
2661 |
|
2662 | type?: string | undefined;
|
2663 |
|
2664 | |
2665 |
|
2666 |
|
2667 | originX?: string | undefined;
|
2668 |
|
2669 | |
2670 |
|
2671 |
|
2672 | originY?: string | undefined;
|
2673 |
|
2674 | |
2675 |
|
2676 |
|
2677 | top?: number | undefined;
|
2678 |
|
2679 | |
2680 |
|
2681 |
|
2682 | left?: number | undefined;
|
2683 |
|
2684 | |
2685 |
|
2686 |
|
2687 | width?: number | undefined;
|
2688 |
|
2689 | |
2690 |
|
2691 |
|
2692 | height?: number | undefined;
|
2693 |
|
2694 | |
2695 |
|
2696 |
|
2697 | scaleX?: number | undefined;
|
2698 |
|
2699 | |
2700 |
|
2701 |
|
2702 | scaleY?: number | undefined;
|
2703 |
|
2704 | |
2705 |
|
2706 |
|
2707 | flipX?: boolean | undefined;
|
2708 |
|
2709 | |
2710 |
|
2711 |
|
2712 | flipY?: boolean | undefined;
|
2713 |
|
2714 | |
2715 |
|
2716 |
|
2717 | opacity?: number | undefined;
|
2718 |
|
2719 | |
2720 |
|
2721 |
|
2722 | angle?: number | undefined;
|
2723 |
|
2724 | |
2725 |
|
2726 |
|
2727 | skewX?: number | undefined;
|
2728 |
|
2729 | |
2730 |
|
2731 |
|
2732 | skewY?: number | undefined;
|
2733 |
|
2734 | |
2735 |
|
2736 |
|
2737 | cornerSize?: number | undefined;
|
2738 |
|
2739 | |
2740 |
|
2741 |
|
2742 | transparentCorners?: boolean | undefined;
|
2743 |
|
2744 | |
2745 |
|
2746 |
|
2747 | hoverCursor?: string | undefined;
|
2748 |
|
2749 | |
2750 |
|
2751 |
|
2752 | moveCursor?: string | undefined;
|
2753 |
|
2754 | |
2755 |
|
2756 |
|
2757 | padding?: number | undefined;
|
2758 |
|
2759 | |
2760 |
|
2761 |
|
2762 | borderColor?: string | undefined;
|
2763 |
|
2764 | |
2765 |
|
2766 |
|
2767 | borderDashArray?: number[] | undefined;
|
2768 |
|
2769 | |
2770 |
|
2771 |
|
2772 | cornerColor?: string | undefined;
|
2773 |
|
2774 | |
2775 |
|
2776 |
|
2777 | cornerStrokeColor?: string | undefined;
|
2778 |
|
2779 | |
2780 |
|
2781 |
|
2782 | cornerStyle?: 'rect' | 'circle' | undefined;
|
2783 |
|
2784 | |
2785 |
|
2786 |
|
2787 | cornerDashArray?: number[] | undefined;
|
2788 |
|
2789 | |
2790 |
|
2791 |
|
2792 |
|
2793 |
|
2794 | centeredScaling?: boolean | undefined;
|
2795 |
|
2796 | |
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 | centeredRotation?: boolean | undefined;
|
2802 |
|
2803 | |
2804 |
|
2805 |
|
2806 | fill?: string | Pattern | Gradient | undefined;
|
2807 |
|
2808 | |
2809 |
|
2810 |
|
2811 |
|
2812 |
|
2813 | fillRule?: string | undefined;
|
2814 |
|
2815 | |
2816 |
|
2817 |
|
2818 | globalCompositeOperation?: string | undefined;
|
2819 |
|
2820 | |
2821 |
|
2822 |
|
2823 | backgroundColor?: string | undefined;
|
2824 |
|
2825 | |
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 | selectionBackgroundColor?: string | undefined;
|
2831 |
|
2832 | |
2833 |
|
2834 |
|
2835 | stroke?: string | undefined;
|
2836 |
|
2837 | |
2838 |
|
2839 |
|
2840 | strokeWidth?: number | undefined;
|
2841 |
|
2842 | |
2843 |
|
2844 |
|
2845 | strokeDashArray?: number[] | undefined;
|
2846 |
|
2847 | |
2848 |
|
2849 |
|
2850 |
|
2851 |
|
2852 | strokeDashOffset?: number | undefined;
|
2853 |
|
2854 | |
2855 |
|
2856 |
|
2857 | strokeLineCap?: string | undefined;
|
2858 |
|
2859 | |
2860 |
|
2861 |
|
2862 | strokeLineJoin?: string | undefined;
|
2863 |
|
2864 | |
2865 |
|
2866 |
|
2867 | strokeMiterLimit?: number | undefined;
|
2868 |
|
2869 | |
2870 |
|
2871 |
|
2872 | shadow?: Shadow | string | undefined;
|
2873 |
|
2874 | |
2875 |
|
2876 |
|
2877 | borderOpacityWhenMoving?: number | undefined;
|
2878 |
|
2879 | |
2880 |
|
2881 |
|
2882 | borderScaleFactor?: number | undefined;
|
2883 |
|
2884 | |
2885 |
|
2886 |
|
2887 | minScaleLimit?: number | undefined;
|
2888 |
|
2889 | |
2890 |
|
2891 |
|
2892 |
|
2893 | selectable?: boolean | undefined;
|
2894 |
|
2895 | |
2896 |
|
2897 |
|
2898 | evented?: boolean | undefined;
|
2899 |
|
2900 | |
2901 |
|
2902 |
|
2903 | visible?: boolean | undefined;
|
2904 |
|
2905 | |
2906 |
|
2907 |
|
2908 | hasControls?: boolean | undefined;
|
2909 |
|
2910 | |
2911 |
|
2912 |
|
2913 | hasBorders?: boolean | undefined;
|
2914 |
|
2915 | |
2916 |
|
2917 |
|
2918 | hasRotatingPoint?: boolean | undefined;
|
2919 |
|
2920 | |
2921 |
|
2922 |
|
2923 | rotatingPointOffset?: number | undefined;
|
2924 |
|
2925 | |
2926 |
|
2927 |
|
2928 | perPixelTargetFind?: boolean | undefined;
|
2929 |
|
2930 | |
2931 |
|
2932 |
|
2933 | includeDefaultValues?: boolean | undefined;
|
2934 |
|
2935 | |
2936 |
|
2937 |
|
2938 | lockMovementX?: boolean | undefined;
|
2939 |
|
2940 | |
2941 |
|
2942 |
|
2943 | lockMovementY?: boolean | undefined;
|
2944 |
|
2945 | |
2946 |
|
2947 |
|
2948 | lockRotation?: boolean | undefined;
|
2949 |
|
2950 | |
2951 |
|
2952 |
|
2953 | lockScalingX?: boolean | undefined;
|
2954 |
|
2955 | |
2956 |
|
2957 |
|
2958 | lockScalingY?: boolean | undefined;
|
2959 |
|
2960 | |
2961 |
|
2962 |
|
2963 | lockUniScaling?: boolean | undefined;
|
2964 |
|
2965 | |
2966 |
|
2967 |
|
2968 |
|
2969 | lockSkewingX?: boolean | undefined;
|
2970 |
|
2971 | |
2972 |
|
2973 |
|
2974 |
|
2975 | lockSkewingY?: boolean | undefined;
|
2976 |
|
2977 | |
2978 |
|
2979 |
|
2980 | lockScalingFlip?: boolean | undefined;
|
2981 |
|
2982 | |
2983 |
|
2984 |
|
2985 |
|
2986 |
|
2987 |
|
2988 | excludeFromExport?: boolean | undefined;
|
2989 |
|
2990 | |
2991 |
|
2992 |
|
2993 | objectCaching?: boolean | undefined;
|
2994 |
|
2995 | |
2996 |
|
2997 |
|
2998 |
|
2999 |
|
3000 |
|
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 | statefullCache?: boolean | undefined;
|
3006 |
|
3007 | |
3008 |
|
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 |
|
3014 |
|
3015 | noScaleCache?: boolean | undefined;
|
3016 |
|
3017 | |
3018 |
|
3019 |
|
3020 |
|
3021 |
|
3022 |
|
3023 |
|
3024 |
|
3025 |
|
3026 | strokeUniform?: boolean | undefined;
|
3027 |
|
3028 | |
3029 |
|
3030 |
|
3031 | dirty?: boolean | undefined;
|
3032 |
|
3033 | |
3034 |
|
3035 |
|
3036 |
|
3037 | paintFirst?: string | undefined;
|
3038 |
|
3039 | |
3040 |
|
3041 |
|
3042 |
|
3043 |
|
3044 |
|
3045 | stateProperties?: string[] | undefined;
|
3046 |
|
3047 | |
3048 |
|
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 |
|
3054 | cacheProperties?: string[] | undefined;
|
3055 |
|
3056 | |
3057 |
|
3058 |
|
3059 |
|
3060 |
|
3061 |
|
3062 | clipPath?: Object | undefined;
|
3063 |
|
3064 | |
3065 |
|
3066 |
|
3067 |
|
3068 |
|
3069 |
|
3070 |
|
3071 | inverted?: boolean | undefined;
|
3072 |
|
3073 | |
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 |
|
3083 | absolutePositioned?: boolean | undefined;
|
3084 |
|
3085 | |
3086 |
|
3087 |
|
3088 | name?: string | undefined;
|
3089 |
|
3090 | |
3091 |
|
3092 |
|
3093 | data?: any;
|
3094 | |
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 |
|
3106 | oCoords?: { tl: Point; mt: Point; tr: Point; ml: Point; mr: Point; bl: Point; mb: Point; br: Point; mtr: Point } | undefined;
|
3107 | |
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 |
|
3113 |
|
3114 |
|
3115 |
|
3116 |
|
3117 |
|
3118 |
|
3119 | aCoords?: { bl: Point; br: Point; tl: Point; tr: Point } | undefined;
|
3120 | |
3121 |
|
3122 |
|
3123 | matrixCache?: any;
|
3124 | |
3125 |
|
3126 |
|
3127 | ownMatrixCache?: any;
|
3128 |
|
3129 | |
3130 |
|
3131 |
|
3132 | snapAngle?: number | undefined;
|
3133 | |
3134 |
|
3135 |
|
3136 | snapThreshold?: null | number | undefined;
|
3137 | |
3138 |
|
3139 |
|
3140 | group?: Group | undefined;
|
3141 | |
3142 |
|
3143 |
|
3144 | canvas?: Canvas | undefined;
|
3145 | }
|
3146 | export interface Object extends IObservable<Object>, IObjectOptions, IObjectAnimation<Object> {}
|
3147 | export class Object {
|
3148 | _controlsVisibility: {
|
3149 | bl?: boolean | undefined;
|
3150 | br?: boolean | undefined;
|
3151 | mb?: boolean | undefined;
|
3152 | ml?: boolean | undefined;
|
3153 | mr?: boolean | undefined;
|
3154 | mt?: boolean | undefined;
|
3155 | tl?: boolean | undefined;
|
3156 | tr?: boolean | undefined;
|
3157 | mtr?: boolean | undefined;
|
3158 | };
|
3159 |
|
3160 | controls: { [key: string]: Control };
|
3161 |
|
3162 | constructor(options?: IObjectOptions);
|
3163 | initialize(options?: IObjectOptions): Object;
|
3164 |
|
3165 | /* Sets object's properties from options
|
3166 | * @param {Object} [options] Options object
|
3167 | */
|
3168 | setOptions(options: IObjectOptions): void;
|
3169 |
|
3170 | |
3171 |
|
3172 |
|
3173 |
|
3174 | transform(ctx: CanvasRenderingContext2D): void;
|
3175 |
|
3176 | |
3177 |
|
3178 |
|
3179 |
|
3180 | toObject(propertiesToInclude?: string[]): any;
|
3181 |
|
3182 | |
3183 |
|
3184 |
|
3185 |
|
3186 | toDatalessObject(propertiesToInclude?: string[]): any;
|
3187 |
|
3188 | |
3189 |
|
3190 |
|
3191 | toString(): string;
|
3192 |
|
3193 | |
3194 |
|
3195 |
|
3196 |
|
3197 | getObjectScaling(): { scaleX: number; scaleY: number };
|
3198 |
|
3199 | |
3200 |
|
3201 |
|
3202 |
|
3203 | getTotalObjectScaling(): { scaleX: number; scaleY: number };
|
3204 |
|
3205 | |
3206 |
|
3207 |
|
3208 |
|
3209 | getObjectOpacity(): number;
|
3210 |
|
3211 | |
3212 |
|
3213 |
|
3214 |
|
3215 |
|
3216 |
|
3217 | setOnGroup(): void;
|
3218 |
|
3219 | |
3220 |
|
3221 |
|
3222 | getViewportTransform(): any[];
|
3223 |
|
3224 | |
3225 |
|
3226 |
|
3227 |
|
3228 | render(ctx: CanvasRenderingContext2D): void;
|
3229 |
|
3230 | |
3231 |
|
3232 |
|
3233 |
|
3234 |
|
3235 |
|
3236 |
|
3237 |
|
3238 | needsItsOwnCache(): boolean;
|
3239 |
|
3240 | |
3241 |
|
3242 |
|
3243 |
|
3244 |
|
3245 |
|
3246 |
|
3247 |
|
3248 | shouldCache(): boolean;
|
3249 |
|
3250 | |
3251 |
|
3252 |
|
3253 |
|
3254 |
|
3255 | willDrawShadow(): boolean;
|
3256 |
|
3257 | |
3258 |
|
3259 |
|
3260 |
|
3261 | drawClipPathOnCache(ctx: CanvasRenderingContext2D): void;
|
3262 |
|
3263 | |
3264 |
|
3265 |
|
3266 |
|
3267 | drawObject(ctx: CanvasRenderingContext2D): void;
|
3268 |
|
3269 | |
3270 |
|
3271 |
|
3272 |
|
3273 | drawCacheOnCanvas(ctx: CanvasRenderingContext2D): void;
|
3274 |
|
3275 | |
3276 |
|
3277 |
|
3278 |
|
3279 |
|
3280 | isCacheDirty(skipCanvas?: boolean): boolean;
|
3281 |
|
3282 | |
3283 |
|
3284 |
|
3285 |
|
3286 |
|
3287 | clone(callback: Function, propertiesToInclude?: string[]): void;
|
3288 |
|
3289 | |
3290 |
|
3291 |
|
3292 |
|
3293 | cloneAsImage(callback: Function, options?: IDataURLOptions): Object;
|
3294 |
|
3295 | |
3296 |
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 |
|
3302 |
|
3303 |
|
3304 |
|
3305 |
|
3306 |
|
3307 |
|
3308 | toCanvasElement(options?: IDataURLOptions): HTMLCanvasElement;
|
3309 |
|
3310 | |
3311 |
|
3312 |
|
3313 |
|
3314 | toDataURL(options: IDataURLOptions): string;
|
3315 |
|
3316 | |
3317 |
|
3318 |
|
3319 |
|
3320 | isType(type: string): boolean;
|
3321 |
|
3322 | |
3323 |
|
3324 |
|
3325 | complexity(): number;
|
3326 |
|
3327 | |
3328 |
|
3329 |
|
3330 |
|
3331 | toJSON(propertiesToInclude?: string[]): any;
|
3332 |
|
3333 | |
3334 |
|
3335 |
|
3336 |
|
3337 | rotate(angle: number): Object;
|
3338 |
|
3339 | |
3340 |
|
3341 |
|
3342 |
|
3343 | centerH(): Object;
|
3344 |
|
3345 | |
3346 |
|
3347 |
|
3348 |
|
3349 |
|
3350 |
|
3351 | viewportCenterH(): Object;
|
3352 |
|
3353 | |
3354 |
|
3355 |
|
3356 |
|
3357 | centerV(): Object;
|
3358 |
|
3359 | |
3360 |
|
3361 |
|
3362 |
|
3363 |
|
3364 |
|
3365 | viewportCenterV(): Object;
|
3366 |
|
3367 | |
3368 |
|
3369 |
|
3370 |
|
3371 | center(): Object;
|
3372 |
|
3373 | |
3374 |
|
3375 |
|
3376 |
|
3377 |
|
3378 |
|
3379 | viewportCenter(): Object;
|
3380 |
|
3381 | |
3382 |
|
3383 |
|
3384 |
|
3385 |
|
3386 | getLocalPointer(e: Event | undefined, pointer?: { x: number; y: number }): { x: number; y: number };
|
3387 |
|
3388 | |
3389 |
|
3390 |
|
3391 |
|
3392 | get<K extends keyof this>(property: K): this[K];
|
3393 |
|
3394 | |
3395 |
|
3396 |
|
3397 |
|
3398 |
|
3399 |
|
3400 |
|
3401 | set<K extends keyof this>(key: K, value: this[K] | ((value: this[K]) => this[K])): Object;
|
3402 |
|
3403 | /**
|
3404 | * Sets property to a given value.
|
3405 | * When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls.
|
3406 | * If you need to update those, call `setCoords()`.
|
3407 | * @param options Property object, iterate over the object properties
|
3408 | */
|
3409 | set(options: Partial<this>): Object;
|
3410 |
|
3411 | /**
|
3412 | * Toggles specified property from `true` to `false` or from `false` to `true`
|
3413 | * @param property Property to toggle
|
3414 | */
|
3415 | toggle(property: keyof this): Object;
|
3416 |
|
3417 | /**
|
3418 | * Sets sourcePath of an object
|
3419 | * @param value Value to set sourcePath to
|
3420 | */
|
3421 | setSourcePath(value: string): Object;
|
3422 |
|
3423 | /**
|
3424 | * Sets "angle" of an instance
|
3425 | * @param angle Angle value
|
3426 | */
|
3427 | setAngle(angle: number): Object;
|
3428 |
|
3429 | /**
|
3430 | * Sets object's properties from options
|
3431 | * @param [options] Options object
|
3432 | */
|
3433 | setOptions(options?: any): void;
|
3434 | /**
|
3435 | * Sets sourcePath of an object
|
3436 | * @param value Value to set sourcePath to
|
3437 | */
|
3438 | setSourcePath(value: string): Object;
|
3439 | // functions from object svg export mixin
|
3440 | // -----------------------------------------------------------------------------------------------------------------------------------
|
3441 | /**
|
3442 | * Returns styles-string for svg-export
|
3443 | * @param {Boolean} skipShadow a boolean to skip shadow filter output
|
3444 | * @return {String}
|
3445 | */
|
3446 | getSvgStyles(skipShadow?: boolean): string;
|
3447 | /**
|
3448 | * Returns transform-string for svg-export
|
3449 | * @param {Boolean} use the full transform or the single object one.
|
3450 | * @return {String}
|
3451 | */
|
3452 | getSvgTransform(full?: boolean, additionalTransform?: string): string;
|
3453 | /**
|
3454 | * Returns transform-string for svg-export from the transform matrix of single elements
|
3455 | */
|
3456 | getSvgTransformMatrix(): string;
|
3457 |
|
3458 | // functions from stateful mixin
|
3459 | // -----------------------------------------------------------------------------------------------------------------------------------
|
3460 | /**
|
3461 | * Returns true if object state (one of its state properties) was changed
|
3462 | * @param {String} [propertySet] optional name for the set of property we want to save
|
3463 | * @return {Boolean} true if instance' state has changed since `{@link fabric.Object#saveState}` was called
|
3464 | */
|
3465 | hasStateChanged(propertySet: string): boolean;
|
3466 | /**
|
3467 | * Saves state of an object
|
3468 | * @param [options] Object with additional `stateProperties` array to include when saving state
|
3469 | * @return thisArg
|
3470 | */
|
3471 | saveState(options?: { stateProperties?: any[] | undefined; propertySet?: string | undefined }): Object;
|
3472 | /**
|
3473 | * Setups state of an object
|
3474 | * @param {Object} [options] Object with additional `stateProperties` array to include when saving state
|
3475 | * @return {fabric.Object} thisArg
|
3476 | */
|
3477 | setupState(options?: any): Object;
|
3478 | // functions from object straightening mixin
|
3479 | // -----------------------------------------------------------------------------------------------------------------------------------
|
3480 | /**
|
3481 | * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer)
|
3482 | */
|
3483 | straighten(): Object;
|
3484 | /**
|
3485 | * Same as straighten but with animation
|
3486 | */
|
3487 | fxStraighten(callbacks: Callbacks): Object;
|
3488 |
|
3489 | // functions from object stacking mixin
|
3490 | // -----------------------------------------------------------------------------------------------------------------------------------
|
3491 | /**
|
3492 | * Moves an object up in stack of drawn objects
|
3493 | * @param [intersecting] If `true`, send object in front of next upper intersecting object
|
3494 | */
|
3495 | bringForward(intersecting?: boolean): Object;
|
3496 | /**
|
3497 | * Moves an object to the top of the stack of drawn objects
|
3498 | */
|
3499 | bringToFront(): Object;
|
3500 | /**
|
3501 | * Moves an object down in stack of drawn objects
|
3502 | * @param [intersecting] If `true`, send object behind next lower intersecting object
|
3503 | */
|
3504 | sendBackwards(intersecting?: boolean): Object;
|
3505 | /**
|
3506 | * Moves an object to the bottom of the stack of drawn objects
|
3507 | */
|
3508 | sendToBack(): Object;
|
3509 | /**
|
3510 | * Moves an object to specified level in stack of drawn objects
|
3511 | * @param index New position of object
|
3512 | */
|
3513 | moveTo(index: number): Object;
|
3514 |
|
3515 | // functions from object origin mixin
|
3516 | // -----------------------------------------------------------------------------------------------------------------------------------
|
3517 | /**
|
3518 | * Translates the coordinates from origin to center coordinates (based on the object's dimensions)
|
3519 | * @param point The point which corresponds to the originX and originY params
|
3520 | * @param originX Horizontal origin: 'left', 'center' or 'right'
|
3521 | * @param originY Vertical origin: 'top', 'center' or 'bottom'
|
3522 | */
|
3523 | translateToCenterPoint(point: Point, originX: string, originY: string): Point;
|
3524 |
|
3525 | /**
|
3526 | * Translates the coordinates from center to origin coordinates (based on the object's dimensions)
|
3527 | * @param center The point which corresponds to center of the object
|
3528 | * @param originX Horizontal origin: 'left', 'center' or 'right'
|
3529 | * @param originY Vertical origin: 'top', 'center' or 'bottom'
|
3530 | */
|
3531 | translateToOriginPoint(center: Point, originX: string, originY: string): Point;
|
3532 | /**
|
3533 | * Returns the real center coordinates of the object
|
3534 | */
|
3535 | getCenterPoint(): Point;
|
3536 |
|
3537 | /**
|
3538 | * Returns the coordinates of the object as if it has a different origin
|
3539 | * @param {String} originX Horizontal origin: 'left', 'center' or 'right'
|
3540 | * @param {String} originY Vertical origin: 'top', 'center' or 'bottom'
|
3541 | * @return {fabric.Point}
|
3542 | */
|
3543 | getPointByOrigin(originX: string, originY: string): Point;
|
3544 |
|
3545 | /**
|
3546 | * Returns the point in local coordinates
|
3547 | * @param point The point relative to the global coordinate system
|
3548 | * @param originX Horizontal origin: 'left', 'center' or 'right'
|
3549 | * @param originY Vertical origin: 'top', 'center' or 'bottom'
|
3550 | */
|
3551 | toLocalPoint(point: Point, originX: string, originY: string): Point;
|
3552 |
|
3553 | /**
|
3554 | * Sets the position of the object taking into consideration the object's origin
|
3555 | * @param pos The new position of the object
|
3556 | * @param originX Horizontal origin: 'left', 'center' or 'right'
|
3557 | * @param originY Vertical origin: 'top', 'center' or 'bottom'
|
3558 | */
|
3559 | setPositionByOrigin(pos: Point, originX: string, originY: string): void;
|
3560 |
|
3561 | /**
|
3562 | * @param to One of 'left', 'center', 'right'
|
3563 | */
|
3564 | adjustPosition(to: string): void;
|
3565 |
|
3566 | // functions from interactivity mixin
|
3567 | // -----------------------------------------------------------------------------------------------------------------------------------
|
3568 | /**
|
3569 | * Draws borders of an object's bounding box.
|
3570 | * Requires public properties: width, height
|
3571 | * Requires public options: padding, borderColor
|
3572 | * @param {CanvasRenderingContext2D} ctx Context to draw on
|
3573 | * @param {Object} styleOverride object to override the object style
|
3574 | * @return {fabric.Object} thisArg
|
3575 | * @chainable
|
3576 | */
|
3577 | drawBorders(ctx: CanvasRenderingContext2D, styleOverride?: any): Object;
|
3578 |
|
3579 | /**
|
3580 | * Draws borders of an object's bounding box when it is inside a group.
|
3581 | * Requires public properties: width, height
|
3582 | * Requires public options: padding, borderColor
|
3583 | * @param {CanvasRenderingContext2D} ctx Context to draw on
|
3584 | * @param {object} options object representing current object parameters
|
3585 | * @param {Object} styleOverride object to override the object style
|
3586 | * @return {fabric.Object} thisArg
|
3587 | * @chainable
|
3588 | */
|
3589 | drawBordersInGroup(ctx: CanvasRenderingContext2D, options?: any, styleOverride?: any): Object;
|
3590 |
|
3591 | /**
|
3592 | * Draws corners of an object's bounding box.
|
3593 | * Requires public properties: width, height
|
3594 | * Requires public options: cornerSize, padding
|
3595 | * @param {CanvasRenderingContext2D} ctx Context to draw on
|
3596 | * @param {Object} styleOverride object to override the object style
|
3597 | * @return {fabric.Object} thisArg
|
3598 | * @chainable
|
3599 | */
|
3600 | drawControls(ctx: CanvasRenderingContext2D, styleOverride?: any): Object;
|
3601 |
|
3602 | /**
|
3603 | * Draws a colored layer behind the object, inside its selection borders.
|
3604 | * Requires public options: padding, selectionBackgroundColor
|
3605 | * this function is called when the context is transformed
|
3606 | * has checks to be skipped when the object is on a staticCanvas
|
3607 | * @param {CanvasRenderingContext2D} ctx Context to draw on
|
3608 | * @return {fabric.Object} thisArg
|
3609 | * @chainable
|
3610 | */
|
3611 | drawSelectionBackground(ctx: CanvasRenderingContext2D): Object;
|
3612 |
|
3613 | /**
|
3614 | * Draws corners of an object's bounding box.
|
3615 | * Requires public properties: width, height
|
3616 | * Requires public options: cornerSize, padding
|
3617 | * @param ctx Context to draw on
|
3618 | */
|
3619 | drawCorners(context: CanvasRenderingContext2D): Object;
|
3620 |
|
3621 | /**
|
3622 | * Returns true if the specified control is visible, false otherwise.
|
3623 | * @param controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.
|
3624 | */
|
3625 | isControlVisible(controlName: string): boolean;
|
3626 | /**
|
3627 | * Sets the visibility of the specified control.
|
3628 | * @param controlName The name of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.
|
3629 | * @param visible true to set the specified control visible, false otherwise
|
3630 | */
|
3631 | setControlVisible(controlName: string, visible: boolean): Object;
|
3632 |
|
3633 | /**
|
3634 | * Sets the visibility state of object controls.
|
3635 | * @param [options] Options object
|
3636 | */
|
3637 | setControlsVisibility(options?: {
|
3638 | bl?: boolean | undefined;
|
3639 | br?: boolean | undefined;
|
3640 | mb?: boolean | undefined;
|
3641 | ml?: boolean | undefined;
|
3642 | mr?: boolean | undefined;
|
3643 | mt?: boolean | undefined;
|
3644 | tl?: boolean | undefined;
|
3645 | tr?: boolean | undefined;
|
3646 | mtr?: boolean | undefined;
|
3647 | }): this;
|
3648 |
|
3649 | // functions from geometry mixin
|
3650 | // -------------------------------------------------------------------------------------------------------------------------------
|
3651 | /**
|
3652 | * Sets corner position coordinates based on current angle, width and height.
|
3653 | * oCoords are used to find the corners
|
3654 | * aCoords are used to quickly find an object on the canvas
|
3655 | * lineCoords are used to quickly find object during pointer events.
|
3656 | * See {@link https://github.com/kangax/fabric.js/wiki/When-to-call-setCoords|When-to-call-setCoords}
|
3657 | * @param {Boolean} [skipCorners] skip calculation of oCoords.
|
3658 | * @return {fabric.Object} thisArg
|
3659 | * @chainable
|
3660 | */
|
3661 | setCoords(skipCorners?: boolean): Object;
|
3662 | /**
|
3663 | * Returns coordinates of object's bounding rectangle (left, top, width, height)
|
3664 | * the box is intented as aligned to axis of canvas.
|
3665 | * @param {Boolean} [absolute] use coordinates without viewportTransform
|
3666 | * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords / .aCoords
|
3667 | * @return {Object} Object with left, top, width, height properties
|
3668 | */
|
3669 | getBoundingRect(
|
3670 | absolute?: boolean,
|
3671 | calculate?: boolean,
|
3672 | ): { left: number; top: number; width: number; height: number };
|
3673 | /**
|
3674 | * Checks if object is fully contained within area of another object
|
3675 | * @param {Object} other Object to test
|
3676 | * @param {Boolean} [absolute] use coordinates without viewportTransform
|
3677 | * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords
|
3678 | * @return {Boolean} true if object is fully contained within area of another object
|
3679 | */
|
3680 | isContainedWithinObject(other: Object, absolute?: boolean, calculate?: boolean): boolean;
|
3681 | /**
|
3682 | * Checks if object is fully contained within area formed by 2 points
|
3683 | * @param pointTL top-left point of area
|
3684 | * @param pointBR bottom-right point of area
|
3685 | */
|
3686 | isContainedWithinRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean;
|
3687 | /**
|
3688 | * Checks if point is inside the object
|
3689 | * @param {fabric.Point} point Point to check against
|
3690 | * @param {Object} [lines] object returned from @method _getImageLines
|
3691 | * @param {Boolean} [absolute] use coordinates without viewportTransform
|
3692 | * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords
|
3693 | * @return {Boolean} true if point is inside the object
|
3694 | */
|
3695 | containsPoint(point: Point, lines?: any, absolute?: boolean, calculate?: boolean): boolean;
|
3696 | /**
|
3697 | * Scales an object (equally by x and y)
|
3698 | * @param value Scale factor
|
3699 | * @return thisArg
|
3700 | */
|
3701 | scale(value: number): Object;
|
3702 | /**
|
3703 | * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)
|
3704 | * @param value New height value
|
3705 | */
|
3706 | scaleToHeight(value: number, absolute?: boolean): Object;
|
3707 | /**
|
3708 | * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)
|
3709 | * @param value New width value
|
3710 | */
|
3711 | scaleToWidth(value: number, absolute?: boolean): Object;
|
3712 | /**
|
3713 | * Checks if object intersects with another object
|
3714 | * @param {Object} other Object to test
|
3715 | * @param {Boolean} [absolute] use coordinates without viewportTransform
|
3716 | * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords
|
3717 | * @return {Boolean} true if object intersects with another object
|
3718 | */
|
3719 | intersectsWithObject(other: Object, absolute?: boolean, calculate?: boolean): boolean;
|
3720 | /**
|
3721 | * Checks if object intersects with an area formed by 2 points
|
3722 | * @param {Object} pointTL top-left point of area
|
3723 | * @param {Object} pointBR bottom-right point of area
|
3724 | * @param {Boolean} [absolute] use coordinates without viewportTransform
|
3725 | * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords
|
3726 | * @return {Boolean} true if object intersects with an area formed by 2 points
|
3727 | */
|
3728 | intersectsWithRect(pointTL: any, pointBR: any, absolute?: boolean, calculate?: boolean): boolean;
|
3729 |
|
3730 | /**
|
3731 | * Animates object's properties
|
3732 | * object.animate('left', ..., {duration: ...});
|
3733 | * @param property Property to animate
|
3734 | * @param value Value to animate property
|
3735 | * @param options The animation options
|
3736 | */
|
3737 | animate(property: string, value: number | string, options?: IAnimationOptions): Object;
|
3738 | /**
|
3739 | * Animates object's properties
|
3740 | * object.animate({ left: ..., top: ... }, { duration: ... });
|
3741 | * @param properties Properties to animate with values to animate to
|
3742 | * @param options The animation options
|
3743 | */
|
3744 | animate(properties: { [key: string]: number | string }, options?: IAnimationOptions): Object;
|
3745 | /**
|
3746 | * Calculate and returns the .coords of an object.
|
3747 | * @return {Object} Object with tl, tr, br, bl ....
|
3748 | * @chainable
|
3749 | */
|
3750 | calcCoords(absolute?: boolean): any;
|
3751 | /**
|
3752 | * calculate trasform Matrix that represent current transformation from
|
3753 | * object properties.
|
3754 | * @param {Boolean} [skipGroup] return transformMatrix for object and not go upward with parents
|
3755 | * @return {Array} matrix Transform Matrix for the object
|
3756 | */
|
3757 | calcTransformMatrix(skipGroup?: boolean): any[];
|
3758 | /**
|
3759 | * calculate transform matrix that represents the current transformations from the
|
3760 | * object's properties, this matrix does not include the group transformation
|
3761 | * @return {Array} transform matrix for the object
|
3762 | */
|
3763 | calcOwnMatrix(): any[];
|
3764 | /**
|
3765 | * return correct set of coordinates for intersection
|
3766 | */
|
3767 | getCoords(absolute?: boolean, calculate?: boolean): [fabric.Point, fabric.Point, fabric.Point, fabric.Point];
|
3768 | /**
|
3769 | * Returns height of an object bounding box counting transformations
|
3770 | * before 2.0 it was named getHeight();
|
3771 | * @return {Number} height value
|
3772 | */
|
3773 | getScaledHeight(): number;
|
3774 | /**
|
3775 | * Returns width of an object bounding box counting transformations
|
3776 | * before 2.0 it was named getWidth();
|
3777 | * @return {Number} width value
|
3778 | */
|
3779 | getScaledWidth(): number;
|
3780 | /**
|
3781 | * Returns id attribute for svg output
|
3782 | * @return {String}
|
3783 | */
|
3784 | getSvgCommons(): string;
|
3785 | /**
|
3786 | * Returns filter for svg shadow
|
3787 | * @return {String}
|
3788 | */
|
3789 | getSvgFilter(): string;
|
3790 | /**
|
3791 | * Returns styles-string for svg-export
|
3792 | * @param {Object} style the object from which to retrieve style properties
|
3793 | * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.
|
3794 | * @return {String}
|
3795 | */
|
3796 | getSvgSpanStyles(style: any, useWhiteSpace?: boolean): string;
|
3797 | /**
|
3798 | * Returns text-decoration property for svg-export
|
3799 | * @param {Object} style the object from which to retrieve style properties
|
3800 | * @return {String}
|
3801 | */
|
3802 | getSvgTextDecoration(style: any): string;
|
3803 | /**
|
3804 | * Checks if object is contained within the canvas with current viewportTransform
|
3805 | * the check is done stopping at first point that appears on screen
|
3806 | * @param {Boolean} [calculate] use coordinates of current position instead of .aCoords
|
3807 | * @return {Boolean} true if object is fully or partially contained within canvas
|
3808 | */
|
3809 | isOnScreen(calculate?: boolean): boolean;
|
3810 | /**
|
3811 | * Checks if object is partially contained within the canvas with current viewportTransform
|
3812 | * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords
|
3813 | * @return {Boolean} true if object is partially contained within canvas
|
3814 | */
|
3815 | isPartiallyOnScreen(calculate?: boolean): boolean;
|
3816 | /**
|
3817 | * This callback function is called every time _discardActiveObject or _setActiveObject
|
3818 | * try to to deselect this object. If the function returns true, the process is cancelled
|
3819 | * @return {Boolean} true to cancel selection
|
3820 | */
|
3821 | onDeselect(options: { e?: Event | undefined; object?: Object | undefined }): boolean;
|
3822 | /**
|
3823 | * This callback function is called every time _discardActiveObject or _setActiveObject
|
3824 | * try to to deselect this object. If the function returns true, the process is cancelled
|
3825 | * @param {Object} [options] options sent from the upper functions
|
3826 | * @param {Event} [options.e] event if the process is generated by an event
|
3827 | */
|
3828 | onDeselect(options: { e?: Event | undefined; object?: fabric.Object | undefined }): boolean;
|
3829 | /**
|
3830 | * This callback function is called every time _discardActiveObject or _setActiveObject
|
3831 | * try to to select this object. If the function returns true, the process is cancelled
|
3832 | */
|
3833 | onSelect(options: { e?: Event | undefined }): boolean;
|
3834 | /**
|
3835 | * Returns svg clipPath representation of an instance
|
3836 | * @param {Function} [reviver] Method for further parsing of svg representation.
|
3837 | * @return {String} svg representation of an instance
|
3838 | */
|
3839 | toClipPathSVG(reviver?: Function): string;
|
3840 | /**
|
3841 | * Returns svg representation of an instance
|
3842 | * @param {Function} [reviver] Method for further parsing of svg representation.
|
3843 | * @return {String} svg representation of an instance
|
3844 | */
|
3845 | toSVG(reviver?: Function): string;
|
3846 | /**
|
3847 | * Translates the coordinates from a set of origin to another (based on the object's dimensions)
|
3848 | * @param {fabric.Point} point The point which corresponds to the originX and originY params
|
3849 | * @param {String} fromOriginX Horizontal origin: 'left', 'center' or 'right'
|
3850 | * @param {String} fromOriginY Vertical origin: 'top', 'center' or 'bottom'
|
3851 | * @param {String} toOriginX Horizontal origin: 'left', 'center' or 'right'
|
3852 | * @param {String} toOriginY Vertical origin: 'top', 'center' or 'bottom'
|
3853 | * @return {fabric.Point}
|
3854 | */
|
3855 | translateToGivenOrigin(
|
3856 | pointL: Point,
|
3857 | fromOriginX: string,
|
3858 | fromOriginY: string,
|
3859 | toOriginX: string,
|
3860 | toOriginY: string,
|
3861 | ): Point;
|
3862 | /*
|
3863 | * Calculate object dimensions from its properties
|
3864 | * @private
|
3865 | * @return {Object} .x width dimension
|
3866 | * @return {Object} .y height dimension
|
3867 | */
|
3868 | _getNonTransformedDimensions(): { x: number; y: number };
|
3869 | /**
|
3870 | * Returns the top, left coordinates
|
3871 | * @private
|
3872 | * @return {fabric.Point}
|
3873 | */
|
3874 | _getLeftTopCoords(): Point;
|
3875 | /*
|
3876 | * Calculate object bounding box dimensions from its properties scale, skew.
|
3877 | * @private
|
3878 | * @return {Object} .x width dimension
|
3879 | * @return {Object} .y height dimension
|
3880 | */
|
3881 | _getTransformedDimensions(skewX?: number, skewY?: number): { x: number; y: number };
|
3882 |
|
3883 | /**
|
3884 | * @private
|
3885 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
3886 | */
|
3887 | _renderFill(ctx: CanvasRenderingContext2D): void;
|
3888 | /**
|
3889 | * @param ctx
|
3890 | * @private
|
3891 | */
|
3892 | _renderStroke(ctx: CanvasRenderingContext2D): void;
|
3893 | /**
|
3894 | * @private
|
3895 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
3896 | */
|
3897 | _removeShadow(ctx: CanvasRenderingContext2D): void;
|
3898 | /**
|
3899 | * @private
|
3900 | * Sets line dash
|
3901 | * @param {CanvasRenderingContext2D} ctx Context to set the dash line on
|
3902 | * @param {Array} dashArray array representing dashes
|
3903 | * @param {Function} alternative function to call if browser does not support lineDash
|
3904 | */
|
3905 | _setLineDash(
|
3906 | ctx: CanvasRenderingContext2D,
|
3907 | dashArray: number[],
|
3908 | alternative?: (ctx: CanvasRenderingContext2D) => void,
|
3909 | ): void;
|
3910 | /**
|
3911 | * @private
|
3912 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
3913 | * @param {Object} filler fabric.Pattern or fabric.Gradient
|
3914 | * @return {Object} offset.offsetX offset for text rendering
|
3915 | * @return {Object} offset.offsetY offset for text rendering
|
3916 | */
|
3917 | _applyPatternGradientTransform(ctx: CanvasRenderingContext2D, filler: string | Pattern | Gradient): void;
|
3918 | /**
|
3919 | * @private
|
3920 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
3921 | */
|
3922 | _render(ctx: CanvasRenderingContext2D): void;
|
3923 | /**
|
3924 | * @private
|
3925 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
3926 | */
|
3927 | _renderPaintInOrder(ctx: CanvasRenderingContext2D): void;
|
3928 | /**
|
3929 | * Returns the instance of the control visibility set for this object.
|
3930 | * @private
|
3931 | * @returns {Object}
|
3932 | */
|
3933 | _getControlsVisibility(): {
|
3934 | tl: boolean;
|
3935 | tr: boolean;
|
3936 | br: boolean;
|
3937 | bl: boolean;
|
3938 | ml: boolean;
|
3939 | mt: boolean;
|
3940 | mr: boolean;
|
3941 | mb: boolean;
|
3942 | mtr: boolean;
|
3943 | };
|
3944 | /**
|
3945 | * Determines which corner has been clicked
|
3946 | * @private
|
3947 | * @param {Object} pointer The pointer indicating the mouse position
|
3948 | * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or false if nothing is found
|
3949 | */
|
3950 | _findTargetCorner(pointer: {
|
3951 | x: number;
|
3952 | y: number;
|
3953 | }): boolean | 'bl' | 'br' | 'mb' | 'ml' | 'mr' | 'mt' | 'tl' | 'tr' | 'mtr';
|
3954 | /**
|
3955 | * @private
|
3956 | * @param {String} key
|
3957 | * @param {*} value
|
3958 | */
|
3959 | _set(key: string, value: any): Object;
|
3960 | /**
|
3961 | * Creates fabric Object instance
|
3962 | * @param {string} Class name
|
3963 | * @param {fabric.Object} Original object
|
3964 | * @param {Function} Callback when complete
|
3965 | * @param {Object} Extra parameters for fabric.Object
|
3966 | * @private
|
3967 | * @return {fabric.Object}
|
3968 | */
|
3969 | static _fromObject(className: string, object: Object, callback?: Function, extraParam?: any): Object;
|
3970 | /**
|
3971 | * Defines the number of fraction digits to use when serializing object values.
|
3972 | */
|
3973 | static NUM_FRACTION_DIGITS?: number | undefined;
|
3974 | }
|
3975 |
|
3976 | interface IPathOptions extends IObjectOptions {
|
3977 | /**
|
3978 | * Array of path points
|
3979 | */
|
3980 | path?: Point[] | undefined;
|
3981 | }
|
3982 | export interface Path extends Object, IPathOptions {}
|
3983 | export class Path {
|
3984 | /**
|
3985 | * Constructor
|
3986 | * @param path Path data (sequence of coordinates and corresponding "command" tokens)
|
3987 | * @param [options] Options object
|
3988 | */
|
3989 | constructor(path?: string | Point[], options?: IPathOptions);
|
3990 |
|
3991 | pathOffset: Point;
|
3992 |
|
3993 | /**
|
3994 | * Returns svg clipPath representation of an instance
|
3995 | * @param {Function} [reviver] Method for further parsing of svg representation.
|
3996 | * @return {String} svg representation of an instance
|
3997 | */
|
3998 | toClipPathSVG(reviver?: Function): string;
|
3999 | /**
|
4000 | * Returns svg representation of an instance
|
4001 | * @param [reviver] Method for further parsing of svg representation.
|
4002 | * @return svg representation of an instance
|
4003 | */
|
4004 | toSVG(reviver?: Function): string;
|
4005 | /**
|
4006 | * Creates an instance of fabric.Path from an SVG <path> element
|
4007 | * @param element to parse
|
4008 | * @param callback Callback to invoke when an fabric.Path instance is created
|
4009 | * @param [options] Options object
|
4010 | */
|
4011 | static fromElement(element: SVGElement, callback: Function, options?: IPathOptions): Path;
|
4012 | /**
|
4013 | * Creates an instance of fabric.Path from an object
|
4014 | * @param callback Callback to invoke when an fabric.Path instance is created
|
4015 | */
|
4016 | static fromObject(object: any, callback: Function): Path;
|
4017 | /**
|
4018 | * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`)
|
4019 | */
|
4020 | static ATTRIBUTE_NAMES: string[];
|
4021 | }
|
4022 | export interface Polygon extends IPolylineOptions {}
|
4023 | export class Polygon extends Polyline {
|
4024 | /**
|
4025 | * Constructor
|
4026 | * @param points Array of points
|
4027 | * @param [options] Options object
|
4028 | */
|
4029 | constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions);
|
4030 | /**
|
4031 | * Returns Polygon instance from an SVG element
|
4032 | * @param element Element to parse
|
4033 | * @param [options] Options object
|
4034 | */
|
4035 | static fromElement(element: SVGElement, options?: IPolylineOptions): Polygon;
|
4036 | /**
|
4037 | * Returns fabric.Polygon instance from an object representation
|
4038 | * @param object Object to create an instance from
|
4039 | */
|
4040 | static fromObject(object: any): Polygon;
|
4041 | }
|
4042 |
|
4043 | interface IPolylineOptions extends IObjectOptions {
|
4044 | /**
|
4045 | * Points array
|
4046 | */
|
4047 | points?: Point[] | undefined;
|
4048 | }
|
4049 | export interface Polyline extends IPolylineOptions {}
|
4050 | export class Polyline extends Object {
|
4051 | /**
|
4052 | * Constructor
|
4053 | * @param points Array of points (where each point is an object with x and y)
|
4054 | * @param [options] Options object
|
4055 | * @param [skipOffset] Whether points offsetting should be skipped
|
4056 | */
|
4057 | constructor(points: Array<{ x: number; y: number }>, options?: IPolylineOptions);
|
4058 |
|
4059 | pathOffset: Point;
|
4060 |
|
4061 | /**
|
4062 | * Calculate the polygon min and max point from points array,
|
4063 | * returning an object with left, top, width, height to measure the polygon size
|
4064 | * @private
|
4065 | * @return {Object} object.left X coordinate of the polygon leftmost point
|
4066 | * @return {Object} object.top Y coordinate of the polygon topmost point
|
4067 | * @return {Object} object.width distance between X coordinates of the polygon leftmost and rightmost point
|
4068 | * @return {Object} object.height distance between Y coordinates of the polygon topmost and bottommost point
|
4069 | */
|
4070 | _calcDimensions(): { left: number; top: number; width: number; height: number };
|
4071 | /**
|
4072 | * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`)
|
4073 | */
|
4074 | static ATTRIBUTE_NAMES: string[];
|
4075 | /**
|
4076 | * Returns Polyline instance from an SVG element
|
4077 | * @param element Element to parse
|
4078 | * @param [options] Options object
|
4079 | */
|
4080 | static fromElement(element: SVGElement, options?: IPolylineOptions): Polyline;
|
4081 | /**
|
4082 | * Returns fabric.Polyline instance from an object representation
|
4083 | * @param object Object to create an instance from
|
4084 | */
|
4085 | static fromObject(object: any): Polyline;
|
4086 | }
|
4087 |
|
4088 | interface IRectOptions extends IObjectOptions {
|
4089 | /**
|
4090 | * Horizontal border radius
|
4091 | */
|
4092 | rx?: number | undefined;
|
4093 |
|
4094 | /**
|
4095 | * Vertical border radius
|
4096 | */
|
4097 | ry?: number | undefined;
|
4098 | }
|
4099 |
|
4100 | export interface Rect extends IRectOptions {}
|
4101 | export class Rect extends Object {
|
4102 | /**
|
4103 | * Constructor
|
4104 | * @param [options] Options object
|
4105 | */
|
4106 | constructor(options?: IRectOptions);
|
4107 | /**
|
4108 | * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`)
|
4109 | */
|
4110 | static ATTRIBUTE_NAMES: string[];
|
4111 | /**
|
4112 | * Returns Rect instance from an SVG element
|
4113 | * @param element Element to parse
|
4114 | * @param [options] Options object
|
4115 | */
|
4116 | static fromElement(element: SVGElement, options?: IRectOptions): Rect;
|
4117 | /**
|
4118 | * Returns Rect instance from an object representation
|
4119 | * @param object Object to create an instance from
|
4120 | */
|
4121 | static fromObject(object: any): Rect;
|
4122 | }
|
4123 |
|
4124 | interface TextOptions extends IObjectOptions {
|
4125 | type?: string | undefined;
|
4126 | /**
|
4127 | * Font size (in pixels)
|
4128 | * @type Number
|
4129 | */
|
4130 | fontSize?: number | undefined;
|
4131 | /**
|
4132 | * Font weight (e.g. bold, normal, 400, 600, 800)
|
4133 | * @type {(Number|String)}
|
4134 | */
|
4135 | fontWeight?: string | number | undefined;
|
4136 | /**
|
4137 | * Font family
|
4138 | * @type String
|
4139 | */
|
4140 | fontFamily?: string | undefined;
|
4141 | /**
|
4142 | * Text decoration underline.
|
4143 | * @type Boolean
|
4144 | */
|
4145 | underline?: boolean | undefined;
|
4146 | /**
|
4147 | * Text decoration overline.
|
4148 | * @type Boolean
|
4149 | */
|
4150 | overline?: boolean | undefined;
|
4151 | /**
|
4152 | * Text decoration linethrough.
|
4153 | * @type Boolean
|
4154 | */
|
4155 | linethrough?: boolean | undefined;
|
4156 | /**
|
4157 | * Text alignment. Possible values: "left", "center", "right", "justify",
|
4158 | * "justify-left", "justify-center" or "justify-right".
|
4159 | * @type String
|
4160 | */
|
4161 | textAlign?: string | undefined;
|
4162 | /**
|
4163 | * Font style . Possible values: "", "normal", "italic" or "oblique".
|
4164 | * @type String
|
4165 | */
|
4166 | fontStyle?: '' | 'normal' | 'italic' | 'oblique' | undefined;
|
4167 | /**
|
4168 | * Line height
|
4169 | * @type Number
|
4170 | */
|
4171 | lineHeight?: number | undefined;
|
4172 | /**
|
4173 | * Superscript schema object (minimum overlap)
|
4174 | * @type {Object}
|
4175 | */
|
4176 | superscript?: { size: number; baseline: number } | undefined;
|
4177 | /**
|
4178 | * Subscript schema object (minimum overlap)
|
4179 | * @type {Object}
|
4180 | */
|
4181 | subscript?: { size: number; baseline: number } | undefined;
|
4182 | /**
|
4183 | * Background color of text lines
|
4184 | * @type String
|
4185 | */
|
4186 | textBackgroundColor?: string | undefined;
|
4187 | /**
|
4188 | * When defined, an object is rendered via stroke and this property specifies its color.
|
4189 | * <b>Backwards incompatibility note:</b> This property was named "strokeStyle" until v1.1.6
|
4190 | */
|
4191 | stroke?: string | undefined;
|
4192 | /**
|
4193 | * Shadow object representing shadow of this shape.
|
4194 | * <b>Backwards incompatibility note:</b> This property was named "textShadow" (String) until v1.2.11
|
4195 | * @type fabric.Shadow
|
4196 | */
|
4197 | shadow?: Shadow | string | undefined;
|
4198 | /**
|
4199 | * additional space between characters
|
4200 | * expressed in thousands of em unit
|
4201 | * @type Number
|
4202 | */
|
4203 | charSpacing?: number | undefined;
|
4204 | /**
|
4205 | * Object containing character styles - top-level properties -> line numbers,
|
4206 | * 2nd-level properties - charater numbers
|
4207 | * @type Object
|
4208 | */
|
4209 | styles?: any;
|
4210 | /**
|
4211 | * Baseline shift, stlyes only, keep at 0 for the main text object
|
4212 | * @type {Number}
|
4213 | */
|
4214 | deltaY?: number | undefined;
|
4215 | /**
|
4216 | * Text input direction. supporting RTL languages.
|
4217 | */
|
4218 | direction?: 'ltr' | 'rtl' | undefined;
|
4219 | text?: string | undefined;
|
4220 | /**
|
4221 | * List of properties to consider when checking if cache needs refresh
|
4222 | * @type Array
|
4223 | */
|
4224 | cacheProperties?: string[] | undefined;
|
4225 | /**
|
4226 | * List of properties to consider when checking if
|
4227 | * state of an object is changed ({@link fabric.Object#hasStateChanged})
|
4228 | * as well as for history (undo/redo) purposes
|
4229 | * @type Array
|
4230 | */
|
4231 | stateProperties?: string[] | undefined;
|
4232 | }
|
4233 | export interface Text extends TextOptions {}
|
4234 | export class Text extends Object {
|
4235 | _text: string[];
|
4236 | cursorOffsetCache: { top: number; left: number };
|
4237 | /**
|
4238 | * Properties which when set cause object to change dimensions
|
4239 | * @type Object
|
4240 | * @private
|
4241 | */
|
4242 | _dimensionAffectingProps: string[];
|
4243 | /**
|
4244 | * List of lines in text object
|
4245 | * @type Array<string>
|
4246 | */
|
4247 | textLines: string[];
|
4248 | /**
|
4249 | * List of grapheme lines in text object
|
4250 | * @private
|
4251 | * @type Array<string>
|
4252 | */
|
4253 | _textLines: string[][];
|
4254 | /**
|
4255 | * List of unwrapped grapheme lines in text object
|
4256 | * @private
|
4257 | * @type Array<string>
|
4258 | */
|
4259 | _unwrappedTextLines: string[][];
|
4260 | /**
|
4261 | * Use this regular expression to filter for whitespaces that is not a new line.
|
4262 | * Mostly used when text is 'justify' aligned.
|
4263 | * @private
|
4264 | * @type RegExp
|
4265 | */
|
4266 | _reSpacesAndTabs: RegExp;
|
4267 | /**
|
4268 | * Use this regular expression to filter for whitespace that is not a new line.
|
4269 | * Mostly used when text is 'justify' aligned.
|
4270 | * @private
|
4271 | * @type RegExp
|
4272 | */
|
4273 | _reSpaceAndTab: RegExp;
|
4274 | /**
|
4275 | * List of line widths
|
4276 | * @private
|
4277 | * @type Array<Number>
|
4278 | */
|
4279 | __lineWidths: number[];
|
4280 | /**
|
4281 | * List of line heights
|
4282 | * @private
|
4283 | * @type Array<Number>
|
4284 | */
|
4285 | __lineHeights: number[];
|
4286 | /**
|
4287 | * Contains characters bounding boxes for each line and char
|
4288 | * @private
|
4289 | * @type Array of char grapheme bounding boxes
|
4290 | */
|
4291 | __charBounds?: Array<
|
4292 | Array<{ width: number; left: number; height?: number | undefined; kernedWidth?: number | undefined; deltaY?: number | undefined }>
|
4293 | > | undefined;
|
4294 | /**
|
4295 | * Text Line proportion to font Size (in pixels)
|
4296 | * @private
|
4297 | * @type Number
|
4298 | */
|
4299 | _fontSizeMult: number;
|
4300 | /**
|
4301 | * @private
|
4302 | * @type Number
|
4303 | */
|
4304 | _fontSizeFraction: number;
|
4305 | /**
|
4306 | * @private
|
4307 | * @type boolean
|
4308 | */
|
4309 | __skipDimension: boolean;
|
4310 | /**
|
4311 | * use this size when measuring text. To avoid IE11 rounding errors
|
4312 | * @type {Number}
|
4313 | * @default
|
4314 | * @readonly
|
4315 | * @private
|
4316 | */
|
4317 | CACHE_FONT_SIZE: number;
|
4318 |
|
4319 | /**
|
4320 | * Constructor
|
4321 | * @param text Text string
|
4322 | * @param [options] Options object
|
4323 | */
|
4324 | constructor(text: string, options?: TextOptions);
|
4325 |
|
4326 | /**
|
4327 | * Return a context for measurement of text string.
|
4328 | * if created it gets stored for reuse
|
4329 | * @return {fabric.Text} thisArg
|
4330 | */
|
4331 | getMeasuringContext(): CanvasRenderingContext2D;
|
4332 |
|
4333 | /**
|
4334 | * Initialize or update text dimensions.
|
4335 | * Updates this.width and this.height with the proper values.
|
4336 | * Does not return dimensions.
|
4337 | */
|
4338 | initDimensions(): void;
|
4339 |
|
4340 | /**
|
4341 | * Enlarge space boxes and shift the others
|
4342 | */
|
4343 | enlargeSpaces(): void;
|
4344 |
|
4345 | /**
|
4346 | * Detect if the text line is ended with an hard break
|
4347 | * text and itext do not have wrapping, return false
|
4348 | * @return {Boolean}
|
4349 | */
|
4350 | isEndOfWrapping(lineIndex: number): boolean;
|
4351 |
|
4352 | /**
|
4353 | * Returns string representation of an instance
|
4354 | */
|
4355 | toString(): string;
|
4356 |
|
4357 | /**
|
4358 | * Computes height of character at given position
|
4359 | * @param {Number} line the line number
|
4360 | * @param {Number} char the character number
|
4361 | * @return {Number} fontSize of the character
|
4362 | */
|
4363 | getHeightOfChar(line: number, char: number): number;
|
4364 |
|
4365 | /**
|
4366 | * measure a text line measuring all characters.
|
4367 | * @param {Number} lineIndex line number
|
4368 | * @return {Object} object.width total width of characters
|
4369 | * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs
|
4370 | */
|
4371 | measureLine(lineIndex: number): { width: number; numOfSpaces: number };
|
4372 |
|
4373 | /**
|
4374 | * Calculate height of line at 'lineIndex'
|
4375 | * @param {Number} lineIndex index of line to calculate
|
4376 | * @return {Number}
|
4377 | */
|
4378 | getHeightOfLine(lineIndex: number): number;
|
4379 |
|
4380 | /**
|
4381 | * Calculate text box height
|
4382 | */
|
4383 | calcTextHeight(): number;
|
4384 |
|
4385 | /**
|
4386 | * Turns the character into a 'superior figure' (i.e. 'superscript')
|
4387 | * @param {Number} start selection start
|
4388 | * @param {Number} end selection end
|
4389 | * @returns {fabric.Text} thisArg
|
4390 | * @chainable
|
4391 | */
|
4392 | setSuperscript(start: number, end: number): Text;
|
4393 |
|
4394 | /**
|
4395 | * Turns the character into an 'inferior figure' (i.e. 'subscript')
|
4396 | * @param {Number} start selection start
|
4397 | * @param {Number} end selection end
|
4398 | * @returns {fabric.Text} thisArg
|
4399 | * @chainable
|
4400 | */
|
4401 | setSubscript(start: number, end: number): Text;
|
4402 |
|
4403 | /**
|
4404 | * Retrieves the value of property at given character position
|
4405 | * @param {Number} lineIndex the line number
|
4406 | * @param {Number} charIndex the charater number
|
4407 | * @param {String} property the property name
|
4408 | * @returns the value of 'property'
|
4409 | */
|
4410 | getValueOfPropertyAt(lineIndex: number, charIndex: number, property: string): any;
|
4411 |
|
4412 | static DEFAULT_SVG_FONT_SIZE: number;
|
4413 |
|
4414 | /**
|
4415 | * Returns fabric.Text instance from an SVG element (<b>not yet implemented</b>)
|
4416 | * @static
|
4417 | * @memberOf fabric.Text
|
4418 | * @param {SVGElement} element Element to parse
|
4419 | * @param {Function} callback callback function invoked after parsing
|
4420 | * @param {Object} [options] Options object
|
4421 | */
|
4422 | static fromElement(element: SVGElement, callback?: Function, options?: TextOptions): Text;
|
4423 |
|
4424 | /**
|
4425 | * Returns fabric.Text instance from an object representation
|
4426 | * @static
|
4427 | * @memberOf fabric.Text
|
4428 | * @param {Object} object Object to create an instance from
|
4429 | * @param {Function} [callback] Callback to invoke when an fabric.Text instance is created
|
4430 | */
|
4431 | static fromObject(object: any, callback?: Function): Text;
|
4432 |
|
4433 | /**
|
4434 | * Check if characters in a text have a value for a property
|
4435 | * whose value matches the textbox's value for that property. If so,
|
4436 | * the character-level property is deleted. If the character
|
4437 | * has no other properties, then it is also deleted. Finally,
|
4438 | * if the line containing that character has no other characters
|
4439 | * then it also is deleted.
|
4440 | *
|
4441 | * @param {string} property The property to compare between characters and text.
|
4442 | */
|
4443 | cleanStyle(property: string): void;
|
4444 |
|
4445 | /**
|
4446 | * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)
|
4447 | * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.
|
4448 | * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. usefull to manage styles.
|
4449 | */
|
4450 | get2DCursorLocation(selectionStart?: number, skipWrapping?: boolean): { lineIndex: number; charIndex: number };
|
4451 |
|
4452 | /**
|
4453 | * return a new object that contains all the style property for a character
|
4454 | * the object returned is newly created
|
4455 | * @param {Number} lineIndex of the line where the character is
|
4456 | * @param {Number} charIndex position of the character on the line
|
4457 | * @return {Object} style object
|
4458 | */
|
4459 | getCompleteStyleDeclaration(lineIndex: number, charIndex: number): any;
|
4460 |
|
4461 | /**
|
4462 | * Gets style of a current selection/cursor (at the start position)
|
4463 | * if startIndex or endIndex are not provided, slectionStart or selectionEnd will be used.
|
4464 | * @param {Number} [startIndex] Start index to get styles at
|
4465 | * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1
|
4466 | * @param {Boolean} [complete] get full style or not
|
4467 | * @return {Array} styles an array with one, zero or more Style objects
|
4468 | */
|
4469 | getSelectionStyles(startIndex?: number, endIndex?: number, complete?: boolean): any[];
|
4470 |
|
4471 | /**
|
4472 | * Returns styles-string for svg-export
|
4473 | * @param {Boolean} skipShadow a boolean to skip shadow filter output
|
4474 | * @return {String}
|
4475 | */
|
4476 | getSvgStyles(skipShadow?: boolean): string;
|
4477 |
|
4478 | /**
|
4479 | * Returns true if object has no styling or no styling in a line
|
4480 | * @param {Number} lineIndex , lineIndex is on wrapped lines.
|
4481 | * @return {Boolean}
|
4482 | */
|
4483 | isEmptyStyles(lineIndex: number): boolean;
|
4484 |
|
4485 | /**
|
4486 | * Remove a style property or properties from all individual character styles
|
4487 | * in a text object. Deletes the character style object if it contains no other style
|
4488 | * props. Deletes a line style object if it contains no other character styles.
|
4489 | *
|
4490 | * @param {String} props The property to remove from character styles.
|
4491 | */
|
4492 | removeStyle(property: string): void;
|
4493 |
|
4494 | /**
|
4495 | * Sets style of a current selection, if no selection exist, do not set anything.
|
4496 | * @param {Object} [styles] Styles object
|
4497 | * @param {Number} [startIndex] Start index to get styles at
|
4498 | * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1
|
4499 | * @return {fabric.IText} thisArg
|
4500 | * @chainable
|
4501 | */
|
4502 | setSelectionStyles(styles: any, startIndex?: number, endIndex?: number): Text;
|
4503 |
|
4504 | /**
|
4505 | * Returns true if object has a style property or has it ina specified line
|
4506 | * @param {Number} lineIndex
|
4507 | * @return {Boolean}
|
4508 | */
|
4509 | styleHas(property: string, lineIndex?: number): boolean;
|
4510 |
|
4511 | /**
|
4512 | * Measure a single line given its index. Used to calculate the initial
|
4513 | * text bounding box. The values are calculated and stored in __lineWidths cache.
|
4514 | * @private
|
4515 | * @param {Number} lineIndex line number
|
4516 | * @return {Number} Line width
|
4517 | */
|
4518 | getLineWidth(lineIndex: number): number;
|
4519 |
|
4520 | /**
|
4521 | * @private
|
4522 | * @param {Number} lineIndex index text line
|
4523 | * @return {Number} Line left offset
|
4524 | */
|
4525 | _getLineLeftOffset(lineIndex: number): number;
|
4526 |
|
4527 | /**
|
4528 | * apply all the character style to canvas for rendering
|
4529 | * @private
|
4530 | * @param {String} _char
|
4531 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
4532 | * @param {Number} lineIndex
|
4533 | * @param {Number} charIndex
|
4534 | * @param {Object} [decl]
|
4535 | */
|
4536 | _applyCharStyles(
|
4537 | method: string,
|
4538 | ctx: CanvasRenderingContext2D,
|
4539 | lineIndex: number,
|
4540 | charIndex: number,
|
4541 | styleDeclaration: any,
|
4542 | ): void;
|
4543 |
|
4544 | /**
|
4545 | * get the reference, not a clone, of the style object for a given character
|
4546 | * @param {Number} lineIndex
|
4547 | * @param {Number} charIndex
|
4548 | * @return {Object} style object
|
4549 | */
|
4550 | _getStyleDeclaration(lineIndex: number, charIndex: number): any;
|
4551 |
|
4552 | /**
|
4553 | * Generate an object that translates the style object so that it is
|
4554 | * broken up by visual lines (new lines and automatic wrapping).
|
4555 | * The original text styles object is broken up by actual lines (new lines only),
|
4556 | * which is only sufficient for Text / IText
|
4557 | * @private
|
4558 | */
|
4559 | _generateStyleMap(textInfo: {
|
4560 | _unwrappedLines: string[];
|
4561 | lines: string[];
|
4562 | graphemeText: string[];
|
4563 | graphemeLines: string[];
|
4564 | }): { [s: number]: { line: number; offset: number } };
|
4565 |
|
4566 | /**
|
4567 | * @private
|
4568 | * Gets the width of character spacing
|
4569 | */
|
4570 | _getWidthOfCharSpacing(): number;
|
4571 |
|
4572 | /**
|
4573 | * measure and return the width of a single character.
|
4574 | * possibly overridden to accommodate different measure logic or
|
4575 | * to hook some external lib for character measurement
|
4576 | * @private
|
4577 | * @param {String} char to be measured
|
4578 | * @param {Object} charStyle style of char to be measured
|
4579 | * @param {String} [previousChar] previous char
|
4580 | * @param {Object} [prevCharStyle] style of previous char
|
4581 | * @return {Object} object contained char width anf kerned width
|
4582 | */
|
4583 | _measureChar(
|
4584 | _char: string,
|
4585 | charStyle: any,
|
4586 | previousChar: string,
|
4587 | prevCharStyle: any,
|
4588 | ): { width: number; kernedWidth: number };
|
4589 |
|
4590 | /**
|
4591 | * @private
|
4592 | * @param {String} method
|
4593 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
4594 | * @param {String} line Content of the line
|
4595 | * @param {Number} left
|
4596 | * @param {Number} top
|
4597 | * @param {Number} lineIndex
|
4598 | * @param {Number} charOffset
|
4599 | */
|
4600 | _renderChars(
|
4601 | method: string,
|
4602 | ctx: CanvasRenderingContext2D,
|
4603 | line: string,
|
4604 | left: number,
|
4605 | top: number,
|
4606 | lineIndex: number,
|
4607 | ): void;
|
4608 |
|
4609 | /**
|
4610 | * @private
|
4611 | * @param {String} method
|
4612 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
4613 | * @param {Number} lineIndex
|
4614 | * @param {Number} charIndex
|
4615 | * @param {String} _char
|
4616 | * @param {Number} left Left coordinate
|
4617 | * @param {Number} top Top coordinate
|
4618 | * @param {Number} lineHeight Height of the line
|
4619 | */
|
4620 | _renderChar(
|
4621 | method: string,
|
4622 | ctx: CanvasRenderingContext2D,
|
4623 | lineIndex: number,
|
4624 | charIndex: number,
|
4625 | _char: string,
|
4626 | left: number,
|
4627 | top: number,
|
4628 | ): void;
|
4629 |
|
4630 | /**
|
4631 | * @private
|
4632 | * @param {String} method Method name ("fillText" or "strokeText")
|
4633 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
4634 | * @param {Array} line Text to render
|
4635 | * @param {Number} left Left position of text
|
4636 | * @param {Number} top Top position of text
|
4637 | * @param {Number} lineIndex Index of a line in a text
|
4638 | */
|
4639 | _renderTextLine(
|
4640 | method: string,
|
4641 | ctx: CanvasRenderingContext2D,
|
4642 | line: string[],
|
4643 | left: number,
|
4644 | top: number,
|
4645 | lineIndex: number,
|
4646 | ): void;
|
4647 |
|
4648 | /**
|
4649 | * @private
|
4650 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
4651 | */
|
4652 | _renderText(ctx: CanvasRenderingContext2D): void;
|
4653 |
|
4654 | /**
|
4655 | * @private
|
4656 | */
|
4657 | _clearCache(): void;
|
4658 |
|
4659 | /**
|
4660 | * Divides text into lines of text and lines of graphemes.
|
4661 | * @private
|
4662 | * @returns {Object} Lines and text in the text
|
4663 | */
|
4664 | _splitText(): { _unwrappedLines: string[]; lines: string[]; graphemeText: string[]; graphemeLines: string[] };
|
4665 |
|
4666 | /**
|
4667 | * @private
|
4668 | * @param {Object} prevStyle
|
4669 | * @param {Object} thisStyle
|
4670 | */
|
4671 | _hasStyleChanged(prevStyle: any, thisStyle: any): boolean;
|
4672 |
|
4673 | /**
|
4674 | * Set the font parameter of the context with the object properties or with charStyle
|
4675 | * @private
|
4676 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
4677 | * @param {Object} [charStyle] object with font style properties
|
4678 | * @param {String} [charStyle.fontFamily] Font Family
|
4679 | * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )
|
4680 | * @param {String} [charStyle.fontWeight] Font weight
|
4681 | * @param {String} [charStyle.fontStyle] Font style (italic|normal)
|
4682 | */
|
4683 | _setTextStyles(
|
4684 | ctx: CanvasRenderingContext2D,
|
4685 | charStyle?: { fontFamily: string; fontSize: number; fontWieght: string; fontStyle: string },
|
4686 | forMeasuring?: boolean,
|
4687 | ): void;
|
4688 |
|
4689 | /**
|
4690 | * @private
|
4691 | * @param {String} method Method name ("fillText" or "strokeText")
|
4692 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
4693 | * @param {String} line Text to render
|
4694 | * @param {Number} left Left position of text
|
4695 | * @param {Number} top Top position of text
|
4696 | * @param {Number} lineIndex Index of a line in a text
|
4697 | */
|
4698 | _renderTextLine(
|
4699 | method: string,
|
4700 | ctx: CanvasRenderingContext2D,
|
4701 | line: string,
|
4702 | left: number,
|
4703 | top: number,
|
4704 | lineIndex: number,
|
4705 | ): void;
|
4706 |
|
4707 | /**
|
4708 | * @private
|
4709 | */
|
4710 | _shouldClearDimensionCache(): boolean;
|
4711 | }
|
4712 | interface ITextOptions extends TextOptions {
|
4713 | /**
|
4714 | * Index where text selection starts (or where cursor is when there is no selection)
|
4715 | * @type Number
|
4716 | */
|
4717 | selectionStart?: number | undefined;
|
4718 | /**
|
4719 | * Index where text selection ends
|
4720 | * @type Number
|
4721 | */
|
4722 | selectionEnd?: number | undefined;
|
4723 | /**
|
4724 | * Color of text selection
|
4725 | * @type String
|
4726 | */
|
4727 | selectionColor?: string | undefined;
|
4728 | /**
|
4729 | * Indicates whether text is selected
|
4730 | * @type Boolean
|
4731 | */
|
4732 | selected?: boolean | undefined;
|
4733 | /**
|
4734 | * Indicates whether text is in editing mode
|
4735 | * @type Boolean
|
4736 | */
|
4737 | isEditing?: boolean | undefined;
|
4738 | /**
|
4739 | * Indicates whether a text can be edited
|
4740 | * @type Boolean
|
4741 | */
|
4742 | editable?: boolean | undefined;
|
4743 | /**
|
4744 | * Border color of text object while it's in editing mode
|
4745 | * @type String
|
4746 | */
|
4747 | editingBorderColor?: string | undefined;
|
4748 | /**
|
4749 | * Width of cursor (in px)
|
4750 | * @type Number
|
4751 | */
|
4752 | cursorWidth?: number | undefined;
|
4753 | /**
|
4754 | * Color of default cursor (when not overwritten by character style)
|
4755 | * @type String
|
4756 | */
|
4757 | cursorColor?: string | undefined;
|
4758 | /**
|
4759 | * Delay between cursor blink (in ms)
|
4760 | * @type Number
|
4761 | */
|
4762 | cursorDelay?: number | undefined;
|
4763 | /**
|
4764 | * Duration of cursor fadein (in ms)
|
4765 | * @type Number
|
4766 | */
|
4767 | cursorDuration?: number | undefined;
|
4768 | /**
|
4769 | * Indicates whether internal text char widths can be cached
|
4770 | * @type Boolean
|
4771 | */
|
4772 | caching?: boolean | undefined;
|
4773 | /**
|
4774 | * Helps determining when the text is in composition, so that the cursor
|
4775 | * rendering is altered.
|
4776 | */
|
4777 | inCompositionMode?: boolean | undefined;
|
4778 | path?: string | undefined;
|
4779 | useNative?: boolean | undefined;
|
4780 | /**
|
4781 | * For functionalities on keyDown + ctrl || cmd
|
4782 | */
|
4783 | ctrlKeysMapDown?: any;
|
4784 | /**
|
4785 | * For functionalities on keyUp + ctrl || cmd
|
4786 | */
|
4787 | ctrlKeysMapUp?: any;
|
4788 | /**
|
4789 | * For functionalities on keyDown
|
4790 | * Map a special key to a function of the instance/prototype
|
4791 | * If you need different behaviour for ESC or TAB or arrows, you have to change
|
4792 | * this map setting the name of a function that you build on the fabric.Itext or
|
4793 | * your prototype.
|
4794 | * the map change will affect all Instances unless you need for only some text Instances
|
4795 | * in that case you have to clone this object and assign your Instance.
|
4796 | * this.keysMap = fabric.util.object.clone(this.keysMap);
|
4797 | * The function must be in fabric.Itext.prototype.myFunction And will receive event as args[0]
|
4798 | */
|
4799 | keysMap?: any;
|
4800 | /**
|
4801 | * Exposes underlying hidden text area
|
4802 | */
|
4803 | hiddenTextarea?: HTMLTextAreaElement | undefined;
|
4804 | }
|
4805 | export interface IText extends ITextOptions {}
|
4806 | export class IText extends Text {
|
4807 | fromPaste: boolean;
|
4808 | /**
|
4809 | * @private
|
4810 | */
|
4811 | _currentCursorOpacity: number;
|
4812 | /**
|
4813 | * @private
|
4814 | */
|
4815 | _reSpace: RegExp;
|
4816 | /**
|
4817 | * Constructor
|
4818 | * @param text Text string
|
4819 | * @param [options] Options object
|
4820 | */
|
4821 | constructor(text: string, options?: ITextOptions);
|
4822 | /**
|
4823 | * Sets selection start (left boundary of a selection)
|
4824 | * @param {Number} index Index to set selection start to
|
4825 | */
|
4826 | setSelectionStart(index: number): void;
|
4827 | /**
|
4828 | * Sets selection end (right boundary of a selection)
|
4829 | * @param {Number} index Index to set selection end to
|
4830 | */
|
4831 | setSelectionEnd(index: number): void;
|
4832 | /**
|
4833 | * Prepare and clean the contextTop
|
4834 | */
|
4835 | clearContextTop(skipRestore?: boolean): void;
|
4836 | /**
|
4837 | * Renders cursor or selection (depending on what exists)
|
4838 | */
|
4839 | renderCursorOrSelection(): void;
|
4840 | /**
|
4841 | * Renders cursor
|
4842 | * @param {Object} boundaries
|
4843 | * @param {CanvasRenderingContext2D} ctx transformed context to draw on
|
4844 | */
|
4845 | renderCursor(boundaries: any, ctx: CanvasRenderingContext2D): void;
|
4846 | /**
|
4847 | * Renders text selection
|
4848 | * @param {Object} boundaries Object with left/top/leftOffset/topOffset
|
4849 | * @param {CanvasRenderingContext2D} ctx transformed context to draw on
|
4850 | */
|
4851 | renderSelection(boundaries: any, ctx: CanvasRenderingContext2D): void;
|
4852 | /**
|
4853 | * High level function to know the height of the cursor.
|
4854 | * the currentChar is the one that precedes the cursor
|
4855 | * Returns fontSize of char at the current cursor
|
4856 | * @return {Number} Character font size
|
4857 | */
|
4858 | getCurrentCharFontSize(): number;
|
4859 | /**
|
4860 | * High level function to know the color of the cursor.
|
4861 | * the currentChar is the one that precedes the cursor
|
4862 | * Returns color (fill) of char at the current cursor
|
4863 | * @return {String} Character color (fill)
|
4864 | */
|
4865 | getCurrentCharColor(): string;
|
4866 | /**
|
4867 | * Returns fabric.IText instance from an object representation
|
4868 | * @static
|
4869 | * @memberOf fabric.IText
|
4870 | * @param {Object} object Object to create an instance from
|
4871 | * @param {function} [callback] invoked with new instance as argument
|
4872 | */
|
4873 | static fromObject(object: any, callback?: Function): IText;
|
4874 | /**
|
4875 | * Initializes all the interactive behavior of IText
|
4876 | */
|
4877 | initBehavior(): void;
|
4878 | /**
|
4879 | * Initializes "added" event handler
|
4880 | */
|
4881 | initAddedHandler(): void;
|
4882 | /**
|
4883 | * Initializes delayed cursor
|
4884 | */
|
4885 | initDelayedCursor(): void;
|
4886 | /**
|
4887 | * Aborts cursor animation and clears all timeouts
|
4888 | */
|
4889 | abortCursorAnimation(): void;
|
4890 | /**
|
4891 | * Selects entire text
|
4892 | * @return {fabric.IText} thisArg
|
4893 | * @chainable
|
4894 | */
|
4895 | selectAll(): IText;
|
4896 | /**
|
4897 | * Returns selected text
|
4898 | * @return {String}
|
4899 | */
|
4900 | getSelectedText(): string;
|
4901 | /**
|
4902 | * Find new selection index representing start of current word according to current selection index
|
4903 | * @param {Number} startFrom Surrent selection index
|
4904 | * @return {Number} New selection index
|
4905 | */
|
4906 | findWordBoundaryLeft(startFrom: number): number;
|
4907 | /**
|
4908 | * Find new selection index representing end of current word according to current selection index
|
4909 | * @param {Number} startFrom Current selection index
|
4910 | * @return {Number} New selection index
|
4911 | */
|
4912 | findWordBoundaryRight(startFrom: number): number;
|
4913 | /**
|
4914 | * Find new selection index representing start of current line according to current selection index
|
4915 | * @param {Number} startFrom Current selection index
|
4916 | * @return {Number} New selection index
|
4917 | */
|
4918 | findLineBoundaryLeft(startFrom: number): number;
|
4919 | /**
|
4920 | * Find new selection index representing end of current line according to current selection index
|
4921 | * @param {Number} startFrom Current selection index
|
4922 | * @return {Number} New selection index
|
4923 | */
|
4924 | findLineBoundaryRight(startFrom: number): number;
|
4925 | /**
|
4926 | * Finds index corresponding to beginning or end of a word
|
4927 | * @param {Number} selectionStart Index of a character
|
4928 | * @param {Number} direction 1 or -1
|
4929 | * @return {Number} Index of the beginning or end of a word
|
4930 | */
|
4931 | searchWordBoundary(selectionStart: number, direction: number): number;
|
4932 | /**
|
4933 | * Selects a word based on the index
|
4934 | * @param {Number} selectionStart Index of a character
|
4935 | */
|
4936 | selectWord(selectionStart: number): void;
|
4937 | /**
|
4938 | * Selects a line based on the index
|
4939 | * @param {Number} selectionStart Index of a character
|
4940 | * @return {fabric.IText} thisArg
|
4941 | * @chainable
|
4942 | */
|
4943 | selectLine(selectionStart: number): IText;
|
4944 | /**
|
4945 | * Enters editing state
|
4946 | * @return {fabric.IText} thisArg
|
4947 | * @chainable
|
4948 | */
|
4949 | enterEditing(e?: MouseEvent): IText;
|
4950 | /**
|
4951 | * Initializes "mousemove" event handler
|
4952 | */
|
4953 | initMouseMoveHandler(): void;
|
4954 | /**
|
4955 | * Exits from editing state
|
4956 | * @return {fabric.IText} thisArg
|
4957 | * @chainable
|
4958 | */
|
4959 | exitEditing(): IText;
|
4960 | /**
|
4961 | * remove and reflow a style block from start to end.
|
4962 | * @param {Number} start linear start position for removal (included in removal)
|
4963 | * @param {Number} end linear end position for removal ( excluded from removal )
|
4964 | */
|
4965 | removeStyleFromTo(start: number, end: number): void;
|
4966 | /**
|
4967 | * Shifts line styles up or down
|
4968 | * @param {Number} lineIndex Index of a line
|
4969 | * @param {Number} offset Can any number?
|
4970 | */
|
4971 | shiftLineStyles(lineIndex: number, offset: number): void;
|
4972 | /**
|
4973 | * Inserts new style object
|
4974 | * @param {Number} lineIndex Index of a line
|
4975 | * @param {Number} charIndex Index of a char
|
4976 | * @param {Number} qty number of lines to add
|
4977 | * @param {Array} copiedStyle Array of objects styles
|
4978 | */
|
4979 | insertNewlineStyleObject(lineIndex: number, charIndex: number, qty: number, copiedStyle: any[]): void;
|
4980 | /**
|
4981 | * Inserts style object for a given line/char index
|
4982 | * @param {Number} lineIndex Index of a line
|
4983 | * @param {Number} charIndex Index of a char
|
4984 | * @param {Number} quantity number Style object to insert, if given
|
4985 | * @param {Array} copiedStyle array of style objecs
|
4986 | */
|
4987 | insertCharStyleObject(lineIndex: number, charIndex: number, quantity: number, copiedStyle: any[]): void;
|
4988 | /**
|
4989 | * Inserts style object(s)
|
4990 | * @param {Array} insertedText Characters at the location where style is inserted
|
4991 | * @param {Number} start cursor index for inserting style
|
4992 | * @param {Array} [copiedStyle] array of style objects to insert.
|
4993 | */
|
4994 | insertNewStyleBlock(insertedText: any[], start: number, copiedStyle?: any[]): void;
|
4995 | /**
|
4996 | * Set the selectionStart and selectionEnd according to the ne postion of cursor
|
4997 | * mimic the key - mouse navigation when shift is pressed.
|
4998 | */
|
4999 | setSelectionStartEndWithShift(start: number, end: number, newSelection: number): void;
|
5000 | /**
|
5001 | * Copies selected text
|
5002 | */
|
5003 | copy(): void;
|
5004 | /**
|
5005 | * convert from fabric to textarea values
|
5006 | */
|
5007 | fromGraphemeToStringSelection(
|
5008 | start: number,
|
5009 | end: number,
|
5010 | _text: string,
|
5011 | ): { selectionStart: number; selectionEnd: number };
|
5012 | /**
|
5013 | * convert from textarea to grapheme indexes
|
5014 | */
|
5015 | fromStringToGraphemeSelection(
|
5016 | start: number,
|
5017 | end: number,
|
5018 | text: string,
|
5019 | ): { selectionStart: number; selectionEnd: number };
|
5020 | /**
|
5021 | * Gets start offset of a selection
|
5022 | * @param {Event} e Event object
|
5023 | * @param {Boolean} isRight
|
5024 | * @return {Number}
|
5025 | */
|
5026 | getDownCursorOffset(e: Event, isRight?: boolean): number;
|
5027 | /**
|
5028 | * Returns index of a character corresponding to where an object was clicked
|
5029 | * @param {Event} e Event object
|
5030 | * @return {Number} Index of a character
|
5031 | */
|
5032 | getSelectionStartFromPointer(e: Event): number;
|
5033 | /**
|
5034 | * @param {Event} e Event object
|
5035 | * @param {Boolean} isRight
|
5036 | * @return {Number}
|
5037 | */
|
5038 | getUpCursorOffset(e: Event, isRight?: boolean): number;
|
5039 | /**
|
5040 | * Initializes double and triple click event handlers
|
5041 | */
|
5042 | initClicks(): void;
|
5043 | /**
|
5044 | * Initializes event handlers related to cursor or selection
|
5045 | */
|
5046 | initCursorSelectionHandlers(): void;
|
5047 | /**
|
5048 | * Initializes "dbclick" event handler
|
5049 | */
|
5050 | initDoubleClickSimulation(): void;
|
5051 | /**
|
5052 | * Initializes hidden textarea (needed to bring up keyboard in iOS)
|
5053 | */
|
5054 | initHiddenTextarea(): void;
|
5055 | /**
|
5056 | * Initializes "mousedown" event handler
|
5057 | */
|
5058 | initMousedownHandler(): void;
|
5059 | /**
|
5060 | * Initializes "mouseup" event handler
|
5061 | */
|
5062 | initMouseupHandler(): void;
|
5063 | /**
|
5064 | * insert characters at start position, before start position.
|
5065 | * start equal 1 it means the text get inserted between actual grapheme 0 and 1
|
5066 | * if style array is provided, it must be as the same length of text in graphemes
|
5067 | * if end is provided and is bigger than start, old text is replaced.
|
5068 | * start/end ar per grapheme position in _text array.
|
5069 | *
|
5070 | * @param {String} text text to insert
|
5071 | * @param {Array} style array of style objects
|
5072 | * @param {Number} start
|
5073 | * @param {Number} end default to start + 1
|
5074 | */
|
5075 | insertChars(text: string, style: any[], start: number, end: number): void;
|
5076 | /**
|
5077 | * Moves cursor down
|
5078 | * @param {Event} e Event object
|
5079 | */
|
5080 | moveCursorDown(e: Event): void;
|
5081 | /**
|
5082 | * Moves cursor left
|
5083 | * @param {Event} e Event object
|
5084 | */
|
5085 | moveCursorLeft(e: Event): void;
|
5086 | /**
|
5087 | * Moves cursor left without keeping selection
|
5088 | * @param {Event} e
|
5089 | */
|
5090 | moveCursorLeftWithoutShift(e: Event): void;
|
5091 | /**
|
5092 | * Moves cursor left while keeping selection
|
5093 | * @param {Event} e
|
5094 | */
|
5095 | moveCursorLeftWithShift(e: Event): void;
|
5096 | /**
|
5097 | * Moves cursor right
|
5098 | * @param {Event} e Event object
|
5099 | */
|
5100 | moveCursorRight(e: Event): void;
|
5101 | /**
|
5102 | * Moves cursor right without keeping selection
|
5103 | * @param {Event} e Event object
|
5104 | */
|
5105 | moveCursorRightWithoutShift(e: Event): void;
|
5106 | /**
|
5107 | * Moves cursor right while keeping selection
|
5108 | * @param {Event} e
|
5109 | */
|
5110 | moveCursorRightWithShift(e: Event): void;
|
5111 | /**
|
5112 | * Moves cursor up
|
5113 | * @param {Event} e Event object
|
5114 | */
|
5115 | moveCursorUp(e: Event): void;
|
5116 | /**
|
5117 | * Moves cursor up without shift
|
5118 | * @param {Number} offset
|
5119 | */
|
5120 | moveCursorWithoutShift(offset: number): void;
|
5121 | /**
|
5122 | * Moves cursor with shift
|
5123 | * @param {Number} offset
|
5124 | */
|
5125 | moveCursorWithShift(offset: number): void;
|
5126 | /**
|
5127 | * Composition end
|
5128 | */
|
5129 | onCompositionEnd(): void;
|
5130 | /**
|
5131 | * Composition start
|
5132 | */
|
5133 | onCompositionStart(): void;
|
5134 | /**
|
5135 | * Handles onInput event
|
5136 | * @param {Event} e Event object
|
5137 | */
|
5138 | onInput(e: Event): void;
|
5139 | /**
|
5140 | * Handles keyup event
|
5141 | * @param {Event} e Event object
|
5142 | */
|
5143 | onKeyDown(e: Event): void;
|
5144 | /**
|
5145 | * Handles keyup event
|
5146 | * We handle KeyUp because ie11 and edge have difficulties copy/pasting
|
5147 | * if a copy/cut event fired, keyup is dismissed
|
5148 | * @param {Event} e Event object
|
5149 | */
|
5150 | onKeyUp(e: Event): void;
|
5151 | /**
|
5152 | * Pastes text
|
5153 | */
|
5154 | paste(): void;
|
5155 | /**
|
5156 | * Removes characters from start/end
|
5157 | * start/end ar per grapheme position in _text array.
|
5158 | *
|
5159 | * @param {Number} start
|
5160 | * @param {Number} end default to start + 1
|
5161 | */
|
5162 | removeChars(start: number, end: number): void;
|
5163 | /**
|
5164 | * Changes cursor location in a text depending on passed pointer (x/y) object
|
5165 | * @param {Event} e Event object
|
5166 | */
|
5167 | setCursorByClick(e: Event): void;
|
5168 | /**
|
5169 | * @private
|
5170 | */
|
5171 | _getNewSelectionStartFromOffset(
|
5172 | mouseOffset: { x: number; y: number },
|
5173 | prevWidth: number,
|
5174 | width: number,
|
5175 | index: number,
|
5176 | jlen: number,
|
5177 | ): number;
|
5178 | /**
|
5179 | * @private
|
5180 | * @param {CanvasRenderingContext2D} ctx Context to render on
|
5181 | */
|
5182 | _render(ctx: CanvasRenderingContext2D): void;
|
5183 | /**
|
5184 | * @private
|
5185 | */
|
5186 | _updateTextarea(): void;
|
5187 | /**
|
5188 | * @private
|
5189 | */
|
5190 | updateFromTextArea(): void;
|
5191 | /**
|
5192 | * Default event handler for the basic functionalities needed on _mouseDown
|
5193 | * can be overridden to do something different.
|
5194 | * Scope of this implementation is: find the click position, set selectionStart
|
5195 | * find selectionEnd, initialize the drawing of either cursor or selection area
|
5196 | * @private
|
5197 | * @param {Object} Options (seems to have an event `e` parameter
|
5198 | */
|
5199 | _mouseDownHandler(options: any): void;
|
5200 | |
5201 |
|
5202 |
|
5203 |
|
5204 | _calcTextareaPosition(): { left: string; top: string; fontSize: string; charHeight: number };
|
5205 | }
|
5206 | interface ITextboxOptions extends ITextOptions {
|
5207 | |
5208 |
|
5209 |
|
5210 |
|
5211 | minWidth?: number | undefined;
|
5212 | |
5213 |
|
5214 |
|
5215 |
|
5216 |
|
5217 |
|
5218 | dynamicMinWidth?: number | undefined;
|
5219 | |
5220 |
|
5221 |
|
5222 | lockScalingFlip?: boolean | undefined;
|
5223 | |
5224 |
|
5225 |
|
5226 |
|
5227 | noScaleCache?: boolean | undefined;
|
5228 | |
5229 |
|
5230 |
|
5231 |
|
5232 |
|
5233 |
|
5234 | splitByGrapheme?: boolean | undefined;
|
5235 | |
5236 |
|
5237 |
|
5238 |
|
5239 | isWrapping?: boolean | undefined;
|
5240 | }
|
5241 | export interface Textbox extends ITextboxOptions {}
|
5242 | export class Textbox extends IText {
|
5243 | |
5244 |
|
5245 |
|
5246 |
|
5247 |
|
5248 | constructor(text: string, options?: ITextboxOptions);
|
5249 | |
5250 |
|
5251 |
|
5252 |
|
5253 |
|
5254 | styleHas(property: string, lineIndex: number): boolean;
|
5255 | |
5256 |
|
5257 |
|
5258 |
|
5259 |
|
5260 | isEmptyStyles(lineIndex: number): boolean;
|
5261 | |
5262 |
|
5263 |
|
5264 |
|
5265 |
|
5266 |
|
5267 | isEndOfWrapping(lineIndex: number): boolean;
|
5268 | |
5269 |
|
5270 |
|
5271 |
|
5272 | getMinWidth(): number;
|
5273 | |
5274 |
|
5275 |
|
5276 |
|
5277 |
|
5278 | _wordJoiners: RegExp;
|
5279 | |
5280 |
|
5281 |
|
5282 |
|
5283 |
|
5284 |
|
5285 |
|
5286 |
|
5287 |
|
5288 | _measureWord(word: string[], lineIndex: number, charOffset: number): number;
|
5289 | |
5290 |
|
5291 |
|
5292 |
|
5293 |
|
5294 |
|
5295 |
|
5296 |
|
5297 |
|
5298 | _wrapText(lines: string[], desiredWidth: number): string[][];
|
5299 | |
5300 |
|
5301 |
|
5302 |
|
5303 |
|
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 | _styleMap?: { [s: number]: { line: number; offset: number } } | undefined;
|
5309 | |
5310 |
|
5311 |
|
5312 |
|
5313 |
|
5314 |
|
5315 |
|
5316 | static fromObject(object: any, callback?: Function): Textbox;
|
5317 | }
|
5318 | interface ITriangleOptions extends IObjectOptions {}
|
5319 | export class Triangle extends Object {
|
5320 | |
5321 |
|
5322 |
|
5323 |
|
5324 | constructor(options?: ITriangleOptions);
|
5325 | |
5326 |
|
5327 |
|
5328 |
|
5329 |
|
5330 | toSVG(reviver?: Function): string;
|
5331 | |
5332 |
|
5333 |
|
5334 |
|
5335 | static fromObject(object: any): Triangle;
|
5336 | }
|
5337 |
|
5338 |
|
5339 |
|
5340 |
|
5341 | interface IAllFilters {
|
5342 | BaseFilter: {
|
5343 | |
5344 |
|
5345 |
|
5346 |
|
5347 | new (options?: any): IBaseFilter;
|
5348 | };
|
5349 | BlendColor: {
|
5350 | |
5351 |
|
5352 |
|
5353 |
|
5354 | new (options?: { color?: string | undefined; mode?: string | undefined; alpha?: number | undefined }): IBlendColorFilter;
|
5355 | |
5356 |
|
5357 |
|
5358 |
|
5359 | fromObject(object: any): IBlendColorFilter;
|
5360 | };
|
5361 | BlendImage: {
|
5362 | |
5363 |
|
5364 |
|
5365 |
|
5366 | new (options?: { image?: Image | undefined; mode?: string | undefined; alpha?: number | undefined }): IBlendImageFilter;
|
5367 | |
5368 |
|
5369 |
|
5370 |
|
5371 | fromObject(object: any): IBlendImageFilter;
|
5372 | };
|
5373 | Brightness: {
|
5374 | new (options?: {
|
5375 | |
5376 |
|
5377 |
|
5378 |
|
5379 | brightness: number;
|
5380 | }): IBrightnessFilter;
|
5381 | |
5382 |
|
5383 |
|
5384 |
|
5385 | fromObject(object: any): IBrightnessFilter;
|
5386 | };
|
5387 | ColorMatrix: {
|
5388 | new (options?: {
|
5389 |
|
5390 | matrix?: number[] | undefined;
|
5391 | }): IColorMatrix;
|
5392 | |
5393 |
|
5394 |
|
5395 |
|
5396 | fromObject(object: any): IColorMatrix;
|
5397 | };
|
5398 | Contrast: {
|
5399 | |
5400 |
|
5401 |
|
5402 |
|
5403 | new (options?: { contrast?: number | undefined }): IContrastFilter;
|
5404 | |
5405 |
|
5406 |
|
5407 |
|
5408 | fromObject(object: any): IContrastFilter;
|
5409 | };
|
5410 | Convolute: {
|
5411 | new (options?: {
|
5412 | opaque?: boolean | undefined;
|
5413 |
|
5414 | matrix?: number[] | undefined;
|
5415 | }): IConvoluteFilter;
|
5416 | |
5417 |
|
5418 |
|
5419 |
|
5420 | fromObject(object: any): IConvoluteFilter;
|
5421 | };
|
5422 | GradientTransparency: {
|
5423 | new (options?: {
|
5424 |
|
5425 | threshold?: number | undefined;
|
5426 | }): IGradientTransparencyFilter;
|
5427 | |
5428 |
|
5429 |
|
5430 |
|
5431 | fromObject(object: any): IGradientTransparencyFilter;
|
5432 | };
|
5433 | Grayscale: {
|
5434 | new (options?: any): IGrayscaleFilter;
|
5435 | |
5436 |
|
5437 |
|
5438 |
|
5439 | fromObject(object: any): IGrayscaleFilter;
|
5440 | };
|
5441 | Invert: {
|
5442 | |
5443 |
|
5444 |
|
5445 |
|
5446 | new (options?: any): IInvertFilter;
|
5447 | |
5448 |
|
5449 |
|
5450 |
|
5451 | fromObject(object: any): IInvertFilter;
|
5452 | };
|
5453 | Mask: {
|
5454 | new (options?: {
|
5455 |
|
5456 | mask?: Image | undefined;
|
5457 | |
5458 |
|
5459 |
|
5460 |
|
5461 | channel: number;
|
5462 | }): IMaskFilter;
|
5463 | |
5464 |
|
5465 |
|
5466 |
|
5467 | fromObject(object: any): IMaskFilter;
|
5468 | };
|
5469 | Multiply: {
|
5470 | new (options?: {
|
5471 | |
5472 |
|
5473 |
|
5474 |
|
5475 | color: string;
|
5476 | }): IMultiplyFilter;
|
5477 | |
5478 |
|
5479 |
|
5480 |
|
5481 | fromObject(object: any): IMultiplyFilter;
|
5482 | };
|
5483 | Noise: {
|
5484 | new (options?: {
|
5485 |
|
5486 | noise: number;
|
5487 | }): INoiseFilter;
|
5488 | |
5489 |
|
5490 |
|
5491 |
|
5492 | fromObject(object: any): INoiseFilter;
|
5493 | };
|
5494 | Pixelate: {
|
5495 | new (options?: {
|
5496 | |
5497 |
|
5498 |
|
5499 |
|
5500 | blocksize?: number | undefined;
|
5501 | }): IPixelateFilter;
|
5502 | |
5503 |
|
5504 |
|
5505 |
|
5506 | fromObject(object: any): IPixelateFilter;
|
5507 | };
|
5508 | RemoveWhite: {
|
5509 | new (options?: {
|
5510 |
|
5511 | threshold?: number | undefined;
|
5512 |
|
5513 | distance?: number | undefined;
|
5514 | }): IRemoveWhiteFilter;
|
5515 | |
5516 |
|
5517 |
|
5518 |
|
5519 | fromObject(object: any): IRemoveWhiteFilter;
|
5520 | };
|
5521 | Resize: {
|
5522 | new (options?: any): IResizeFilter;
|
5523 | |
5524 |
|
5525 |
|
5526 |
|
5527 | fromObject(object: any): IResizeFilter;
|
5528 | };
|
5529 | Saturation: {
|
5530 | |
5531 |
|
5532 |
|
5533 |
|
5534 | new (options?: { saturation?: number | undefined }): ISaturationFilter;
|
5535 | |
5536 |
|
5537 |
|
5538 |
|
5539 | fromObject(object: any): ISaturationFilter;
|
5540 | };
|
5541 | Sepia2: {
|
5542 | new (options?: any): ISepia2Filter;
|
5543 | |
5544 |
|
5545 |
|
5546 |
|
5547 | fromObject(object: any): ISepia2Filter;
|
5548 | };
|
5549 | Sepia: {
|
5550 | new (options?: any): ISepiaFilter;
|
5551 | |
5552 |
|
5553 |
|
5554 |
|
5555 | fromObject(object: any): ISepiaFilter;
|
5556 | };
|
5557 | Tint: {
|
5558 | new (options?: {
|
5559 | |
5560 |
|
5561 |
|
5562 |
|
5563 | color?: string | undefined;
|
5564 |
|
5565 | opacity?: number | undefined;
|
5566 | }): ITintFilter;
|
5567 | |
5568 |
|
5569 |
|
5570 |
|
5571 | fromObject(object: any): ITintFilter;
|
5572 | };
|
5573 | }
|
5574 | interface IBaseFilter {
|
5575 | |
5576 |
|
5577 |
|
5578 |
|
5579 | setOptions(options?: any): void;
|
5580 | |
5581 |
|
5582 |
|
5583 | toObject(): any;
|
5584 | |
5585 |
|
5586 |
|
5587 | toJSON(): string;
|
5588 | |
5589 |
|
5590 |
|
5591 |
|
5592 |
|
5593 |
|
5594 | applyTo2d(options: any): void;
|
5595 | }
|
5596 | interface IBlendColorFilter extends IBaseFilter {
|
5597 | color?: string | undefined;
|
5598 | mode?: string | undefined;
|
5599 | alpha?: number | undefined;
|
5600 | |
5601 |
|
5602 |
|
5603 |
|
5604 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5605 | }
|
5606 | interface IBlendImageFilter extends IBaseFilter {
|
5607 | |
5608 |
|
5609 |
|
5610 |
|
5611 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5612 | }
|
5613 | interface IBrightnessFilter extends IBaseFilter {
|
5614 | |
5615 |
|
5616 |
|
5617 |
|
5618 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5619 | }
|
5620 | interface IColorMatrix extends IBaseFilter {
|
5621 | matrix?: number[] | undefined;
|
5622 | |
5623 |
|
5624 |
|
5625 |
|
5626 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5627 | }
|
5628 | interface IContrastFilter extends IBaseFilter {
|
5629 | |
5630 |
|
5631 |
|
5632 |
|
5633 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5634 | }
|
5635 | interface IConvoluteFilter extends IBaseFilter {
|
5636 | |
5637 |
|
5638 |
|
5639 |
|
5640 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5641 | }
|
5642 | interface IGradientTransparencyFilter extends IBaseFilter {
|
5643 | |
5644 |
|
5645 |
|
5646 |
|
5647 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5648 | }
|
5649 | interface IGrayscaleFilter extends IBaseFilter {
|
5650 | |
5651 |
|
5652 |
|
5653 |
|
5654 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5655 | }
|
5656 | interface IInvertFilter extends IBaseFilter {
|
5657 | |
5658 |
|
5659 |
|
5660 |
|
5661 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5662 | }
|
5663 | interface IMaskFilter extends IBaseFilter {
|
5664 | |
5665 |
|
5666 |
|
5667 |
|
5668 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5669 | }
|
5670 | interface IMultiplyFilter extends IBaseFilter {
|
5671 | |
5672 |
|
5673 |
|
5674 |
|
5675 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5676 | }
|
5677 | interface INoiseFilter extends IBaseFilter {
|
5678 | |
5679 |
|
5680 |
|
5681 |
|
5682 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5683 | }
|
5684 | interface IPixelateFilter extends IBaseFilter {
|
5685 | |
5686 |
|
5687 |
|
5688 |
|
5689 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5690 | }
|
5691 | interface IRemoveWhiteFilter extends IBaseFilter {
|
5692 | |
5693 |
|
5694 |
|
5695 |
|
5696 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5697 | }
|
5698 | interface IResizeFilter extends IBaseFilter {
|
5699 | |
5700 |
|
5701 |
|
5702 | resizeType: string;
|
5703 |
|
5704 | |
5705 |
|
5706 |
|
5707 | scaleX: number;
|
5708 |
|
5709 | |
5710 |
|
5711 |
|
5712 | scaleY: number;
|
5713 |
|
5714 | |
5715 |
|
5716 |
|
5717 | lanczosLobes: number;
|
5718 | |
5719 |
|
5720 |
|
5721 |
|
5722 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5723 | }
|
5724 | interface ISaturationFilter extends IBaseFilter {
|
5725 | |
5726 |
|
5727 |
|
5728 |
|
5729 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5730 | }
|
5731 | interface ISepiaFilter extends IBaseFilter {
|
5732 | |
5733 |
|
5734 |
|
5735 |
|
5736 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5737 | }
|
5738 | interface ISepia2Filter extends IBaseFilter {
|
5739 | |
5740 |
|
5741 |
|
5742 |
|
5743 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5744 | }
|
5745 | interface ITintFilter extends IBaseFilter {
|
5746 | |
5747 |
|
5748 |
|
5749 |
|
5750 | applyTo(canvasEl: HTMLCanvasElement): void;
|
5751 | }
|
5752 |
|
5753 |
|
5754 |
|
5755 |
|
5756 | export class BaseBrush {
|
5757 | |
5758 |
|
5759 |
|
5760 | color: string;
|
5761 |
|
5762 | |
5763 |
|
5764 |
|
5765 | width: number;
|
5766 |
|
5767 | |
5768 |
|
5769 |
|
5770 |
|
5771 |
|
5772 | shadow: Shadow | string;
|
5773 | |
5774 |
|
5775 |
|
5776 | strokeLineCap: string;
|
5777 |
|
5778 | |
5779 |
|
5780 |
|
5781 | strokeLineJoin: string;
|
5782 |
|
5783 | |
5784 |
|
5785 |
|
5786 | strokeDashArray: any[];
|
5787 | }
|
5788 |
|
5789 | export class CircleBrush extends BaseBrush {
|
5790 | |
5791 |
|
5792 |
|
5793 | width: number;
|
5794 | |
5795 |
|
5796 |
|
5797 | drawDot(pointer: any): void;
|
5798 |
|
5799 | |
5800 |
|
5801 |
|
5802 | addPoint(pointer: any): Point;
|
5803 | }
|
5804 |
|
5805 | export class SprayBrush extends BaseBrush {
|
5806 | |
5807 |
|
5808 |
|
5809 | width: number;
|
5810 | |
5811 |
|
5812 |
|
5813 | density: number;
|
5814 |
|
5815 | |
5816 |
|
5817 |
|
5818 | dotWidth: number;
|
5819 | |
5820 |
|
5821 |
|
5822 | dotWidthVariance: number;
|
5823 |
|
5824 | |
5825 |
|
5826 |
|
5827 | randomOpacity: boolean;
|
5828 | |
5829 |
|
5830 |
|
5831 | optimizeOverlapping: boolean;
|
5832 |
|
5833 | addSprayChunk(pointer: any): void;
|
5834 | }
|
5835 | export class PatternBrush extends PencilBrush {
|
5836 | getPatternSrc(): HTMLCanvasElement;
|
5837 |
|
5838 | getPatternSrcFunction(): string;
|
5839 |
|
5840 | |
5841 |
|
5842 |
|
5843 | getPattern(): any;
|
5844 | |
5845 |
|
5846 |
|
5847 | createPath(pathData: string): Path;
|
5848 | }
|
5849 | export class PencilBrush extends BaseBrush {
|
5850 | |
5851 |
|
5852 |
|
5853 |
|
5854 | convertPointsToSVGPath(points: Array<{ x: number; y: number }>, minX?: number, minY?: number): string[];
|
5855 |
|
5856 | |
5857 |
|
5858 |
|
5859 |
|
5860 | createPath(pathData: string): Path;
|
5861 | }
|
5862 |
|
5863 |
|
5864 |
|
5865 |
|
5866 | interface IUtilAnimationOptions {
|
5867 | |
5868 |
|
5869 |
|
5870 | startValue?: number | undefined;
|
5871 | |
5872 |
|
5873 |
|
5874 | endValue?: number | undefined;
|
5875 | |
5876 |
|
5877 |
|
5878 | byValue?: number | undefined;
|
5879 | |
5880 |
|
5881 |
|
5882 | duration?: number | undefined;
|
5883 | |
5884 |
|
5885 |
|
5886 | onChange?: ((value: number) => void) | undefined;
|
5887 | |
5888 |
|
5889 |
|
5890 | onComplete?: Function | undefined;
|
5891 | |
5892 |
|
5893 |
|
5894 | easing?: Function | undefined;
|
5895 | }
|
5896 | interface IUtilAnimation {
|
5897 | |
5898 |
|
5899 |
|
5900 |
|
5901 | animate(options?: IUtilAnimationOptions): void;
|
5902 | |
5903 |
|
5904 |
|
5905 |
|
5906 |
|
5907 | requestAnimFrame(callback: Function): void;
|
5908 | }
|
5909 |
|
5910 | type IUtilAminEaseFunction = (t: number, b: number, c: number, d: number) => number;
|
5911 |
|
5912 | interface IUtilAnimEase {
|
5913 | easeInBack: IUtilAminEaseFunction;
|
5914 | easeInBounce: IUtilAminEaseFunction;
|
5915 | easeInCirc: IUtilAminEaseFunction;
|
5916 | easeInCubic: IUtilAminEaseFunction;
|
5917 | easeInElastic: IUtilAminEaseFunction;
|
5918 | easeInExpo: IUtilAminEaseFunction;
|
5919 | easeInOutBack: IUtilAminEaseFunction;
|
5920 | easeInOutBounce: IUtilAminEaseFunction;
|
5921 | easeInOutCirc: IUtilAminEaseFunction;
|
5922 | easeInOutCubic: IUtilAminEaseFunction;
|
5923 | easeInOutElastic: IUtilAminEaseFunction;
|
5924 | easeInOutExpo: IUtilAminEaseFunction;
|
5925 | easeInOutQuad: IUtilAminEaseFunction;
|
5926 | easeInOutQuart: IUtilAminEaseFunction;
|
5927 | easeInOutQuint: IUtilAminEaseFunction;
|
5928 | easeInOutSine: IUtilAminEaseFunction;
|
5929 | easeInQuad: IUtilAminEaseFunction;
|
5930 | easeInQuart: IUtilAminEaseFunction;
|
5931 | easeInQuint: IUtilAminEaseFunction;
|
5932 | easeInSine: IUtilAminEaseFunction;
|
5933 | easeOutBack: IUtilAminEaseFunction;
|
5934 | easeOutBounce: IUtilAminEaseFunction;
|
5935 | easeOutCirc: IUtilAminEaseFunction;
|
5936 | easeOutCubic: IUtilAminEaseFunction;
|
5937 | easeOutElastic: IUtilAminEaseFunction;
|
5938 | easeOutExpo: IUtilAminEaseFunction;
|
5939 | easeOutQuad: IUtilAminEaseFunction;
|
5940 | easeOutQuart: IUtilAminEaseFunction;
|
5941 | easeOutQuint: IUtilAminEaseFunction;
|
5942 | easeOutSine: IUtilAminEaseFunction;
|
5943 | }
|
5944 |
|
5945 | interface IUtilImage {
|
5946 | setImageSmoothing(ctx: CanvasRenderingContext2D, value: any): void;
|
5947 | }
|
5948 |
|
5949 | interface IUtilArc {
|
5950 | |
5951 |
|
5952 |
|
5953 | drawArc(ctx: CanvasRenderingContext2D, fx: number, fy: number, coords: number[]): void;
|
5954 | |
5955 |
|
5956 |
|
5957 |
|
5958 |
|
5959 |
|
5960 |
|
5961 |
|
5962 |
|
5963 |
|
5964 | getBoundsOfArc(
|
5965 | fx: number,
|
5966 | fy: number,
|
5967 | rx: number,
|
5968 | ry: number,
|
5969 | rot: number,
|
5970 | large: number,
|
5971 | sweep: number,
|
5972 | tx: number,
|
5973 | ty: number,
|
5974 | ): Point[];
|
5975 | |
5976 |
|
5977 |
|
5978 |
|
5979 |
|
5980 |
|
5981 |
|
5982 | getBoundsOfCurve(
|
5983 | x0: number,
|
5984 | y0: number,
|
5985 | x1: number,
|
5986 | y1: number,
|
5987 | x2: number,
|
5988 | y2: number,
|
5989 | x3: number,
|
5990 | y3: number,
|
5991 | ): Point[];
|
5992 | }
|
5993 |
|
5994 | interface IUtilDomEvent {
|
5995 | |
5996 |
|
5997 |
|
5998 |
|
5999 |
|
6000 | getPointer(event: Event, upperCanvasEl: HTMLCanvasElement): Point;
|
6001 |
|
6002 | |
6003 |
|
6004 |
|
6005 | addListener(element: HTMLElement, eventName: string, handler: Function): void;
|
6006 |
|
6007 | |
6008 |
|
6009 |
|
6010 | removeListener(element: HTMLElement, eventName: string, handler: Function): void;
|
6011 | }
|
6012 |
|
6013 | interface IUtilDomMisc {
|
6014 | |
6015 |
|
6016 |
|
6017 | getById(id: string | HTMLElement): HTMLElement;
|
6018 | |
6019 |
|
6020 |
|
6021 | toArray(arrayLike: any): any[];
|
6022 | |
6023 |
|
6024 |
|
6025 |
|
6026 |
|
6027 |
|
6028 | makeElement(tagName: string, attributes?: any): HTMLElement;
|
6029 | |
6030 |
|
6031 |
|
6032 |
|
6033 |
|
6034 | addClass(element: HTMLElement, classname: string): void;
|
6035 | |
6036 |
|
6037 |
|
6038 |
|
6039 |
|
6040 |
|
6041 | wrapElement(element: HTMLElement, wrapper: HTMLElement | string, attributes?: any): HTMLElement;
|
6042 | |
6043 |
|
6044 |
|
6045 |
|
6046 | getScrollLeftTop(element: HTMLElement): { left: number; top: number };
|
6047 | |
6048 |
|
6049 |
|
6050 |
|
6051 | getElementOffset(element: HTMLElement): { left: number; top: number };
|
6052 | |
6053 |
|
6054 |
|
6055 |
|
6056 |
|
6057 | getElementStyle(elment: HTMLElement, attr: string): string;
|
6058 | |
6059 |
|
6060 |
|
6061 |
|
6062 |
|
6063 | getScript(url: string, callback: Function): void;
|
6064 | |
6065 |
|
6066 |
|
6067 |
|
6068 | makeElementUnselectable(element: HTMLElement): HTMLElement;
|
6069 | |
6070 |
|
6071 |
|
6072 |
|
6073 | makeElementSelectable(element: HTMLElement): HTMLElement;
|
6074 | }
|
6075 |
|
6076 | interface IUtilDomRequest {
|
6077 | |
6078 |
|
6079 |
|
6080 |
|
6081 | request(
|
6082 | url: string,
|
6083 | options?: {
|
6084 |
|
6085 | method?: string | undefined;
|
6086 |
|
6087 | onComplete: Function;
|
6088 | },
|
6089 | ): XMLHttpRequest;
|
6090 | }
|
6091 |
|
6092 | interface IUtilDomStyle {
|
6093 | |
6094 |
|
6095 |
|
6096 | setStyle(element: HTMLElement, styles: any): HTMLElement;
|
6097 | }
|
6098 |
|
6099 | interface IUtilArray {
|
6100 | |
6101 |
|
6102 |
|
6103 |
|
6104 |
|
6105 | invoke(array: any[], method: string): any[];
|
6106 | |
6107 |
|
6108 |
|
6109 |
|
6110 | min(array: any[], byProperty: string): any;
|
6111 | |
6112 |
|
6113 |
|
6114 |
|
6115 | max(array: any[], byProperty: string): any;
|
6116 | }
|
6117 |
|
6118 | interface IUtilClass {
|
6119 | |
6120 |
|
6121 |
|
6122 |
|
6123 |
|
6124 |
|
6125 | createClass(parent: Function, properties?: any): any;
|
6126 | |
6127 |
|
6128 |
|
6129 |
|
6130 |
|
6131 | createClass(properties?: any): any;
|
6132 | }
|
6133 |
|
6134 | interface IUtilObject {
|
6135 | |
6136 |
|
6137 |
|
6138 |
|
6139 |
|
6140 | extend(destination: any, source: any): any;
|
6141 |
|
6142 | |
6143 |
|
6144 |
|
6145 |
|
6146 | clone(object: any): any;
|
6147 | }
|
6148 |
|
6149 | interface IUtilString {
|
6150 | |
6151 |
|
6152 |
|
6153 |
|
6154 | camelize(string: string): string;
|
6155 |
|
6156 | |
6157 |
|
6158 |
|
6159 |
|
6160 |
|
6161 |
|
6162 |
|
6163 | capitalize(string: string, firstLetterOnly: boolean): string;
|
6164 |
|
6165 | |
6166 |
|
6167 |
|
6168 |
|
6169 | escapeXml(string: string): string;
|
6170 |
|
6171 | |
6172 |
|
6173 |
|
6174 |
|
6175 |
|
6176 | graphemeSplit(string: string): string[];
|
6177 | }
|
6178 |
|
6179 | interface IUtilMisc {
|
6180 | |
6181 |
|
6182 |
|
6183 |
|
6184 | removeFromArray(array: any[], value: any): any[];
|
6185 |
|
6186 | |
6187 |
|
6188 |
|
6189 |
|
6190 |
|
6191 | getRandomInt(min: number, max: number): number;
|
6192 |
|
6193 | |
6194 |
|
6195 |
|
6196 |
|
6197 | degreesToRadians(degrees: number): number;
|
6198 |
|
6199 | |
6200 |
|
6201 |
|
6202 |
|
6203 | radiansToDegrees(radians: number): number;
|
6204 |
|
6205 | |
6206 |
|
6207 |
|
6208 |
|
6209 |
|
6210 |
|
6211 | rotatePoint(point: Point, origin: Point, radians: number): Point;
|
6212 |
|
6213 | |
6214 |
|
6215 |
|
6216 |
|
6217 |
|
6218 | rotateVector(vector: { x: number; y: number }, radians: number): { x: number; y: number };
|
6219 |
|
6220 | |
6221 |
|
6222 |
|
6223 |
|
6224 |
|
6225 |
|
6226 | transformPoint(p: Point, t: any[], ignoreOffset?: boolean): Point;
|
6227 |
|
6228 | |
6229 |
|
6230 |
|
6231 |
|
6232 | invertTransform(t: any[]): any[];
|
6233 |
|
6234 | |
6235 |
|
6236 |
|
6237 |
|
6238 |
|
6239 | toFixed(number: number, fractionDigits: number): number;
|
6240 |
|
6241 | |
6242 |
|
6243 |
|
6244 |
|
6245 |
|
6246 | parseUnit(value: number | string, fontSize?: number): number | string;
|
6247 |
|
6248 | |
6249 |
|
6250 |
|
6251 | falseFunction(): boolean;
|
6252 |
|
6253 | |
6254 |
|
6255 |
|
6256 |
|
6257 |
|
6258 | getKlass(type: string, namespace: string): any;
|
6259 |
|
6260 | |
6261 |
|
6262 |
|
6263 |
|
6264 | resolveNamespace(namespace: string): any;
|
6265 |
|
6266 | |
6267 |
|
6268 |
|
6269 |
|
6270 |
|
6271 |
|
6272 |
|
6273 | loadImage(url: string, callback: (image: HTMLImageElement) => void, context?: any, crossOrigin?: string): void;
|
6274 |
|
6275 | |
6276 |
|
6277 |
|
6278 |
|
6279 |
|
6280 |
|
6281 |
|
6282 | enlivenObjects(objects: any[], callback: Function, namespace: string, reviver?: Function): void;
|
6283 |
|
6284 | |
6285 |
|
6286 |
|
6287 |
|
6288 |
|
6289 | groupSVGElements(elements: any[], options?: any, path?: string): Object | Group;
|
6290 |
|
6291 | |
6292 |
|
6293 |
|
6294 |
|
6295 |
|
6296 |
|
6297 |
|
6298 |
|
6299 |
|
6300 |
|
6301 |
|
6302 |
|
6303 | clearFabricFontCache(fontFamily?: string): void;
|
6304 |
|
6305 | |
6306 |
|
6307 |
|
6308 |
|
6309 |
|
6310 |
|
6311 | populateWithProperties(source: any, destination: any, properties: any): void;
|
6312 |
|
6313 | |
6314 |
|
6315 |
|
6316 |
|
6317 |
|
6318 |
|
6319 |
|
6320 |
|
6321 |
|
6322 |
|
6323 | drawDashedLine(ctx: CanvasRenderingContext2D, x: number, y: number, x2: number, y2: number, da: any[]): void;
|
6324 |
|
6325 | |
6326 |
|
6327 |
|
6328 |
|
6329 |
|
6330 | createCanvasElement(canvasEl?: HTMLCanvasElement): HTMLCanvasElement;
|
6331 |
|
6332 | |
6333 |
|
6334 |
|
6335 | createImage(): HTMLImageElement;
|
6336 |
|
6337 | |
6338 |
|
6339 |
|
6340 |
|
6341 | createAccessors(klass: any): any;
|
6342 |
|
6343 | |
6344 |
|
6345 |
|
6346 |
|
6347 | clipContext(receiver: Object, ctx: CanvasRenderingContext2D): void;
|
6348 |
|
6349 | |
6350 |
|
6351 |
|
6352 |
|
6353 |
|
6354 | multiplyTransformMatrices(a: number[], b: number[]): number[];
|
6355 |
|
6356 | |
6357 |
|
6358 |
|
6359 |
|
6360 | qrDecompose(
|
6361 | a: number[],
|
6362 | ): {
|
6363 | angle: number;
|
6364 | scaleX: number;
|
6365 | scaleY: number;
|
6366 | skewX: number;
|
6367 | skewY: number;
|
6368 | translateX: number;
|
6369 | translateY: number;
|
6370 | };
|
6371 |
|
6372 | |
6373 |
|
6374 |
|
6375 |
|
6376 |
|
6377 | saveObjectTransform(
|
6378 | target: Object,
|
6379 | ): {
|
6380 | scaleX: number;
|
6381 | scaleY: number;
|
6382 | skewX: number;
|
6383 | skewY: number;
|
6384 | angle: number;
|
6385 | left: number;
|
6386 | flipX: boolean;
|
6387 | flipY: boolean;
|
6388 | top: number;
|
6389 | };
|
6390 |
|
6391 | |
6392 |
|
6393 |
|
6394 |
|
6395 |
|
6396 |
|
6397 |
|
6398 |
|
6399 |
|
6400 |
|
6401 |
|
6402 |
|
6403 |
|
6404 |
|
6405 |
|
6406 |
|
6407 |
|
6408 |
|
6409 | composeMatrix(options: {
|
6410 | angle: number;
|
6411 | scaleX: number;
|
6412 | scaleY: number;
|
6413 | flipX: boolean;
|
6414 | flipY: boolean;
|
6415 | skewX: number;
|
6416 | skewY: number;
|
6417 | translateX: number;
|
6418 | translateY: number;
|
6419 | }): number[];
|
6420 |
|
6421 | |
6422 |
|
6423 |
|
6424 |
|
6425 | getFunctionBody(fn: Function): string;
|
6426 |
|
6427 | |
6428 |
|
6429 |
|
6430 |
|
6431 |
|
6432 |
|
6433 |
|
6434 |
|
6435 | isTransparent(ctx: CanvasRenderingContext2D, x: number, y: number, tolerance: number): boolean;
|
6436 |
|
6437 | |
6438 |
|
6439 |
|
6440 |
|
6441 |
|
6442 |
|
6443 | resetObjectTransform(target: Object): void;
|
6444 | }
|
6445 |
|
6446 | export const util: IUtil;
|
6447 | interface IUtil
|
6448 | extends IUtilImage,
|
6449 | IUtilAnimation,
|
6450 | IUtilArc,
|
6451 | IObservable<IUtil>,
|
6452 | IUtilDomEvent,
|
6453 | IUtilDomMisc,
|
6454 | IUtilDomRequest,
|
6455 | IUtilDomStyle,
|
6456 | IUtilClass,
|
6457 | IUtilMisc {
|
6458 | ease: IUtilAnimEase;
|
6459 | array: IUtilArray;
|
6460 | object: IUtilObject;
|
6461 | string: IUtilString;
|
6462 | }
|
6463 |
|
6464 | export interface Resources {
|
6465 | [key: string]: HTMLCanvasElement;
|
6466 | }
|
6467 | export interface FilterBackend {
|
6468 | resources: Resources;
|
6469 |
|
6470 | applyFilters(
|
6471 | filters: IBaseFilter[],
|
6472 | sourceElement: HTMLImageElement | HTMLCanvasElement,
|
6473 | sourceWidth: number,
|
6474 | sourceHeight: number,
|
6475 | targetCanvas: HTMLCanvasElement,
|
6476 | cacheKey?: string,
|
6477 | ): any;
|
6478 |
|
6479 | evictCachesForKey(cacheKey: string): void;
|
6480 |
|
6481 | dispose(): void;
|
6482 |
|
6483 | clearWebGLCaches(): void;
|
6484 | }
|
6485 | export let filterBackend: FilterBackend | undefined;
|
6486 | export interface Canvas2dFilterBackend extends FilterBackend {}
|
6487 | export class Canvas2dFilterBackend {
|
6488 | constructor();
|
6489 | }
|
6490 |
|
6491 | export interface GPUInfo {
|
6492 | renderer: string;
|
6493 | vendor: string;
|
6494 | }
|
6495 |
|
6496 | export interface WebglFilterBackendOptions {
|
6497 | tileSize: number;
|
6498 | }
|
6499 | export interface WebglFilterBackend extends FilterBackend, WebglFilterBackendOptions {
|
6500 | setupGLContext(width: number, height: number): void;
|
6501 |
|
6502 | chooseFastestCopyGLTo2DMethod(width: number, height: number): void;
|
6503 |
|
6504 | createWebGLCanvas(width: number, height: number): void;
|
6505 |
|
6506 | applyFiltersDebug(
|
6507 | filters: IBaseFilter[],
|
6508 | sourceElement: HTMLImageElement | HTMLCanvasElement,
|
6509 | sourceWidth: number,
|
6510 | sourceHeight: number,
|
6511 | targetCanvas: HTMLCanvasElement,
|
6512 | cacheKey?: string,
|
6513 | ): any;
|
6514 |
|
6515 | glErrorToString(context: any, errorCode: any): string;
|
6516 |
|
6517 | createTexture(
|
6518 | gl: WebGLRenderingContext,
|
6519 | width: number,
|
6520 | height: number,
|
6521 | textureImageSource?: HTMLImageElement | HTMLCanvasElement,
|
6522 | ): WebGLTexture;
|
6523 |
|
6524 | getCachedTexture(uniqueId: string, textureImageSource: HTMLImageElement | HTMLCanvasElement): WebGLTexture;
|
6525 |
|
6526 | copyGLTo2D(gl: WebGLRenderingContext, pipelineState: any): void;
|
6527 |
|
6528 | captureGPUInfo(): GPUInfo;
|
6529 | }
|
6530 |
|
6531 | export class WebglFilterBackend {
|
6532 | constructor(options?: WebglFilterBackendOptions);
|
6533 | }
|
6534 |
|
6535 | export class Control {
|
6536 | constructor(options?: Partial<Control>);
|
6537 |
|
6538 | |
6539 |
|
6540 |
|
6541 |
|
6542 |
|
6543 |
|
6544 |
|
6545 |
|
6546 | visible: boolean;
|
6547 |
|
6548 | |
6549 |
|
6550 |
|
6551 |
|
6552 |
|
6553 |
|
6554 |
|
6555 |
|
6556 |
|
6557 |
|
6558 | actionName: string;
|
6559 |
|
6560 | |
6561 |
|
6562 |
|
6563 |
|
6564 |
|
6565 |
|
6566 | angle: number;
|
6567 |
|
6568 | |
6569 |
|
6570 |
|
6571 |
|
6572 |
|
6573 |
|
6574 | x: number;
|
6575 |
|
6576 | |
6577 |
|
6578 |
|
6579 |
|
6580 |
|
6581 |
|
6582 | y: number;
|
6583 |
|
6584 | |
6585 |
|
6586 |
|
6587 |
|
6588 |
|
6589 |
|
6590 |
|
6591 |
|
6592 |
|
6593 |
|
6594 |
|
6595 | offsetX: number;
|
6596 |
|
6597 | |
6598 |
|
6599 |
|
6600 |
|
6601 |
|
6602 | offsetY: number;
|
6603 |
|
6604 | |
6605 |
|
6606 |
|
6607 |
|
6608 |
|
6609 | sizeX?: number | undefined;
|
6610 |
|
6611 | |
6612 |
|
6613 |
|
6614 |
|
6615 | sizeY?: number | undefined;
|
6616 |
|
6617 | |
6618 |
|
6619 |
|
6620 |
|
6621 |
|
6622 |
|
6623 | touchSizeX?: number | undefined;
|
6624 |
|
6625 | |
6626 |
|
6627 |
|
6628 |
|
6629 |
|
6630 |
|
6631 | touchSizeY?: number | undefined;
|
6632 |
|
6633 | |
6634 |
|
6635 |
|
6636 |
|
6637 |
|
6638 | cursorStyle: string;
|
6639 |
|
6640 | |
6641 |
|
6642 |
|
6643 |
|
6644 |
|
6645 | withConnection: boolean;
|
6646 |
|
6647 | |
6648 |
|
6649 |
|
6650 |
|
6651 | actionHandler(eventData: MouseEvent, transformData: Transform, x: number, y: number): boolean;
|
6652 |
|
6653 | |
6654 |
|
6655 |
|
6656 | mouseDownHandler(eventData: MouseEvent, transformData: Transform, x: number, y: number): boolean;
|
6657 |
|
6658 | |
6659 |
|
6660 |
|
6661 | mouseUpHandler(eventData: MouseEvent, transformData: Transform, x: number, y: number): boolean;
|
6662 |
|
6663 | |
6664 |
|
6665 |
|
6666 | getActionHandler(eventData: MouseEvent, fabricObject: Object, control: Control): ControlMouseEventHandler;
|
6667 |
|
6668 | |
6669 |
|
6670 |
|
6671 | getMouseDownHandler(eventData: MouseEvent, fabricObject: Object, control: Control): ControlMouseEventHandler;
|
6672 |
|
6673 | |
6674 |
|
6675 |
|
6676 | getMouseUpHandler(eventData: MouseEvent, fabricObject: Object, control: Control): ControlMouseEventHandler;
|
6677 |
|
6678 | |
6679 |
|
6680 |
|
6681 |
|
6682 |
|
6683 | cursorStyleHandler(eventData: MouseEvent, control: Control, fabricObject: Object): string;
|
6684 |
|
6685 | |
6686 |
|
6687 |
|
6688 | getActionName(eventData: MouseEvent, control: Control, fabricObject: Object): string;
|
6689 |
|
6690 | |
6691 |
|
6692 |
|
6693 | getVisibility(fabricObject: Object, controlKey: string): boolean;
|
6694 |
|
6695 | |
6696 |
|
6697 |
|
6698 | setVisibility(visibility: boolean): void;
|
6699 |
|
6700 | positionHandler(dim: { x: number, y: number }, finalMatrix: any, fabricObject: Object, currentControl: Control): Point;
|
6701 |
|
6702 | |
6703 |
|
6704 |
|
6705 | calcCornerCoords(objectAngle: number, objectCornerSize: number, centerX: number, centerY: number, isTouch: boolean): void;
|
6706 |
|
6707 | |
6708 |
|
6709 |
|
6710 |
|
6711 |
|
6712 |
|
6713 |
|
6714 | render(ctx: CanvasRenderingContext2D, left: number, top: number, styleOverride: any, fabricObject: Object): void;
|
6715 | }
|
6716 |
|
6717 | type ControlMouseEventHandler = (eventData: MouseEvent, transformData: Transform, x: number, y: number) => boolean;
|
6718 |
|
6719 | export interface Transform {
|
6720 | target: Object;
|
6721 | action: string;
|
6722 | actionHandler: ControlMouseEventHandler;
|
6723 | altKey: boolean;
|
6724 | corner: string;
|
6725 | ex: number;
|
6726 | ey: number;
|
6727 | lastX: number;
|
6728 | lastY: number;
|
6729 | offsetX: number;
|
6730 | offsetY: number;
|
6731 | originX: "left" | "right";
|
6732 | originY: "top" | "bottom";
|
6733 | original: any;
|
6734 | scaleX: number;
|
6735 | scaleY: number;
|
6736 | shiftKey: boolean;
|
6737 | skewX: number;
|
6738 | skewY: number;
|
6739 | theta: number;
|
6740 | width: number;
|
6741 | }
|
6742 |
|
\ | No newline at end of file |