texcoord
Get a [u1, v1, u2, v2]
texture coordinate region from the given bounds. Best suited for rendering with top left texture coordinates.
//sprite boundsvar position = 0 0var size = 64 64 //atlas dimensionsvar atlasSize = 1024 1024 var t = // [ 0, 0, 0.0625, 0.0625 ] var def = // [0, 0, 1, 1]
Usage
texcoord([position, shape, texShape, out])
Returns a [u1, v1, u2, v2]
array with texture coordinates (typically 0.0 to 1.0) based on the given regions. All arguments are optional.
positions
the [x,y] position for our spriteshape
the [width,height] sprite sizetexShape
the [width,height] for our atlas (defaults to sprite size)out
if specified, the result will be stored in this array rather than creating a new one
If no arguments are specified, the return will be [0, 0, 1, 1]
(i.e. "use full atlas").
License
MIT, see LICENSE.md for details.