mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Merge pull request #21325 from clark-stevenson/master
Update pixi.js to 4.6
This commit is contained in:
65
types/pixi.js/index.d.ts
vendored
65
types/pixi.js/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Pixi.js 4.5
|
||||
// Type definitions for Pixi.js 4.6
|
||||
// Project: https://github.com/pixijs/pixi.js/tree/dev
|
||||
// Definitions by: clark-stevenson <https://github.com/pixijs/pixi-typescript>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -372,7 +372,7 @@ declare namespace PIXI {
|
||||
on(event: interaction.InteractionEventTypes, fn: (event: interaction.InteractionEvent) => void, context?: any): this;
|
||||
once(event: interaction.InteractionEventTypes, fn: (event: interaction.InteractionEvent) => void, context?: any): this;
|
||||
removeListener(event: interaction.InteractionEventTypes, fn?: (event: interaction.InteractionEvent) => void, context?: any): this;
|
||||
removeAllListeners(event: interaction.InteractionEventTypes): 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;
|
||||
}
|
||||
@@ -875,7 +875,7 @@ declare namespace PIXI {
|
||||
on(event: "prerender" | "postrender", fn: () => void, context?: any): this;
|
||||
once(event: "prerender" | "postrender", fn: () => void, context?: any): this;
|
||||
removeListener(event: "prerender" | "postrender", fn?: () => void, context?: any): this;
|
||||
removeAllListeners(event: "prerender" | "postrender"): this;
|
||||
removeAllListeners(event?: "prerender" | "postrender"): this;
|
||||
off(event: "prerender" | "postrender", fn?: () => void, context?: any): this;
|
||||
addListener(event: "prerender" | "postrender", fn: () => void, context?: any): this;
|
||||
}
|
||||
@@ -977,7 +977,7 @@ declare namespace PIXI {
|
||||
once(event: "context", fn: (gl: WebGLRenderingContext) => void, context?: any): this;
|
||||
removeListener(event: "prerender" | "postrender", fn?: () => void, context?: any): this;
|
||||
removeListener(event: "context", fn?: (gl: WebGLRenderingContext) => void, context?: any): this;
|
||||
removeAllListeners(event: "prerender" | "postrender" | "context"): this;
|
||||
removeAllListeners(event?: "prerender" | "postrender" | "context"): this;
|
||||
off(event: "prerender" | "postrender", fn?: () => void, context?: any): this;
|
||||
off(event: "context", fn?: (gl: WebGLRenderingContext) => void, context?: any): this;
|
||||
addListener(event: "prerender" | "postrender", fn: () => void, context?: any): this;
|
||||
@@ -1485,7 +1485,7 @@ declare namespace PIXI {
|
||||
on(event: "update", fn: (baseRenderTexture: BaseRenderTexture) => void, context?: any): this;
|
||||
once(event: "update", fn: (baseRenderTexture: BaseRenderTexture) => void, context?: any): this;
|
||||
removeListener(event: "update", fn?: (baseRenderTexture: BaseRenderTexture) => void, context?: any): this;
|
||||
removeAllListeners(event: "update"): this;
|
||||
removeAllListeners(event?: "update"): this;
|
||||
off(event: "update", fn?: (baseRenderTexture: BaseRenderTexture) => void, context?: any): this;
|
||||
addListener(event: "update", fn: (baseRenderTexture: BaseRenderTexture) => void, context?: any): this;
|
||||
}
|
||||
@@ -1542,7 +1542,7 @@ declare namespace PIXI {
|
||||
on(event: "update" | "loaded" | "error" | "dispose", fn: (baseTexture: BaseTexture) => void, context?: any): this;
|
||||
once(event: "update" | "loaded" | "error" | "dispose", fn: (baseTexture: BaseTexture) => void, context?: any): this;
|
||||
removeListener(event: "update" | "loaded" | "error" | "dispose", fn?: (baseTexture: BaseTexture) => void, context?: any): this;
|
||||
removeAllListeners(event: "update" | "loaded" | "error" | "dispose"): this;
|
||||
removeAllListeners(event?: "update" | "loaded" | "error" | "dispose"): this;
|
||||
off(event: "update" | "loaded" | "error" | "dispose", fn?: (baseTexture: BaseTexture) => void, context?: any): this;
|
||||
addListener(event: "update" | "loaded" | "error" | "dispose", fn: (baseTexture: BaseTexture) => void, context?: any): this;
|
||||
}
|
||||
@@ -1568,7 +1568,7 @@ declare namespace PIXI {
|
||||
protected _uvs: TextureUvs;
|
||||
orig: Rectangle;
|
||||
protected _updateID: number;
|
||||
transform: any;
|
||||
transform: TextureMatrix;
|
||||
textureCacheIds: string[];
|
||||
|
||||
update(): void;
|
||||
@@ -1576,7 +1576,7 @@ declare namespace PIXI {
|
||||
protected onBaseTextureUpdated(baseTexture: BaseTexture): void;
|
||||
destroy(destroyBase?: boolean): void;
|
||||
clone(): Texture;
|
||||
protected _updateUvs(): void;
|
||||
_updateUvs(): void;
|
||||
|
||||
static fromImage(imageUrl: string, crossOrigin?: boolean, scaleMode?: number, sourceScale?: number): Texture;
|
||||
static fromFrame(frameId: string): Texture;
|
||||
@@ -1604,10 +1604,27 @@ declare namespace PIXI {
|
||||
on(event: "update", fn: (texture: Texture) => void, context?: any): this;
|
||||
once(event: "update", fn: (texture: Texture) => void, context?: any): this;
|
||||
removeListener(event: "update", fn?: (texture: Texture) => void, context?: any): this;
|
||||
removeAllListeners(event: "update"): this;
|
||||
removeAllListeners(event?: "update"): this;
|
||||
off(event: "update", fn?: (texture: Texture) => void, context?: any): this;
|
||||
addListener(event: "update", fn: (texture: Texture) => void, context?: any): this;
|
||||
}
|
||||
class TextureMatrix {
|
||||
constructor(texture: Texture, clampMargin?: number);
|
||||
|
||||
protected _texture: Texture;
|
||||
mapCoord: Matrix;
|
||||
uClampFrame: Float32Array;
|
||||
uClampOffset: Float32Array;
|
||||
protected _lastTextureID: number;
|
||||
|
||||
clampOffset: number;
|
||||
clampMargin: number;
|
||||
|
||||
texture: Texture;
|
||||
|
||||
update(forceUpdate?: boolean): boolean;
|
||||
multiplyUvs(uvs: Float32Array, out?: Float32Array): Float32Array;
|
||||
}
|
||||
class TextureUvs {
|
||||
x0: number;
|
||||
y0: number;
|
||||
@@ -1833,7 +1850,7 @@ declare namespace PIXI {
|
||||
static fromFrames(frame: string[]): AnimatedSprite;
|
||||
static fromImages(images: string[]): AnimatedSprite;
|
||||
}
|
||||
class TextureTransform {
|
||||
class TextureMatrix {
|
||||
constructor(texture: Texture, clampMargin?: number);
|
||||
|
||||
protected _texture: Texture;
|
||||
@@ -1857,7 +1874,7 @@ declare namespace PIXI {
|
||||
protected _width: number;
|
||||
protected _height: number;
|
||||
protected _canvasPattern: CanvasPattern;
|
||||
uvTransform: TextureTransform;
|
||||
uvTransform: TextureMatrix;
|
||||
uvRespectAnchor: boolean;
|
||||
|
||||
clampMargin: number;
|
||||
@@ -1986,6 +2003,8 @@ declare namespace PIXI {
|
||||
map: Texture;
|
||||
}
|
||||
class AlphaFilter extends Filter<{}> {
|
||||
constructor(alpha?: number);
|
||||
|
||||
alpha: number;
|
||||
glShaderKey: number;
|
||||
}
|
||||
@@ -2409,7 +2428,7 @@ declare namespace PIXI {
|
||||
texture: Texture;
|
||||
tintRgb: Float32Array;
|
||||
protected _glDatas: { [n: number]: any; };
|
||||
protected _uvTransform: extras.TextureTransform;
|
||||
protected _uvTransform: extras.TextureMatrix;
|
||||
uploadUvTransform: boolean;
|
||||
multiplyUvs(): void;
|
||||
refresh(forceUpdate?: boolean): void;
|
||||
@@ -2642,7 +2661,7 @@ declare namespace PIXI {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////pixi-gl-core/////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// pixi-gl-core https://github.com/pixijs/pixi-gl-core
|
||||
// pixi-gl-core 1.1.2 https://github.com/pixijs/pixi-gl-core
|
||||
// sharedArrayBuffer as a type is not available yet.
|
||||
// need to fully define what an `Attrib` is.
|
||||
namespace glCore {
|
||||
@@ -2727,7 +2746,7 @@ declare namespace PIXI {
|
||||
uniforms: any;
|
||||
attributes: any;
|
||||
|
||||
bind(): void;
|
||||
bind(): this;
|
||||
destroy(): void;
|
||||
}
|
||||
class GLTexture {
|
||||
@@ -3203,6 +3222,15 @@ declare namespace PIXI {
|
||||
type PRECISION = string;
|
||||
}
|
||||
|
||||
namespace GroupD8 {
|
||||
/**
|
||||
* @name PIXI.GroupD8.isSwapWidthHeight
|
||||
* @see PIXI.GroupD8.isVertical
|
||||
* @deprecated since version 4.6.0
|
||||
*/
|
||||
function isSwapWidthHeight(rotation: number): boolean;
|
||||
}
|
||||
|
||||
namespace extras {
|
||||
/**
|
||||
* @class
|
||||
@@ -3212,6 +3240,15 @@ declare namespace PIXI {
|
||||
* @deprecated since version 4.2.0
|
||||
*/
|
||||
type MovieClip = extras.AnimatedSprite;
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @name TextureTransform
|
||||
* @memberof PIXI.extras
|
||||
* @see PIXI.TextureMatrix
|
||||
* @deprecated since version 4.6.0
|
||||
*/
|
||||
type TextureTranform = TextureMatrix;
|
||||
}
|
||||
|
||||
namespace filters {
|
||||
|
||||
@@ -1235,6 +1235,67 @@ function demos() {
|
||||
}
|
||||
}
|
||||
|
||||
class TextureRotate {
|
||||
private app: PIXI.Application;
|
||||
private bol: boolean;
|
||||
private texture: PIXI.Texture;
|
||||
private secondTexture: PIXI.Texture;
|
||||
private dude: PIXI.Sprite;
|
||||
|
||||
constructor() {
|
||||
this.app = new PIXI.Application();
|
||||
document.body.appendChild(this.app.view);
|
||||
|
||||
this.bol = false;
|
||||
|
||||
PIXI.loader.add("flowerTop", "required/assets/flowerTop.png");
|
||||
PIXI.loader.load((loader: PIXI.loaders.Loader, resources: any) => {
|
||||
this.texture = resources.flowerTop.texture;
|
||||
this.init();
|
||||
});
|
||||
}
|
||||
|
||||
private init(): void {
|
||||
const textures = [this.texture];
|
||||
const D8 = PIXI.GroupD8;
|
||||
for (let rotate = 1; rotate < 16; rotate++) {
|
||||
const h = D8.isVertical(rotate) ? this.texture.frame.width : this.texture.frame.height;
|
||||
const w = D8.isVertical(rotate) ? this.texture.frame.height : this.texture.frame.width;
|
||||
|
||||
const frame = this.texture.frame;
|
||||
const crop = new PIXI.Rectangle(this.texture.frame.x, this.texture.frame.y, w, h);
|
||||
const trim = crop;
|
||||
let rotatedTexture: PIXI.Texture;
|
||||
if (rotate % 2 === 0) {
|
||||
rotatedTexture = new PIXI.Texture(this.texture.baseTexture, frame, crop, trim, rotate);
|
||||
} else {
|
||||
rotatedTexture = new PIXI.Texture(this.texture.baseTexture, frame, crop, trim, rotate - 1);
|
||||
rotatedTexture.rotate++;
|
||||
}
|
||||
textures.push(rotatedTexture);
|
||||
}
|
||||
|
||||
const offsetX = this.app.renderer.width / 16 | 0;
|
||||
const offsetY = this.app.renderer.height / 8 | 0;
|
||||
const gridW = this.app.renderer.width / 4 | 0;
|
||||
const gridH = this.app.renderer.height / 5 | 0;
|
||||
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const dude = new PIXI.Sprite(textures[i < 8 ? i * 2 : (i - 8) * 2 + 1]);
|
||||
dude.scale.x = 0.5;
|
||||
dude.scale.y = 0.5;
|
||||
dude.x = offsetX + gridW * (i % 4);
|
||||
dude.y = offsetY + gridH * (i / 4 | 0);
|
||||
this.app.stage.addChild(dude);
|
||||
|
||||
const text = new PIXI.Text("rotate = " + dude.texture.rotate, { fontFamily: "Courier New", fontSize: "12px", fill: "white", align: "left" });
|
||||
text.x = dude.x;
|
||||
text.y = dude.y - 20;
|
||||
this.app.stage.addChild(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TextureSwap {
|
||||
private app: PIXI.Application;
|
||||
private bol: boolean;
|
||||
|
||||
Reference in New Issue
Block a user