caravan-x
Version:
A terminal-based utility for managing Caravan multisig wallets in regtest mode. This tool simplifies development and testing with Caravan by providing an easy-to-use interface
1,560 lines (1,511 loc) • 177 kB
TypeScript
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;
removeListener(
event: interaction.InteractionEventTypes,
fn?: (event: interaction.InteractionEvent) => void,
context?: any,
): this;
removeAllListeners(event?: interaction.InteractionEventTypes): this;
off(
event: interaction.InteractionEventTypes,
fn?: (event: interaction.InteractionEvent) => void,
context?: any,
): this;
addListener(
event: interaction.InteractionEventTypes,
fn: (event: interaction.InteractionEvent) => void,
context?: any,
): this;
}
/**
* Generic class to deal with traditional 2D matrix transforms
*/
class TransformBase {
static IDENTITY: TransformBase;
worldTransform: Matrix;
localTransform: Matrix;
protected _worldID: number;
protected _parentID: number;
/**
* Updates only local matrix
*/
updateLocalTransform(): void;
/**
* Updates the values of the object and applies the parent"s transform.
*
* @param parentTransform - The transform of the parent of this object
*/
updateTransform(parentTransform: TransformBase): void;
updateWorldTransform(parentTransform: TransformBase): void;
}
/**
* Transform that takes care about its versions
*/
class TransformStatic extends TransformBase {
position: ObservablePoint;
scale: ObservablePoint;
pivot: ObservablePoint;
skew: ObservablePoint;
protected _rotation: number;
protected _sr?: number;
protected _cr?: number;
protected _cy?: number;
protected _sy?: number;
protected _sx?: number;
protected _cx?: number;
protected _localID: number;
protected _currentLocalID: number;
protected onChange(): void;
updateSkew(): void;
/**
* Decomposes a matrix and sets the transforms properties based on it.
*
* @param matrix - The matrix to decompose
*/
setFromMatrix(matrix: Matrix): void;
rotation: number;
}
/**
* Generic class to deal with traditional 2D matrix transforms
* local transformation is calculated from position,scale,skew and rotation
*/
class Transform extends TransformBase {
constructor();
position: Point;
scale: Point;
skew: ObservablePoint;
pivot: Point;
protected _rotation: number;
protected _sr?: number;
protected _cr?: number;
protected _cy?: number;
protected _sy?: number;
protected _sx?: number;
protected _cx?: number;
updateSkew(): void;
/**
* Decomposes a matrix and sets the transforms properties based on it.
*
* @param matrix - The matrix to decompose
*/
setFromMatrix(matrix: Matrix): void;
rotation: number;
}
// graphics
/**
* A GraphicsData object.
*/
class GraphicsData {
constructor(
lineWidth: number,
lineColor: number,
lineAlpha: number,
fillColor: number,
fillAlpha: number,
fill: boolean,
nativeLines: boolean,
shape: Circle | Rectangle | Ellipse | Polygon | RoundedRectangle | any,
lineAlignment?: number,
);
lineWidth: number;
lineAlignment: number;
nativeLines: boolean;
lineColor: number;
lineAlpha: number;
protected _lineTint: number;
fillColor: number;
fillAlpha: number;
protected _fillTint: number;
fill: boolean;
protected holes:
| Circle[]
| Rectangle[]
| Ellipse[]
| Polygon[]
| RoundedRectangle[]
| any[];
shape: Circle | Rectangle | Ellipse | Polygon | RoundedRectangle | any;
type?: number;
/**
* Creates a new GraphicsData object with the same values as this one.
*
* @return Cloned GraphicsData object
*/
clone(): GraphicsData;
/**
* Adds a hole to the shape.
*
* @param shape - The shape of the hole.
*/
addHole(
shape: Circle | Rectangle | Ellipse | Polygon | RoundedRectangle | any,
): void;
/**
* Destroys the Graphics data.
*/
destroy(options?: DestroyOptions | boolean): void;
}
/**
* The Graphics class contains methods used to draw primitive shapes such as lines, circles and
* rectangles to the display, and to color and fill them.
*/
class Graphics extends Container {
/**
* Graphics curves resolution settings. If `adaptive` flag is set to `true`,
* the resolution is calculated based on the curve"s length to ensure better visual quality.
* Adaptive draw works with `bezierCurveTo` and `quadraticCurveTo`.
*
* @property {boolean} adaptive=false - flag indicating if the resolution should be adaptive
* @property {number} maxLength=10 - maximal length of a single segment of the curve (if adaptive = false, ignored)
* @property {number} minSegments=8 - minimal number of segments in the curve (if adaptive = false, ignored)
* @property {number} maxSegments=2048 - maximal number of segments in the curve (if adaptive = false, ignored)
*/
static CURVES: {
adaptive: boolean;
maxLength: number;
minSegments: number;
maxSegments: number;
};
constructor(nativeLines?: boolean);
/**
* When cacheAsBitmap is set to true the graphics object will be rendered as if it was a sprite.
* This is useful if your graphics element does not change often, as it will speed up the rendering
* of the object in exchange for taking up texture memory. It is also useful if you need the graphics
* object to be anti-aliased, because it will be rendered using canvas. This is not recommended if
* you are constantly redrawing the graphics element.
*
* @default false
*/
cacheAsBitmap: boolean;
fillAlpha: number;
lineWidth: number;
nativeLines: boolean;
lineColor: number;
lineAlignment: number;
protected graphicsData: GraphicsData[];
tint: number;
protected _prevTint: number;
blendMode: number;
currentPath: GraphicsData;
protected _webGL: any;
isMask: boolean;
boundsPadding: number;
protected _localBounds: Bounds;
dirty: number;
canvasTintDirty: number;
fastRectDirty: number;
clearDirty: number;
boundsDirty: number;
protected cachedSpriteDirty: boolean;
protected _spriteRect: Rectangle;
protected _fastRect: boolean;
static _SPRITE_TEXTURE: Texture;
clone(): Graphics;
protected _quadraticCurveLength(
fromX: number,
fromY: number,
cpX: number,
cpY: number,
toX: number,
toY: number,
): number;
protected _bezierCurveLength(
fromX: number,
fromY: number,
cpX: number,
cpY: number,
cpX2: number,
cpY2: number,
toX: number,
toY: number,
): number;
protected _segmentsCount(length: number): number;
lineStyle(
lineWidth?: number,
color?: number,
alpha?: number,
alignment?: number,
): Graphics;
moveTo(x: number, y: number): Graphics;
lineTo(x: number, y: number): Graphics;
quadraticCurveTo(
cpX: number,
cpY: number,
toX: number,
toY: number,
): Graphics;
bezierCurveTo(
cpX: number,
cpY: number,
cpX2: number,
cpY2: number,
toX: number,
toY: number,
): Graphics;
arcTo(
x1: number,
y1: number,
x2: number,
y2: number,
radius: number,
): Graphics;
arc(
cx: number,
cy: number,
radius: number,
startAngle: number,
endAngle: number,
anticlockwise?: boolean,
): Graphics;
beginFill(color: number, alpha?: number): Graphics;
endFill(): Graphics;
drawRect(x: number, y: number, width: number, height: number): Graphics;
drawRoundedRect(
x: number,
y: number,
width: number,
height: number,
radius: number,
): Graphics;
drawCircle(x: number, y: number, radius: number): Graphics;
drawEllipse(x: number, y: number, width: number, height: number): Graphics;
drawPolygon(path: number[] | Point[] | Polygon): Graphics;
drawStar(
x: number,
y: number,
points: number,
radius: number,
innerRadius: number,
rotation?: number,
): Graphics;
clear(): Graphics;
isFastRect(): boolean;
protected _renderCanvas(renderer: CanvasRenderer): void;
protected _calculateBounds(): Rectangle;
protected _renderSpriteRect(renderer: PIXI.SystemRenderer): void;
containsPoint(point: Point): boolean;
updateLocalBounds(): void;
drawShape(
shape: Circle | Rectangle | Ellipse | Polygon | RoundedRectangle | any,
): GraphicsData;
generateCanvasTexture(scaleMode?: number, resolution?: number): Texture;
closePath(): Graphics;
addHole(): Graphics;
destroy(options?: DestroyOptions | boolean): void;
}
class CanvasGraphicsRenderer {
constructor(renderer: SystemRenderer);
render(graphics: Graphics): void;
protected updateGraphicsTint(graphics: Graphics): void;
protected renderPolygon(
points: Point[],
close: boolean,
context: CanvasRenderingContext2D,
): void;
destroy(): void;
}
/**
* Renders the graphics object.
*/
class GraphicsRenderer extends ObjectRenderer {
constructor(renderer: PIXI.CanvasRenderer);
protected graphicsDataPool: GraphicsData[];
protected primitiveShader: PrimitiveShader;
gl: WebGLRenderingContext;
CONTEXT_UID: number;
/**
* Destroys this renderer.
*/
destroy(): void;
/**
* Renders a graphics object.
*
* @param graphics - The graphics object to render.
*/
render(graphics: Graphics): void;
protected updateGraphics(graphics: PIXI.Graphics): void;
getWebGLData(
webGL: WebGLRenderingContext,
type: number,
nativeLines: number,
): WebGLGraphicsData;
}
class WebGLGraphicsData {
constructor(
gl: WebGLRenderingContext,
shader: glCore.GLShader,
attribsState: glCore.AttribState,
);
gl: WebGLRenderingContext;
color: number[];
points: Point[];
indices: number[];
buffer: WebGLBuffer;
indexBuffer: WebGLBuffer;
dirty: boolean;
glPoints: number[];
glIndices: number[];
shader: glCore.GLShader;
vao: glCore.VertexArrayObject;
nativeLines: boolean;
reset(): void;
upload(): void;
destroy(): void;
}
/**
* This shader is used to draw simple primitive shapes for {@link PIXI.Graphics}.
*/
class PrimitiveShader extends glCore.GLShader {}
// math
/**
* Implements Dihedral Group D_8, see [group D4]{@link http://mathworld.wolfram.com/DihedralGroupD4.html},
* D8 is the same but with diagonals. Used for texture rotations.
*
* Vector xX(i), xY(i) is U-axis of sprite with rotation i
* Vector yY(i), yY(i) is V-axis of sprite with rotation i
* Rotations: 0 grad (0), 90 grad (2), 180 grad (4), 270 grad (6)
* Mirrors: vertical (8), main diagonal (10), horizontal (12), reverse diagonal (14)
* This is the small part of gameofbombs.com portal system. It works.
*
* @author Ivan @ivanpopelyshev
* @class
* @memberof PIXI
*/
namespace GroupD8 {
const E: number;
const SE: number;
const S: number;
const SW: number;
const W: number;
const NW: number;
const N: number;
const NE: number;
const MIRROR_HORIZONTAL: number;
const MIRROR_VERTICAL: number;
function uX(ind: number): number;
function uY(ind: number): number;
function vX(ind: number): number;
function vY(ind: number): number;
function inv(rotation: number): number;
function add(rotationSecond: number, rotationFirst: number): number;
function sub(rotationSecond: number, rotationFirst: number): number;
/**
* Adds 180 degrees to rotation. Commutative operation.
*
* @param rotation - The number to rotate.
* @returns rotated number
*/
function rotate180(rotation: number): number;
/**
* Direction of main vector can be horizontal, vertical or diagonal.
* Some objects work with vertical directions different.
*
* @param rotation - The number to check.
* @returns Whether or not the direction is vertical
*/
function isVertical(rotation: number): boolean;
/**
* @param dx - TODO
* @param dy - TODO
*
* @return TODO
*/
function byDirection(dx: number, dy: number): number;
/**
* Helps sprite to compensate texture packer rotation.
*
* @param matrix - sprite world matrix
* @param rotation - The rotation factor to use.
* @param tx - sprite anchoring
* @param ty - sprite anchoring
*/
function matrixAppendRotationInv(
matrix: Matrix,
rotation: number,
tx: number,
ty: number,
): void;
}
/**
* The PixiJS Matrix class as an object, which makes it a lot faster,
* here is a representation of it :
* | a | c | tx|
* | b | d | ty|
* | 0 | 0 | 1 |
*/
class Matrix {
constructor(
a?: number,
b?: number,
c?: number,
d?: number,
tx?: number,
ty?: number,
);
a: number;
b: number;
c: number;
d: number;
tx: number;
ty: number;
/**
* Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
*
* a = array[0]
* b = array[1]
* c = array[3]
* d = array[4]
* tx = array[2]
* ty = array[5]
*
* @param {number[]} array - The array that the matrix will be populated from.
*/
fromArray(array: number[]): void;
/**
* sets the matrix properties
*
* @param a - Matrix component
* @param b - Matrix component
* @param c - Matrix component
* @param d - Matrix component
* @param tx - Matrix component
* @param ty - Matrix component
*
* @return This matrix. Good for chaining method calls.
*/
set(
a: number,
b: number,
c: number,
d: number,
tx: number,
ty: number,
): Matrix;
/**
* Creates an array from the current Matrix object.
*
* @param transpose - Whether we need to transpose the matrix or not
* @param [out=new Float32Array(9)] - If provided the array will be assigned to out
* @return the newly created array which contains the matrix
*/
toArray(transpose?: boolean, out?: number[]): number[];
/**
* Get a new position with the current transformation applied.
* Can be used to go from a child"s coordinate space to the world coordinate space. (e.g. rendering)
*