forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabricjs.d.ts
4600 lines (4187 loc) · 145 KB
/
fabricjs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for FabricJS v1.5.0
// Project: http://fabricjs.com/
// Definitions by: Oliver Klemencic <https://github.com/oklemencic/>, Joseph Livecchi <https://github.com/joewashear007/>, Michael Randolph <https://github.com/mrand01/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* tslint:disable:no-unused-variable */
/* tslint:disable:whitespace */
/* tslint:disable:typedef */
// Support AMD require
declare module "fabric" {
export = fabric;
}
declare namespace fabric {
var isLikelyNode: boolean;
var isTouchSupported: boolean;
/////////////////////////////////////////////////////////////
// farbic Functions
/////////////////////////////////////////////////////////////
function createCanvasForNode(width: number, height: number): ICanvas;
// Parse
// ----------------------------------------------------------
/**
* Creates markup containing SVG referenced elements like patterns, gradients etc.
* @param {fabric.Canvas} canvas instance of fabric.Canvas
*/
function createSVGRefElementsMarkup(canvas: IStaticCanvas): string;
/**
* Creates markup containing SVG font faces
* @param {Array} objects Array of fabric objects
*/
function createSVGFontFacesMarkup(objects: IObject[]): string;
/**
* Takes string corresponding to an SVG document, and parses it into a set of fabric objects
* @param {String} string
* @param {Function} callback
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
*/
function loadSVGFromString(string: string, callback: (results: IObject[], options: any) => void, reviver?: Function): void;
/**
* Takes url corresponding to an SVG document, and parses it into a set of fabric objects.
* Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)
* @param {String} url
* @param {Function} callback
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
*/
function loadSVGFromURL(url: string, callback: (results: IObject[], options: any) => void, reviver?: Function): void;
/**
* Returns CSS rules for a given SVG document
* @param {SVGDocument} doc SVG document to parse
*/
function getCSSRules(doc: SVGElement): any;
function parseElements(elements: any[], callback: Function, options: any, reviver?: Function): void;
/**
* Parses "points" attribute, returning an array of values
* @param {String} points points attribute string
*/
function parsePointsAttribute(points: string): any[];
/**
* Parses "style" attribute, retuning an object with values
* @param {SVGElement} element Element to parse
*/
function parseStyleAttribute(element: SVGElement): any;
/**
* Transforms an array of svg elements to corresponding fabric.* instances
* @param {Array} elements Array of elements to parse
* @param {Function} callback Being passed an array of fabric instances (transformed from SVG elements)
* @param {Object} [options] Options object
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
*/
function parseElements(elements: any[], callback: Function, options?: any, reviver?: Function): void;
/**
* Returns an object of attributes' name/value, given element and an array of attribute names;
* Parses parent "g" nodes recursively upwards.
* @param {DOMElement} element Element to parse
* @param {Array} attributes Array of attributes to parse
*/
function parseAttributes(elemen: HTMLElement, attributes: string[], svgUid?: string): { [key: string]: string }
/**
* Parses an SVG document, returning all of the gradient declarations found in it
* @param {SVGDocument} doc SVG document to parse
*/
function getGradientDefs(doc: SVGElement): { [key: string]: any };
/**
* Parses a short font declaration, building adding its properties to a style object
* @param {String} value font declaration
* @param {Object} oStyle definition
*/
function parseFontDeclaration(value: string, oStyle: any): void;
/**
* Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback
* @param {SVGDocument} doc SVG document to parse
* @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document).
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
*/
function parseSVGDocument(doc: SVGElement, callback: (results: IObject[], options: any) => void, reviver?: Function): void;
/**
* Parses "transform" attribute, returning an array of values
* @param {String} attributeValue String containing attribute value
*/
function parseTransformAttribute(attributeValue: string): number[];
// fabric Log
// ---------------
/**
* Wrapper around `console.log` (when available)
*/
function log(...values: any[]): void;
/**
* Wrapper around `console.warn` (when available)
*/
function warn(...values: any[]): void;
////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////
var Canvas: ICanvasStatic;
var StaticCanvas: IStaticCanvasStatic;
var Color: IColorStatic;
var Pattern: IPatternStatic;
var Intersection: IIntersectionStatic;
var Point: IPointStatic;
var Circle: ICircleStatic;
var Ellipse: IEllipseStatic;
var Group: IGroupStatic;
var Image: IImageStatic;
var Line: ILineStatic;
var Object: IObjectStatic;
var Path: IPathStatic;
var PathGroup: IPathGroupStatic;
var Polygon: IPolygonStatic;
var Polyline: IPolylineStatic;
var Rect: IRectStatic;
var Shadow: IShadowStatic;
var Text: ITextStatic;
var IText: IITextStatic;
var Triangle: ITriangleStatic;
var util: IUtil;
///////////////////////////////////////////////////////////////////////////////
// Data Object Interfaces - These intrface are not specific part of fabric,
// They are just helpful for for defining function paramters
//////////////////////////////////////////////////////////////////////////////
interface IDataURLOptions {
/**
* The format of the output image. Either "jpeg" or "png"
*/
format?: string;
/**
* Quality level (0..1). Only used for jpeg
*/
quality?: number;
/**
* Multiplier to scale by
*/
multiplier?: number;
/**
* Cropping left offset. Introduced in v1.2.14
*/
left?: number;
/**
* Cropping top offset. Introduced in v1.2.14
*/
top?: number;
/**
* Cropping width. Introduced in v1.2.14
*/
width?: number;
/**
* Cropping height. Introduced in v1.2.14
*/
height?: number;
}
interface IEvent {
e: Event;
target?: IObject;
}
interface IFillOptions {
/**
* options.source Pattern source
*/
source: string | HTMLImageElement;
/**
* Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat)
*/
repeat?: string;
/**
* Pattern horizontal offset from object's left/top corner
*/
offsetX?: number;
/**
* Pattern vertical offset from object's left/top corner
*/
offsetY?: number;
}
interface IToSVGOptions {
/**
* If true xml tag is not included
*/
suppressPreamble: boolean;
/**
* SVG viewbox object
*/
viewBox: IViewBox;
/**
* Encoding of SVG output
*/
encoding: string;
}
interface IViewBox {
/**
* x-cooridnate of viewbox
*/
x: number;
/**
* y-coordinate of viewbox
*/
y: number;
/**
* Width of viewbox
*/
width: number;
/**
* Height of viewbox
*/
height: number;
}
///////////////////////////////////////////////////////////////////////////////
// Mixins Interfaces
//////////////////////////////////////////////////////////////////////////////
interface ICollection<T> {
/**
* Adds objects to collection, then renders canvas (if `renderOnAddRemove` is not `false`)
* Objects should be instances of (or inherit from) fabric.Object
* @param {...fabric.Object} object Zero or more fabric instances
*/
add(...object: IObject[]): T;
/**
* Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`)
* An object should be an instance of (or inherit from) fabric.Object
* @param {Object} object Object to insert
* @param {Number} index Index to insert object at
* @param {Boolean} nonSplicing When `true`, no splicing (shifting) of objects occurs
* @return {Self} thisArg
* @chainable
*/
insertAt(object: IObject, index: number, nonSplicing: boolean): T;
/**
* Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)
* @param {...fabric.Object} object Zero or more fabric instances
* @return {Self} thisArg
* @chainable
*/
remove(...object: IObject[]): T;
/**
* Executes given function for each object in this group
* @param {Function} callback
* @param {Object} context Context (aka thisObject)
* @return {Self} thisArg
*/
forEachObject(callback: (element: IObject, index: number, array: IObject[]) => any, context?: any): T;
/**
* Returns an array of children objects of this instance
* Type parameter introduced in 1.3.10
* @param {String} [type] When specified, only objects of this type are returned
* @return {Array}
*/
getObjects(type?: string): IObject[];
/**
* Returns object at specified index
* @param {Number} index
* @return {Self} thisArg
*/
item(index: number): T;
/**
* Returns true if collection contains no objects
* @return {Boolean} true if collection is empty
*/
isEmpty(): boolean;
/**
* Returns a size of a collection (i.e: length of an array containing its objects)
* @return {Number} Collection size
*/
size(): number;
/**
* Returns true if collection contains an object
* @param {Object} object Object to check against
* @return {Boolean} `true` if collection contains an object
*/
contains(object: IObject): boolean;
/**
* Returns number representation of a collection complexity
* @return {Number} complexity
*/
complexity(): number;
}
interface IObservable<T> {
/**
* Observes specified event
* @param eventName Event name (eg. 'after:render')
* @param handler Function that receives a notification when an event of the specified type occurs
*/
on(eventName: string, handler: (e: IEvent) => any): T;
/**
* Observes specified event
* @param eventName Object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})
*/
on(eventName: {[key:string] : Function}): T;
/**
* Fires event with an optional options object
* @deprecated `fire` deprecated since 1.0.7 (use `trigger` instead)
* @param {String} eventName Event name to fire
* @param {Object} [options] Options object
*/
trigger(eventName: string, options?: any): T;
/**
* Stops event observing for a particular event handler. Calling this method
* without arguments removes all handlers for all events
* @deprecated `stopObserving` deprecated since 0.8.34 (use `off` instead)
* @param eventName Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})
* @param handler Function to be deleted from EventListeners
*/
off(eventName?: string|any, handler?: (e: IEvent) => any): T;
}
// animation mixin
// ----------------------------------------------------
interface ICanvasAnimation<T> {
FX_DURATION: number;
/**
* Centers object horizontally with animation.
* @param {fabric.Object} object Object to center
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
* @param {Function} [callbacks.onComplete] Invoked on completion
* @param {Function} [callbacks.onChange] Invoked on every step of animation
*/
fxCenterObjectH(object: IObject, callbacks?: { onComplete: Function; onChange: Function; }): T;
/**
* Centers object vertically with animation.
* @param {fabric.Object} object Object to center
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
* @param {Function} [callbacks.onComplete] Invoked on completion
* @param {Function} [callbacks.onChange] Invoked on every step of animation
*/
fxCenterObjectV(object: IObject, callbacks?: { onComplete: Function; onChange: Function; }): T;
/**
* Same as `fabric.Canvas#remove` but animated
* @param {fabric.Object} object Object to remove
* @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties
* @param {Function} [callbacks.onComplete] Invoked on completion
* @param {Function} [callbacks.onChange] Invoked on every step of animation
* @return {fabric.Canvas} thisArg
* @chainable
*/
fxRemove(object: IObject, callbacks?: { onComplete: Function; onChange: Function; }): T;
}
interface IObjectAnimation<T> {
/**
* Animates object's properties
* object.animate('left', ..., {duration: ...});
* @param property Property to animate
* @param value Value to animate property
* @param options The animation options
*/
animate(property: string, value: number|string, options?: IAnimationOptions): IObject;
/**
* Animates object's properties
* object.animate({ left: ..., top: ... }, { duration: ... });
* @param properties Properties to animate
* @param value Options object
*/
animate(properties: any, options?: IAnimationOptions): IObject;
}
interface IAnimationOptions {
/**
* Allows to specify starting value of animatable property (if we don't want current value to be used).
*/
from?: string|number;
/**
* Defaults to 500 (ms). Can be used to change duration of an animation.
*/
duration?: number;
/**
* Callback; invoked on every value change
*/
onChange?: Function;
/**
* Callback; invoked when value change is completed
*/
onComplete?: Function;
/**
* Easing function. Default: fabric.util.ease.easeInSine
*/
easing?: Function;
/**
* Value to modify the property by, default: end - start
*/
by?: number;
}
///////////////////////////////////////////////////////////////////////////////
// General Fabric Interfaces
//////////////////////////////////////////////////////////////////////////////
interface IColor {
/**
* Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])
*/
getSource(): number[];
/**
* Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
*/
setSource(source: number[]): void;
/**
* Returns color represenation in RGB format ex: rgb(0-255,0-255,0-255)
*/
toRgb(): string;
/**
* Returns color represenation in RGBA format ex: rgba(0-255,0-255,0-255,0-1)
*/
toRgba(): string;
/**
* Returns color represenation in HSL format ex: hsl(0-360,0%-100%,0%-100%)
*/
toHsl(): string;
/**
* Returns color represenation in HSLA format ex: hsla(0-360,0%-100%,0%-100%,0-1)
*/
toHsla(): string;
/**
* Returns color represenation in HEX format ex: FF5555
*/
toHex(): string;
/**
* Gets value of alpha channel for this color
*/
getAlpha(): number;
/**
* Sets value of alpha channel for this color
* @param {Number} alpha Alpha value 0-1
*/
setAlpha(alpha: number): void;
/**
* Transforms color to its grayscale representation
*/
toGrayscale(): IColor;
/**
* Transforms color to its black and white representation
* @param {Number} threshold
*/
toBlackWhite(threshold: number): IColor;
/**
* Overlays color with another color
* @param {String|fabric.Color} otherColor
*/
overlayWith(otherColor: string|IColor): IColor;
}
interface IColorStatic {
/**
* Color class
* The purpose of Color is to abstract and encapsulate common color operations;
* @param {String} color optional in hex or rgb(a) format
*/
new (color?: string): IColor;
/**
* Returns new color object, when given a color in RGB format
* @param {String} color Color value ex: rgb(0-255,0-255,0-255)
*/
fromRgb(color: string): IColor;
/**
* Returns new color object, when given a color in RGBA format
* @param {String} color Color value ex: rgb(0-255,0-255,0-255)
*/
fromRgba(color: string): IColor;
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format
* @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)
*/
sourceFromRgb(color: string): number[];
/**
* Returns new color object, when given a color in HSL format
* @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)
*/
fromHsl(color: string): IColor;
/**
* Returns new color object, when given a color in HSLA format
* @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)
*/
fromHsla(color: string): IColor;
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.
* @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)
*/
sourceFromHsl(color: string): number[];
/**
* Returns new color object, when given a color in HEX format
* @param {String} color Color value ex: FF5555
*/
fromHex(color: string): IColor;
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format
* @param {String} color ex: FF5555
*/
sourceFromHex(color: string): number[];
/**
* Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5])
* @param {Array} source
*/
fromSource(source: number[]): IColor;
prototype: any;
}
interface IGradientOptions {
/**
* @param {String} [options.type] Type of gradient 'radial' or 'linear'
*/
type?: string;
/**
* x-coordinate of start point
*/
x1?: number;
/**
* y-coordinate of start point
*/
y1?: number;
/**
* x-coordinate of end point
*/
x2?: number;
/**
* y-coordinate of end point
*/
y2?: number;
/**
* Radius of start point (only for radial gradients)
*/
r1?: number;
/**
* Radius of end point (only for radial gradients)
*/
r2?: number;
/**
* Color stops object eg. {0:string; 1:string;
*/
colorStops?: any;
}
interface IGradient extends IGradientOptions {
/**
* Adds another colorStop
* @param {Object} colorStop Object with offset and color
*/
addColorStop(colorStop: any): IGradient;
/**
* Returns object representation of a gradient
*/
toObject(): any;
/**
* Returns SVG representation of an gradient
* @param {Object} object Object to create a gradient for
* @param {Boolean} normalize Whether coords should be normalized
* @return {String} SVG representation of an gradient (linear/radial)
*/
toSVG(object: IObject, normalize?: boolean): string;
/**
* Returns an instance of CanvasGradient
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
toLive(ctx: CanvasRenderingContext2D, object?: IPathGroup): CanvasGradient;
}
interface IGrandientStatic {
new (options?: IGradientOptions): IGradient;
/**
* Returns instance from an SVG element
* @param {SVGGradientElement} el SVG gradient element
* @param {fabric.Object} instance
*/
fromElement(el: SVGGradientElement, instance: IObject): IGradient;
/**
* Returns instance from its object representation
* @param {Object} obj
* @param {Object} [options] Options object
*/
fromObject(obj: any, options: any[]): IGradient;
}
interface IIntersection {
/**
* Appends a point to intersection
*/
appendPoint(point: IPoint): void;
/**
* Appends points to intersection
*/
appendPoints(points: IPoint[]): void;
}
interface IIntersectionStatic {
/**
* Intersection class
*/
new (status?: string): void;
/**
* Checks if polygon intersects another polygon
*/
intersectPolygonPolygon(points1: IPoint[], points2: IPoint[]): IIntersection;
/**
* Checks if line intersects polygon
*/
intersectLinePolygon(a1: IPoint, a2: IPoint, points: IPoint[]): IIntersection;
/**
* Checks if one line intersects another
*/
intersectLineLine(a1: IPoint, a2: IPoint, b1: IPoint, b2: IPoint): IIntersection;
/**
* Checks if polygon intersects rectangle
*/
intersectPolygonRectangle(points: IPoint[], r1: number, r2: number): IIntersection;
}
interface IPatternOptions {
/**
* Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat)
*/
repeat: string;
/**
* Pattern horizontal offset from object's left/top corner
*/
offsetX: number;
/**
* Pattern vertical offset from object's left/top corner
*/
offsetY: number;
/**
* The source for the pattern
*/
source: string|HTMLImageElement;
}
interface IPattern extends IPatternOptions {
new (options?: IPatternOptions): IPattern;
initialise(options?: IPatternOptions): IPattern;
/**
* Returns an instance of CanvasPattern
*/
toLive(ctx: CanvasRenderingContext2D): IPattern;
/**
* Returns object representation of a pattern
*/
toObject(): any;
/**
* Returns SVG representation of a pattern
* @param {fabric.Object} object
*/
toSVG(object: IObject): string;
}
interface IPatternStatic {
new (options?: IPatternOptions): IPattern;
prototype: any;
}
interface IPoint {
x: number;
y: number;
/**
* Adds another point to this one and returns another one
* @param {fabric.Point} that
*/
add(that: IPoint): IPoint;
/**
* Adds another point to this one
* @param {fabric.Point} that
*/
addEquals(that: IPoint): IPoint;
/**
* Adds value to this point and returns a new one
* @param {Number} scalar
*/
scalarAdd(scalar: number): IPoint;
/**
* Adds value to this point
* @param {Number} scalar
*/
scalarAddEquals(scalar: number): IPoint;
/**
* Subtracts another point from this point and returns a new one
* @param {fabric.Point} that
*/
subtract(that: IPoint): IPoint;
/**
* Subtracts another point from this point
* @param {fabric.Point} that
*/
subtractEquals(that: IPoint): IPoint;
/**
* Subtracts value from this point and returns a new one
* @param {Number} scalar
*/
scalarSubtract(scalar: number): IPoint;
/**
* Subtracts value from this point
* @param {Number} scalar
*/
scalarSubtractEquals(scalar: number): IPoint;
/**
* Miltiplies this point by a value and returns a new one
* @param {Number} scalar
*/
multiply(scalar: number): IPoint;
/**
* Miltiplies this point by a value
* @param {Number} scalar
*/
multiplyEquals(scalar: number): IPoint;
/**
* Divides this point by a value and returns a new one
* @param {Number} scalar
*/
divide(scalar: number): IPoint;
/**
* Divides this point by a value
* @param {Number} scalar
*/
divideEquals(scalar: number): IPoint;
/**
* Returns true if this point is equal to another one
* @param {fabric.Point} that
*/
eq(that: IPoint): IPoint;
/**
* Returns true if this point is less than another one
* @param {fabric.Point} that
*/
lt(that: IPoint): IPoint;
/**
* Returns true if this point is less than or equal to another one
* @param {fabric.Point} that
*/
lte(that: IPoint): IPoint;
/**
* Returns true if this point is greater another one
* @param {fabric.Point} that
*/
gt(that: IPoint): IPoint;
/**
* Returns true if this point is greater than or equal to another one
* @param {fabric.Point} that
*/
gte(that: IPoint): IPoint;
/**
* Returns new point which is the result of linear interpolation with this one and another one
* @param {fabric.Point} that
* @param {Number} t
*/
lerp(that: IPoint, t: number): IPoint;
/**
* Returns distance from this point and another one
* @param {fabric.Point} that
*/
distanceFrom(that: IPoint): number;
/**
* Returns the point between this point and another one
* @param {fabric.Point} that
*/
midPointFrom(that: IPoint): IPoint;
/**
* Returns a new point which is the min of this and another one
* @param {fabric.Point} that
*/
min(that: IPoint): IPoint;
/**
* Returns a new point which is the max of this and another one
* @param {fabric.Point} that
*/
max(that: IPoint): IPoint;
/**
* Returns string representation of this point
*/
toString(): string;
/**
* Sets x/y of this point
* @param {Number} x
* @param {Number} y
*/
setXY(x:number, y: number): IPoint;
/**
* Sets x/y of this point from another point
* @param {fabric.Point} that
*/
setFromPoint(that: IPoint): IPoint;
/**
* Swaps x/y of this point and another point
* @param {fabric.Point} that
*/
swap(that: IPoint): IPoint;
}
interface IPointStatic {
new (x: number, y: number): IPoint;
prototype: any;
}
interface IShadowOptions {
/**
* Whether the shadow should affect stroke operations
*/
affectStrike: boolean;
/**
* Shadow blur
*/
blur: number;
/**
* Shadow color
*/
color: string;
/**
* Indicates whether toObject should include default values
*/
includeDefaultValues: boolean;
/**
* Shadow horizontal offset
*/
offsetX: number;
/**
* Shadow vertical offset
*/
offsetY: number;
}
interface IShadow extends IShadowOptions {
initialize(options?: IShadowOptions|string): IShadow;
/**
* Returns object representation of a shadow
*/
toObject(): IObject;
/**
* Returns a string representation of an instance, CSS3 text-shadow declaration
*/
toString(): string;
/**
* Returns SVG representation of a shadow
* @param {fabric.Object} object
*/
toSVG(object: IObject): string;
/**
* Regex matching shadow offsetX, offsetY and blur, Static
*/
reOffsetsAndBlur: RegExp
}
interface IShadowStatic {
new (options?: IShadowOptions): IShadow;
reOffsetsAndBlur: RegExp;
}
///////////////////////////////////////////////////////////////////////////////
// Canvas Interfaces
//////////////////////////////////////////////////////////////////////////////
interface ICanvasDimensions {
/**
* Width of canvas element
*/
width: number;
/**
* Height of canvas element
*/
height: number;
}
interface ICanvasDimensionsOptions {
/**
* Set the given dimensions only as canvas backstore dimensions
*/
backstoreOnly?: boolean;
/**
* Set the given dimensions only as css dimensions
*/
cssOnly?: boolean;
}
interface IStaticCanvasOptions {
/**
* Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas
*/
allowTouchScrolling?: boolean;
/**
* Indicates whether this canvas will use image smoothing, this is on by default in browsers
*/
imageSmoothingEnabled?: boolean;
/**
* Indicates whether objects should remain in current stack position when selected.
* When false objects are brought to top and rendered as part of the selection group
*/
preserveObjectStacking?: boolean;
/**
* The transformation (in the format of Canvas transform) which focuses the viewport
*/
viewportTransform?: number[];
freeDrawingColor?: string;
freeDrawingLineWidth?: number;
/**
* Background color of canvas instance.
* Should be set via setBackgroundColor
*/
backgroundColor?: string|IPattern;
/**
* Background image of canvas instance.
* Should be set via setBackgroundImage
* <b>Backwards incompatibility note:</b> The "backgroundImageOpacity" and "backgroundImageStretch" properties are deprecated since 1.3.9.
*/
backgroundImage?: IImage | string;
backgroundImageOpacity?: number;
backgroundImageStretch?: number;
/**
* Function that determines clipping of entire canvas area
* Being passed context as first argument. See clipping canvas area
*/
clipTo?: (context: CanvasRenderingContext2D) => void;
/**
* Indicates whether object controls (borders/controls) are rendered above overlay image
*/
controlsAboveOverlay?: boolean;
/**
* Indicates whether toObject/toDatalessObject should include default values
*/
includeDefaultValues?: boolean;
/**
* Overlay color of canvas instance.
* Should be set via setOverlayColor
*/
overlayColor?: string|IPattern;