texture-atlas
atlaspack rewritten in TypeScript with some API changes.
API changes
Most of this API changes are meant to promote type consistency.
Use ES6 module
// Import module // es6; // commonjsconst Atlas = Atlas; // Create an instance const canvas = ;const atlas = canvas;
No factory function
Create an instance using new
operator.
new Atlas(canvas[, options])
canvas
HTMLCanvasElement A canvas element to store atlas.options
Objecttilepad
Boolean If true, each packed image pads itself with a tiled pattern of itself. Useful for avoiding texture bleeding when mipmapping.
Atlas#pack(id, drawable)
id
string texture id. used byAtlas#uv
andAtlas#uv2
.drawable
HTMLImageElement | HTMLCanvasElement texture image.Altas#pack
returnsnull
on failure.
Atlas#expand(id, drawable)
id
string texture id. used byAtlas#uv
andAtlas#uv2
.drawable
HTMLImageElement | HTMLCanvasElement texture image.Altas#expand
does not return a new Atlas instance. It mutates the calling instance.
Atlas#uv()
Atlas#uv
does not receive any parameter. It usesaltas.canvas
width and height.
Atlas#uv2()
Atlas#uv2
returns uv inFloat32Array
format. ( shape = [4, 2], stride = [2, 1] )
const uv1 = atlas'my_awesome_uv';const uv2 = atlas'my_awesome_uv'; ;;;;;;;;
Atlas#json
Atlas#json
has been removed.
Atlas#_debug
Atlas#_debug
has been moved intoutils
namespace.
; ;
install
$ npm install texture-atlas
Development
Build
$ npm run build$ npm run build:watch
Test
$ npm test
Run example
$ npm run start:example
Credits
Kyle Robinson Young (@shama) for code from atlaspack
License
MIT