Module Texture-PIXI

class type _t = { ... }
type t = Js.t(_t);

Various GL target types

module Impl: { ... };
include PIXI.EventEmitter.Impl;
let create: unit => PIXI.EventEmitter.t;
let eventNames: Js.t(PIXI.EventEmitter._t) => array(string);
let listeners: Js.t(PIXI.EventEmitter._t) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => array((Js.t({.. }) => unit));
let listenerCount: Js.t(PIXI.EventEmitter._t) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => int;
let emit: Js.t(PIXI.EventEmitter._t) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => bool;
let on: Js.t(PIXI.EventEmitter._t as 'd) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => fn:('b => unit) => ?⁠context:'c => unit => Js.t('d);
let addListener: Js.t(PIXI.EventEmitter._t as 'd) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => fn:('b => unit) => ?⁠context:'c => unit => Js.t('d);
let once: Js.t(PIXI.EventEmitter._t as 'd) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => fn:('b => unit) => ?⁠context:'c => unit => Js.t('d);
let removeListener: Js.t(PIXI.EventEmitter._t as 'b) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => ?⁠fn:(Js.t({.. }) => unit) => ?⁠context:Js.t({.. }) => ?⁠once:bool => unit => Js.t('b);
let off: Js.t(PIXI.EventEmitter._t as 'b) => event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => ?⁠fn:(Js.t({.. }) => unit) => ?⁠context:Js.t({.. }) => ?⁠once:bool => unit => Js.t('b);
let removeAllListeners: Js.t(PIXI.EventEmitter._t as 'b) => ?⁠event:[ `String(string) | `Symbol(PIXI.Symbol.t) ] => unit => Js.t('b);
include Impl;
let empty: Js.t(_t);

An empty texture, used often to not have to create multiple empty textures. Can not be destroyed.

let white: Js.t(_t);

A white texture of 16x16 size, used for graphics and other things Can not be destroyed.

let create: baseTexture:PIXI.BaseTexture.t => ?⁠frame:PIXI.Rectangle.t => ?⁠orig:PIXI.Rectangle.t => ?⁠trim:PIXI.Rectangle.t => ?⁠rotate:float => ?⁠anchor:PIXI.Point.t => unit => t;

creates new texture

parameter baseTexture

The base texture source to create the texture from

parameter frame

The rectangle frame of the texture to show

parameter orig

The area of original texture

parameter trim

Trimmed rectangle of original texture

parameter rotate

indicates how the texture was rotated by texture packer

parameter achor

Default anchor point used for sprite placement / rotation

let get_frame: Js.t(_t) => Js.t(PIXI.Rectangle.#_t);

This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

let set_frame: Js.t(_t) => Js.t(PIXI.Rectangle.#_t) => unit;

This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

let getBaseTexture: Js.t(_t) => Js.t(PIXI.C1.#baseTexture);

The base texture that this texture uses

let setBaseTexture: Js.t(_t) => Js.t(PIXI.C1.#baseTexture) => unit;

The base texture that this texture uses

let getDefaultAnchor: Js.t(_t) => Js.t(PIXI.Point.#_t);

Anchor point that is used as default if sprite is created with this texture. Changing the defaultAnchor at a later point of time will not update Sprite's anchor point.

let setDefaultAnchor: Js.t(_t) => Js.t(PIXI.Point.#_t) => unit;

Anchor point that is used as default if sprite is created with this texture. Changing the defaultAnchor at a later point of time will not update Sprite's anchor point.

let getFrame: Js.t(_t) => Js.t(PIXI.Rectangle.#_t);

The frame specifies the region of the base texture that this texture uses. Please call updateUvs() after you change coordinates of frame manually.

let setFrame: Js.t(_t) => Js.t(PIXI.Rectangle.#_t) => unit;

The frame specifies the region of the base texture that this texture uses. Please call updateUvs() after you change coordinates of frame manually.

let getHeight: Js.t(_t) => float;

The height of the Texture in pixels

let setHeight: Js.t(_t) => float => unit;

The height of the Texture in pixels

let getNoFrame: Js.t(_t) => bool;

Does this Texture have any frame data assigned to it? This mode is enabled automatically if no frame was passed inside constructor. In this mode texture is subscribed to baseTexture events, and fires update on any change. Beware, after loading or resize of baseTexture event can fired two times! If you want more control, subscribe on baseTexture itself. Any assignment of frame switches off noFrame mode.

let setNoFrame: Js.t(_t) => bool => unit;

Does this Texture have any frame data assigned to it? This mode is enabled automatically if no frame was passed inside constructor. In this mode texture is subscribed to baseTexture events, and fires update on any change. Beware, after loading or resize of baseTexture event can fired two times! If you want more control, subscribe on baseTexture itself. Any assignment of frame switches off noFrame mode.

let getOrig: Js.t(_t) => Js.t(PIXI.Rectangle.#_t);

This is the area of original texture, before it was put in atlas

let setOrig: Js.t(_t) => Js.t(PIXI.Rectangle.#_t) => unit;

This is the area of original texture, before it was put in atlas

let getRequiresUpdate: Js.t(_t) => Js.t(PIXI.Rectangle.#_t);

This will let a renderer know that a texture has been updated (used mainly for WebGL uv updates)

let setRequiresUpdate: Js.t(_t) => Js.t(PIXI.Rectangle.#_t) => unit;

This will let a renderer know that a texture has been updated (used mainly for WebGL uv updates)

let getResolution: Js.t(_t) => float;

Returns resolution of baseTexture

let setResolution: Js.t(_t) => float => unit;

Returns resolution of baseTexture

let getRotate: Js.t(_t) => float;

Indicates whether the texture is rotated inside the atlas set to 2 to compensate for texture packer rotation set to 6 to compensate for spine packer rotation can be used to rotate or mirror sprites See PIXI.groupD8 for explanation

let setRotate: Js.t(_t) => float => unit;

Indicates whether the texture is rotated inside the atlas set to 2 to compensate for texture packer rotation set to 6 to compensate for spine packer rotation can be used to rotate or mirror sprites See PIXI.groupD8 for explanation

let getTextureCacheIds: Js.t(_t) => array(string);

The ids under which this Texture has been added to the texture cache. This is automatically set as long as Texture.addToCache is used, but may not be set if a Texture is added directly to the TextureCache array

let setTextureCacheIds: Js.t(_t) => array(string) => unit;

The ids under which this Texture has been added to the texture cache. This is automatically set as long as Texture.addToCache is used, but may not be set if a Texture is added directly to the TextureCache array.

let getTrim: Js.t(_t) => Js.t(PIXI.Rectangle.#_t);

This is the trimmed area of original texture, before it was put in atlas Please call updateUvs() after you change coordinates of trim manually

let setTrim: Js.t(_t) => Js.t(PIXI.Rectangle.#_t) => unit;

This is the trimmed area of original texture, before it was put in atlas Please call updateUvs() after you change coordinates of trim manually

let getUvMatrix: Js.t(_t) => PIXI.TextureMatrix.t;

Default TextureMatrix instance for this texture By default that object is not created because its heavy

let setUvMatrix: Js.t(_t) => PIXI.TextureMatrix.t => unit;

Default TextureMatrix instance for this texture By default that object is not created because its heavy

let getValid: Js.t(_t) => float;

This will let the renderer know if the texture is valid. If it's not then it cannot be rendered

let setValid: Js.t(_t) => float => unit;

This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.

let getWidth: Js.t(_t) => float;

The width of the Texture in pixels

let setWidth: Js.t(_t) => float => unit;

The width of the Texture in pixels

let addToCache: texture:Js.t(_t) => id:string => unit;

Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object.

parameter texture

The Texture to add to the cache

parameter id

The id that the Texture will be stored against

let from: ?⁠source:[ `String(string) | `HtmlImageElement(Webapi.Dom.HtmlImageElement.t) | `HtmlCanvasElement(Webapi.Dom.HtmlElement.t) | `HtmlVideoElement(Webapi.Dom.HtmlElement.t) | `BaseTexture(PIXI.BaseTexture.t) ] => ?⁠options:'a => ?⁠strict:bool => unit => Js.t(_t);

Helper function that creates a new Texture based on the source you provide. The source can be - frame id, image url, video url, canvas element, video element, base texture

see /bs-pixi/PIXI/BaseTexture-PIXI/#val-createOptions

BaseTexture.createOptions

parameter source

Source to create texture from

parameter options

options

parameter strict

Enforce strict-mode, see PIXI.settings.STRICT_TEXTURE_CACHE

returns

The newly created texture

let fromBuffer: buffer:[ `Float32Array(Js.Typed_array.Float32Array.t) | `UInt8Array(Js.Typed_array.Uint8Array.t) ] => width:float => height:float => ?⁠options:'a => unit => Js.t(_t);

Create a new Texture with a BufferResource from a Float32Array. RGBA values are floats from 0 to 1.

see /bs-pixi/PIXI/BaseTexture-PIXI/#val-createOptions

BaseTexture.createOptions

parameter buffer

The optional array to use, if no data is provided, a new Float32Array is created

parameter width

Width of the resource

parameter height

Height of the resource

parameter options

See PIXI.BaseTexture's constructor for options

returns

The newly created texture

let fromLoader: source:[ `HTMLImageElement(Webapi.Dom.HtmlImageElement.t) | `HTMLCanvasElement(Webapi.Dom.HtmlElement.t) ] => imageUrl:string => ?⁠name:string => unit => Js.t(_t);

Create a texture from a source and add to the cache

parameter source

Create a texture from a source and add to the cache.

parameter imageUrl

File name of texture, for cache and resolving resolution

parameter name

Human readable name for the texture cache. If no name is specified, only imageUrl will be used as the cache ID.

returns

output texture

let removeFromCache: texture:[ `Texture(t) | `String(string) ] => Js.Nullable.t(Js.t(_t));

Remove a Texture from the global TextureCache

parameter texture

id of a Texture to be removed, or a Texture instance itself

returns

The Texture that was removed

let clone: Js.t(_t) => unit;

Creates a new texture object that acts the same as this one

returns

the new texture

let destroy: Js.t(_t) => ?⁠destroyBase:bool => unit => unit;

Destroys this texture

parameter destroyBase

Whether to destroy the base texture as well

let update: Js.t(_t) => unit;

Updates this texture on the gpu. Calls the TextureResource update. If you adjusted frame manually, please call updateUvs() instead.

let updateUvs: Js.t(_t) => unit;

Updates the internal WebGL UV cache. Use it after you change frame or trim of the texture. Call it after changing the frame