This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathpixi.js.d.ts
4726 lines (4406 loc) · 169 KB
/
pixi.js.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 pixi.js 4.8
// Project: https://github.com/pixijs/pixi.js/tree/v4.x
// Definitions by: clark-stevenson <https://github.com/clark-stevenson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
declare namespace PIXI {
// from CONST
/** String of the current PIXI version. */
const VERSION: typeof CONST.VERSION;
/** Two Pi. */
const PI_2: typeof CONST.PI_2;
/** Conversion factor for converting radians to degrees. */
const RAD_TO_DEG: typeof CONST.RAD_TO_DEG;
/** Conversion factor for converting degrees to radians. */
const DEG_TO_RAD: typeof CONST.DEG_TO_RAD;
/** Constant to identify the Renderer Type. */
const RENDERER_TYPE: typeof CONST.RENDERER_TYPE;
/**
* Various blend modes supported by PIXI.
*
* IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
* Anything else will silently act like NORMAL.
*/
const BLEND_MODES: typeof CONST.BLEND_MODES;
/**
* Various webgl draw modes. These can be used to specify which GL drawMode to use
* under certain situations and renderers.
*/
const DRAW_MODES: typeof CONST.DRAW_MODES;
/**
* The scale modes that are supported by pixi.
*
* The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations.
* It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.
*/
const SCALE_MODES: typeof CONST.SCALE_MODES;
/**
* The wrap modes that are supported by pixi.
*
* The {@link PIXI.settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations.
* It can be re-assigned to either CLAMP or REPEAT, depending upon suitability.
* If the texture is non power of two then clamp will be used regardless as webGL can
* only use REPEAT if the texture is po2.
*
* This property only affects WebGL.
*/
const WRAP_MODES: typeof CONST.WRAP_MODES;
/**
* Constants that specify the transform type.
*/
const TRANSFORM_MODE: typeof CONST.TRANSFORM_MODE;
/**
* Constants that specify float precision in shaders.
*/
const PRECISION: typeof CONST.PRECISION;
/**
* The gc modes that are supported by pixi.
*
* The {@link PIXI.settings.GC_MODE} Garbage Collection mode for PixiJS textures is AUTO
* If set to GC_MODE, the renderer will occasionally check textures usage. If they are not
* used for a specified period of time they will be removed from the GPU. They will of course
* be uploaded again when they are required. This is a silent behind the scenes process that
* should ensure that the GPU does not get filled up.
*
* Handy for mobile devices!
* This property only affects WebGL.
*/
const GC_MODES: typeof CONST.GC_MODES;
/**
* Constants that identify shapes, mainly to prevent `instanceof` calls.
*/
const SHAPES: typeof CONST.SHAPES;
/**
* Constants that define the type of gradient on text.
*/
const TEXT_GRADIENT: typeof CONST.TEXT_GRADIENT;
/**
* Represents the update priorities used by internal PIXI classes when registered with
* the {@link PIXI.ticker.Ticker} object. Higher priority items are updated first and lower
* priority items, such as render, should go later.
*/
const UPDATE_PRIORITY: typeof CONST.UPDATE_PRIORITY;
function autoDetectRenderer(
width: number,
height: number,
options?: PIXI.RendererOptions,
forceCanvas?: boolean
): PIXI.WebGLRenderer | PIXI.CanvasRenderer;
/**
* This helper function will automatically detect which renderer you should be using.
* WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by
* the browser then this function will return a canvas renderer
* @param [options] - The optional renderer parameters
* @param [options.width=800] - the width of the renderers view
* @param [options.height=600] - the height of the renderers view
* @param [options.view] - the canvas to use as a view, optional
* @param [options.transparent=false] - If the render view is transparent, default false
* @param [options.antialias=false] - sets antialias (only applicable in chrome at the moment)
* @param [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, enable this if you
* need to call toDataUrl on the webgl context
* @param [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
* not before the new render pass.
* @param [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2
* @param [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present
* @param [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering,
* stopping pixel interpolation.
* @param [options.forceFXAA=false] - forces FXAA antialiasing to be used over native.
* FXAA is faster, but may not always look as great **webgl only**
* @param [options.legacy=false] - `true` to ensure compatibility with older / less advanced devices.
* If you experience unexplained flickering try setting this to true. **webgl only**
* @param [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
* for devices with dual graphics card **webgl only**
* @return Returns WebGL renderer if available, otherwise CanvasRenderer
*/
function autoDetectRenderer(options?: PIXI.RendererOptions): PIXI.WebGLRenderer | PIXI.CanvasRenderer;
const loader: PIXI.loaders.Loader;
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////SETTINGS///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/**
* User"s customizable globals for overriding the default PIXI settings, such
* as a renderer"s default resolution, framerate, float percision, etc.
* @example
* // Use the native window resolution as the default resolution
* // will support high-density displays when rendering
* PIXI.settings.RESOLUTION = window.devicePixelRatio.
*
* // Disable interpolation when scaling, will make texture be pixelated
* PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
*/
namespace settings {
/**
* Target frames per millisecond.
* @default 0.06
*/
let TARGET_FPMS: number;
/**
* If set to true WebGL will attempt make textures mimpaped by default.
* Mipmapping will only succeed if the base texture uploaded has power of two dimensions.
* @default true
*/
let MIPMAP_TEXTURES: boolean;
/**
* If set to true WebGL will attempt make textures mimpaped by default.
* Mipmapping will only succeed if the base texture uploaded has power of two dimensions.
* @default true
*/
let RESOLUTION: number;
/**
* Default filter resolution.
* @default 1
*/
let FILTER_RESOLUTION: number;
/**
* The maximum textures that this device supports.
* @default 32
*/
let SPRITE_MAX_TEXTURES: number;
/**
* The default sprite batch size.
*
* The default aims to balance desktop and mobile devices.
* @default 4096
*/
let SPRITE_BATCH_SIZE: number;
/**
* The prefix that denotes a URL is for a retina asset.
* @example `@2x`
* @default /@([0-9\.]+)x/
*/
let RETINA_PREFIX: RegExp;
/**
* The default render options if none are supplied to {@link PIXI.WebGLRenderer}
* or {@link PIXI.CanvasRenderer}.
*
* @static
* @constant
* @memberof PIXI.settings
* @type {object}
* @property {HTMLCanvasElement} view=null
* @property {number} resolution=1
* @property {boolean} antialias=false
* @property {boolean} forceFXAA=false
* @property {boolean} autoResize=false
* @property {boolean} transparent=false
* @property {number} backgroundColor=0x000000
* @property {boolean} clearBeforeRender=true
* @property {boolean} preserveDrawingBuffer=false
* @property {boolean} roundPixels=false
* @property {number} width=800
* @property {number} height=600
* @property {boolean} legacy=false
*/
const RENDER_OPTIONS: {
view: HTMLCanvasElement | null;
antialias: boolean;
forceFXAA: boolean;
autoResize: boolean;
transparent: boolean;
backgroundColor: number;
clearBeforeRender: boolean;
preserveDrawingBuffer: boolean;
roundPixels: boolean;
width: number;
height: number;
legacy: boolean;
};
/**
* Default transform type.
* @type {PIXI.TRANSFORM_MODE}
* @default PIXI.TRANSFORM_MODE.STATIC
*/
let TRANSFORM_MODE: number;
/**
* Default Garbage Collection mode.
* @type {PIXI.GC_MODES}
* @default PIXI.GC_MODES.AUTO
*/
let GC_MODE: number;
/**
* Default Garbage Collection max idle.
* @default 3600
*/
let GC_MAX_IDLE: number;
/**
* Default Garbage Collection maximum check count.
* @default 600
*/
let GC_MAX_CHECK_COUNT: number;
/**
* Default wrap modes that are supported by pixi.
* @type {PIXI.WRAP_MODES}
* @default PIXI.WRAP_MODES.CLAMP
*/
let WRAP_MODE: number;
/**
* The scale modes that are supported by pixi.
* @type {PIXI.SCALE_MODES}
* @default PIXI.SCALE_MODES.LINEAR
*/
let SCALE_MODE: number;
/**
* Default specify float precision in vertex shader.
* @type {PIXI.PRECISION}
* @default PIXI.PRECISION.HIGH
*/
let PRECISION_VERTEX: string;
/**
* Default specify float precision in fragment shader.
* @type {PIXI.PRECISION}
* @default PIXI.PRECISION.MEDIUM
*/
let PRECISION_FRAGMENT: string;
/**
* @deprecated since version 4.4.0
*/
let PRECISION: string;
/**
* Default number of uploads per frame using prepare plugin.
* @default 4
*/
let UPLOADS_PER_FRAME: number;
/**
* Can we upload the same buffer in a single frame?
*/
let CAN_UPLOAD_SAME_BUFFER: boolean;
/**
* Default Mesh `canvasPadding`.
* @see PIXI.mesh.Mesh#canvasPadding
*/
let MESH_CANVAS_PADDING: number;
}
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////ACCESSIBILITY////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
namespace accessibility {
// accessibility
class AccessibilityManager {
constructor(renderer: CanvasRenderer | WebGLRenderer);
activate(): void;
deactivate(): void;
protected div: HTMLElement;
protected pool: HTMLElement[];
protected renderId: number;
debug: boolean;
renderer: SystemRenderer;
protected children: AccessibleTarget[];
protected isActive: boolean;
protected updateAccessibleObjects(displayObject: DisplayObject): void;
protected update(): void;
protected capHitArea(hitArea: HitArea): void;
protected addChild(displayObject: DisplayObject): void;
protected _onClick(e: interaction.InteractionEvent): void;
protected _onFocus(e: interaction.InteractionEvent): void;
protected _onFocusOut(e: interaction.InteractionEvent): void;
protected _onKeyDown(e: interaction.InteractionEvent): void;
protected _onMouseMove(e: MouseEvent): void;
destroy(): void;
}
interface AccessibleTarget {
accessible: boolean;
accessibleTitle: string | null;
accessibleHint: string | null;
tabIndex: number;
}
}
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////CORE//////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// const
namespace CONST {
/** String of the current PIXI version. */
const VERSION: string;
/** Two Pi. */
const PI_2: number;
/** Conversion factor for converting radians to degrees. */
const RAD_TO_DEG: number;
/** Conversion factor for converting degrees to radians. */
const DEG_TO_RAD: number;
const TARGET_FPMS: number;
/** Constant to identify the Renderer Type. */
const RENDERER_TYPE: {
/** Unknown render type. */
UNKNOWN: number;
/** WebGL render type. */
WEBGL: number;
/** Canvas render type. */
CANVAS: number;
};
/**
* Various blend modes supported by PIXI.
*
* IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
* Anything else will silently act like NORMAL.
*/
const BLEND_MODES: {
NORMAL: number;
ADD: number;
MULTIPLY: number;
SCREEN: number;
OVERLAY: number;
DARKEN: number;
LIGHTEN: number;
COLOR_DODGE: number;
COLOR_BURN: number;
HARD_LIGHT: number;
SOFT_LIGHT: number;
DIFFERENCE: number;
EXCLUSION: number;
HUE: number;
SATURATION: number;
COLOR: number;
LUMINOSITY: number;
NORMAL_NPM: number;
ADD_NPM: number;
SCREEN_NPM: number;
};
/**
* Various webgl draw modes. These can be used to specify which GL drawMode to use
* under certain situations and renderers.
*/
const DRAW_MODES: {
POINTS: number;
LINES: number;
LINE_LOOP: number;
LINE_STRIP: number;
TRIANGLES: number;
TRIANGLE_STRIP: number;
TRIANGLE_FAN: number;
};
/**
* The scale modes that are supported by pixi.
*
* The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations.
* It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.
*/
const SCALE_MODES: {
LINEAR: number;
NEAREST: number;
};
/**
* The gc modes that are supported by pixi.
*
* The {@link PIXI.settings.GC_MODE} Garbage Collection mode for PixiJS textures is AUTO
* If set to GC_MODE, the renderer will occasionally check textures usage. If they are not
* used for a specified period of time they will be removed from the GPU. They will of course
* be uploaded again when they are required. This is a silent behind the scenes process that
* should ensure that the GPU does not get filled up.
*
* Handy for mobile devices!
* This property only affects WebGL.
*/
const GC_MODES: {
/** Garbage collection will happen periodically automatically */
AUTO: number;
/** Garbage collection will need to be called manually */
MANUAL: number;
};
const WRAP_MODES: {
/** The textures uvs are clamped */
CLAMP: number;
/** The texture uvs tile and repeat */
MIRRORED_REPEAT: number;
/** The texture uvs tile and repeat with mirroring */
REPEAT: number;
};
/**
* Constants that specify the transform type.
*/
const TRANSFORM_MODE: {
DEFAULT: number;
DYNAMIC: number;
STATIC: number;
};
/**
* Regexp for image type by extension.
*
* @example `image.png`
*/
const URL_FILE_EXTENSION: RegExp | string;
/**
* Regexp for data URI.
* Based on: {@link https://github.com/ragingwind/data-uri-regex}
*
* @example data:image/png;base64
*/
const DATA_URI: RegExp | string;
/**
* Regexp for SVG size.
*
* @example <svg width="100" height="100"></svg>;
*/
const SVG_SIZE: RegExp | string;
/**
* Constants that identify shapes, mainly to prevent `instanceof` calls.
*/
const SHAPES: {
/** Polygon */
POLY: number;
/** Rectangle */
RECT: number;
/** Circle */
CIRC: number;
/** Ellipse */
ELIP: number;
/** Rounded Rectangle */
RREC: number;
};
/**
* Constants that specify float precision in shaders.
*/
const PRECISION: {
/** "lowp" */
LOW: string;
/** "mediump" */
MEDIUM: string;
/** "highp" */
HIGH: string;
};
/**
* Constants that define the type of gradient on text.
*/
const TEXT_GRADIENT: {
/** Vertical gradient */
LINEAR_VERTICAL: number;
/** Linear gradient */
LINEAR_HORIZONTAL: number;
};
/**
* Represents the update priorities used by internal PIXI classes when registered with
* the {@link PIXI.ticker.Ticker} object. Higher priority items are updated first and lower
* priority items, such as render, should go later.
*/
const UPDATE_PRIORITY: {
/** INTERACTION=50 Highest priority, used for {@link PIXI.interaction.InteractionManager} */
INTERACTION: number;
/** HIGH=25 High priority updating, {@link PIXI.VideoBaseTexture} and {@link PIXI.extras.AnimatedSprite} */
HIGH: number;
/** NORMAL=0 Default priority for ticker events, see {@link PIXI.ticker.Ticker#add}. */
NORMAL: number;
/** LOW=-25 Low priority used for {@link PIXI.Application} rendering. */
LOW: number;
/** UTILITY=-50 Lowest priority used for {@link PIXI.prepare.BasePrepare} utility. */
UTILITY: number;
};
}
// display
interface StageOptions {
children?: boolean;
texture?: boolean;
baseTexture?: boolean;
}
/**
* Convenience class to create a new PIXI application.
* This class automatically creates the renderer, ticker
* and root container.
*
* @example
* // Create the application
* const app = new PIXI.Application();
*
* // Add the view to the DOM
* document.body.appendChild(app.view);
*
* // ex, add display objects
* app.stage.addChild(PIXI.Sprite.fromImage("something.png"));
*/
class Application {
constructor(options?: ApplicationOptions);
constructor(
width?: number,
height?: number,
options?: ApplicationOptions,
noWebGL?: boolean,
sharedTicker?: boolean,
sharedLoader?: boolean
);
private _ticker: ticker.Ticker;
renderer: PIXI.WebGLRenderer | PIXI.CanvasRenderer;
stage: Container;
ticker: ticker.Ticker;
/**
* Loader instance to help with asset loading.
*/
loader: loaders.Loader;
readonly screen: Rectangle;
/**
* Convenience method for stopping the render.
*/
stop(): void;
/**
* Convenience method for starting the render.
*/
start(): void;
/**
* Render the current stage.
*/
render(): void;
/**
* Destroy and don"t use after this.
* @param [removeView=false] Automatically remove canvas from DOM.
* @param [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
*/
destroy(removeView?: boolean, stageOptions?: StageOptions | boolean): void;
readonly view: HTMLCanvasElement;
}
interface DestroyOptions {
/** if set to true, all the children will have their destroy method called as well. "options" will be passed on to those calls. */
children?: boolean;
/**
* It Should it destroy the current texture of the sprite as well
*
* Only used for child Sprites if options.children is set to true
*/
texture?: boolean;
/**
* Should it destroy the base texture of the sprite as well
*
* Only used for child Sprites if options.children is set to true
*/
baseTexture?: boolean;
}
/**
* "Builder" pattern for bounds rectangles
* Axis-Aligned Bounding Box
* It is not a shape! Its mutable thing, no "EMPTY" or that kind of problems
*/
class Bounds {
minX: number;
minY: number;
maxX: number;
maxY: number;
rect: Rectangle;
/**
* Checks if bounds are empty.
*
* @return True if empty.
*/
isEmpty(): boolean;
/**
* Clears the bounds and resets.
*
*/
clear(): void;
/**
* Can return Rectangle.EMPTY constant, either construct new rectangle, either use your rectangle
* It is not guaranteed that it will return tempRect
*
* @param rect - temporary object will be used if AABB is not empty
* @returns A rectangle of the bounds
*/
getRectangle(rect?: Rectangle): Rectangle;
/**
* This function should be inlined when its possible.
*
* @param point - The point to add.
*/
addPoint(point: Point): void;
/**
* Adds a quad, not transformed
*
* @param vertices - The verts to add.
*/
addQuad(vertices: ArrayLike<number>): Bounds | undefined;
/**
* Adds sprite frame, transformed.
*
* @param transform - TODO
* @param x0 - TODO
* @param y0 - TODO
* @param x1 - TODO
* @param y1 - TODO
*/
addFrame(transform: Transform, x0: number, y0: number, x1: number, y1: number): void;
/**
* Add an array of vertices
*
* @param transform - TODO
* @param vertices - TODO
* @param beginOffset - TODO
* @param endOffset - TODO
*/
addVertices(transform: Transform, vertices: ArrayLike<number>, beginOffset: number, endOffset: number): void;
/**
* Adds other Bounds
*
* @param bounds - TODO
*/
addBounds(bounds: Bounds): void;
/**
* Adds other Bounds, masked with Bounds
*
* @param bounds - TODO
* @param mask - TODO
*/
addBoundsMask(bounds: Bounds, mask: Bounds): void;
/**
* Adds other Bounds, masked with Rectangle
*
* @param bounds - TODO
* @param area - TODO
*/
addBoundsArea(bounds: Bounds, area: Rectangle): void;
}
/**
* A Container represents a collection of display objects.
*
* It is the base class of all display objects that act as a container for other objects.
*
* ```js
* let container = new PIXI.Container();
* container.addChild(sprite);
* ```
*/
class Container extends DisplayObject {
// begin extras.getChildByName
/**
* Returns the display object in the container
*
* @param name - instance name
* @return The child with the specified name.
*/
getChildByName<T extends DisplayObject = Container>(name: string): T;
// end extras.getChildByName
children: DisplayObject[];
width: number;
height: number;
protected onChildrenChange: (...args: any[]) => void;
addChild<T extends DisplayObject>(...children: T[]): T;
/**
* Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown
*
* @param child - The child to add
* @param index - The index to place the child in
* @return The child that was added.
*/
addChildAt<T extends DisplayObject>(child: T, index: number): T;
/**
* Swaps the position of 2 Display Objects within this container.
*
* @param child - First display object to swap
* @param child2 - Second display object to swap
*/
swapChildren(child: DisplayObject, child2: DisplayObject): void;
/**
* Returns the index position of a child DisplayObject instance
*
* @param child - The DisplayObject instance to identify
* @return The index position of the child display object to identify
*/
getChildIndex(child: DisplayObject): number;
/**
* Changes the position of an existing child in the display object container
*
* @param child - The child DisplayObject instance for which you want to change the index number
* @param index - The resulting index number for the child display object
*/
setChildIndex(child: DisplayObject, index: number): void;
/**
* Returns the child at the specified index
*
* @param index - The index to get the child at
* @return The child at the given index, if any.
*/
getChildAt<T extends DisplayObject = Container>(index: number): T;
removeChild<T extends DisplayObject = Container>(child: DisplayObject): T;
/**
* Removes a child from the specified index position.
*
* @param index - The index to get the child from
* @return The child that was removed.
*/
removeChildAt<T extends DisplayObject = Container>(index: number): T;
/**
* Removes all children from this container that are within the begin and end indexes.
*
* @param [beginIndex=0] - The beginning position.
* @param [endIndex=this.children.length] - The ending position. Default value is size of the container.
* @returns List of removed children
*/
removeChildren<T extends DisplayObject = Container>(beginIndex?: number, endIndex?: number): T[];
/**
* Updates the transform on all children of this container for rendering
*/
updateTransform(): void;
/**
* Recalculates the bounds of the container.
*/
calculateBounds(): void;
/**
* Recalculates the bounds of the object. Override this to
* calculate the bounds of the specific object (not including children).
*
*/
protected _calculateBounds(): void;
protected containerUpdateTransform(): void;
renderWebGL(renderer: WebGLRenderer): void;
renderAdvancedWebGL(renderer: WebGLRenderer): void;
protected _renderWebGL(renderer: WebGLRenderer): void;
protected _renderCanvas(renderer: CanvasRenderer): void;
renderCanvas(renderer: CanvasRenderer): void;
/**
* Removes all internal references and listeners as well as removes children from the display list.
* Do not use a Container after calling `destroy`.
*
* @param [options] - Options parameter. A boolean will act as if all options have been set to that value
*/
destroy(options?: DestroyOptions | boolean): void;
once(
event: interaction.InteractionEventTypes | "added" | "removed",
fn: (event: interaction.InteractionEvent) => void,
context?: any
): this;
once(event: string | symbol, fn: (...args: any[]) => any, context?: any): this;
on(
event: interaction.InteractionEventTypes | "added" | "removed",
fn: (event: interaction.InteractionEvent) => void,
context?: any
): this;
on(event: string | symbol, fn: (...args: any[]) => any, context?: any): this;
off(event: "added" | "removed" | string | symbol, fn?: (...args: any[]) => any, context?: any): this;
}
/**
* The base class for all objects that are rendered on the screen.
* This is an abstract class and should not be used on its own rather it should be extended.
*/
class DisplayObject extends utils.EventEmitter
implements interaction.InteractiveTarget, accessibility.AccessibleTarget {
// begin extras.cacheAsBitmap
protected _cacheAsBitmap: boolean;
protected _cacheData: boolean;
/**
* Set this to true if you want this display object to be cached as a bitmap.
* This basically takes a snap shot of the display object as it is at that moment. It can
* provide a performance benefit for complex static displayObjects.
* To remove simply set this property to "false"
*
* IMPORTANT GOTCHA - make sure that all your textures are preloaded BEFORE setting this property to true
* as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear.
*/
cacheAsBitmap: boolean;
protected _renderCachedWebGL(renderer: WebGLRenderer): void;
protected _initCachedDisplayObject(renderer: WebGLRenderer): void;
protected _renderCachedCanvas(renderer: CanvasRenderer): void;
protected _initCachedDisplayObjectCanvas(renderer: CanvasRenderer): void;
protected _calculateCachedBounds(): Rectangle;
protected _getCachedLocalBounds(): Rectangle;
protected _destroyCachedDisplayObject(): void;
protected _cacheAsBitmapDestroy(options: boolean | any): void;
// end extras.cacheAsBitmap
// begin extras.getChildByName
/**
* The instance name of the object.
*/
name: string | null;
// end extras.getChildByName
// begin extras.getGlobalPosition
/**
* Returns the global position of the displayObject. Does not depend on object scale, rotation and pivot.
*
* @param point - the point to write the global value to. If null a new point will be returned
* @param skipUpdate - setting to true will stop the transforms of the scene graph from
* being updated. This means the calculation returned MAY be out of date BUT will give you a
* nice performance boost
* @return The updated point
*/
getGlobalPosition(point?: Point, skipUpdate?: boolean): Point;
// end extras.getGlobalPosition
// begin accessible target
accessible: boolean;
accessibleTitle: string | null;
accessibleHint: string | null;
tabIndex: number;
// end accessible target
// begin interactive target
interactive: boolean;
interactiveChildren: boolean;
hitArea: PIXI.Rectangle | PIXI.Circle | PIXI.Ellipse | PIXI.Polygon | PIXI.RoundedRectangle | PIXI.HitArea;
buttonMode: boolean;
cursor: string;
trackedPointers: { [key: number]: interaction.InteractionTrackingData };
// Deprecated
/** @deprecated */
defaultCursor: string;
// end interactive target
transform: TransformBase;
alpha: number;
visible: boolean;
renderable: boolean;
parent: Container;
worldAlpha: number;
filterArea: Rectangle | null;
protected _filters: Array<Filter<any>> | null;
protected _enabledFilters: Array<Filter<any>> | null;
protected _bounds: Bounds;
protected _boundsID: number;
protected _lastBoundsID: number;
protected _boundsRect: Rectangle;
protected _localBoundsRect: Rectangle;
protected _mask: PIXI.Graphics | PIXI.Sprite | null;
protected readonly _destroyed: boolean;
x: number;
y: number;
worldTransform: Matrix;
localTransform: Matrix;
position: Point | ObservablePoint;
scale: Point | ObservablePoint;
pivot: Point | ObservablePoint;
skew: ObservablePoint;
rotation: number;
worldVisible: boolean;
mask: PIXI.Graphics | PIXI.Sprite | null;
filters: Array<Filter<any>> | null;
/**
* Updates the object transform for rendering
*
* TODO - Optimization pass!
*/
updateTransform(): void;
protected displayObjectUpdateTransform(): void;
/**
* recursively updates transform of all objects from the root to this one
* internal function for toLocal()
*/
protected _recursivePostUpdateTransform(): void;
/**
* Retrieves the bounds of the displayObject as a rectangle object.
*
* @param skipUpdate - setting to true will stop the transforms of the scene graph from
* being updated. This means the calculation returned MAY be out of date BUT will give you a
* nice performance boost
* @param rect - Optional rectangle to store the result of the bounds calculation
* @return the rectangular bounding area
*/
getBounds(skipUpdate?: boolean, rect?: Rectangle): Rectangle;
/**
* Retrieves the local bounds of the displayObject as a rectangle object
*
* @param [rect] - Optional rectangle to store the result of the bounds calculation
* @return the rectangular bounding area
*/
getLocalBounds(rect?: Rectangle): Rectangle;
/**
* Calculates the global position of the display object
*
* @param position - The world origin to calculate from
* @param [point] - A Point object in which to store the value, optional
* (otherwise will create a new Point)
* @param [skipUpdate=false] - Should we skip the update transform.
* @return A point object representing the position of this object
*/
toGlobal(position: PointLike): Point;
/**
* Calculates the global position of the display object
*
* @param position - The world origin to calculate from
* @param [point] - A Point object in which to store the value, optional
* (otherwise will create a new Point)
* @param [skipUpdate=false] - Should we skip the update transform.
* @return A point object representing the position of this object
*/
toGlobal<T extends PointLike>(position: PointLike, point?: T, skipUpdate?: boolean): T;
//creates and returns a new point
toLocal(position: PointLike, from?: DisplayObject): Point;
/**
* Calculates the local position of the display object relative to another point
*
* @param position - The world origin to calculate from
* @param [from] - The DisplayObject to calculate the global position from
* @param [point] - A Point object in which to store the value, optional
* (otherwise will create a new Point)
* @param [skipUpdate=false] - Should we skip the update transform
* @return A point object representing the position of this object
*/
toLocal<T extends PointLike>(position: PointLike, from?: DisplayObject, point?: T, skipUpdate?: boolean): T;
/**
* Renders the object using the WebGL renderer
*
* @param renderer - The renderer
*/
renderWebGL(renderer: WebGLRenderer): void;
renderCanvas(renderer: CanvasRenderer): void;
setParent(container: Container): Container;
/**
* Convenience function to set the position, scale, skew and pivot at once.
*
* @param [x=0] - The X position
* @param [y=0] - The Y position
* @param [scaleX=1] - The X scale value
* @param [scaleY=1] - The Y scale value
* @param [rotation=0] - The rotation
* @param [skewX=0] - The X skew value
* @param [skewY=0] - The Y skew value
* @param [pivotX=0] - The X pivot value
* @param [pivotY=0] - The Y pivot value
* @return The DisplayObject instance
*/
setTransform(
x?: number,
y?: number,
scaleX?: number,
scaleY?: number,
rotation?: number,
skewX?: number,
skewY?: number,
pivotX?: number,
pivotY?: number
): DisplayObject;
/**
* Base destroy method for generic display objects. This will automatically
* remove the display object from its parent Container as well as remove
* all current event listeners and internal references. Do not use a DisplayObject
* after calling `destroy`.
*/
destroy(): void;
on(
event: interaction.InteractionEventTypes,
fn: (event: interaction.InteractionEvent) => void,
context?: any
): this;
on(event: string | symbol, fn: (...args: any[]) => any, context?: any): this;
once(
event: interaction.InteractionEventTypes,
fn: (event: interaction.InteractionEvent) => void,
context?: any
): this;
once(event: string | symbol, fn: (...args: any[]) => any, context?: any): this;