1.0.2 • Published 7 years ago
texture2cube v1.0.2
Texure2Cube
Generate a cube like image from three textures without canvas, which could allow a server side system to do this work.
Texture2Cube uses ndarray to load image data, then use this data to transform the textures.
usage
Install and import it as a module.
npm i texture2cube Here shows a basic example:
var CubeImage = require('texture2cube');
var cubeImage = new CubeImage({
top: 'texture_top.png',
left: 'texture_left.png',
rignt: 'texture_right.png',
})
cubeImage.toPng('./cube.png');API
Constructor
constructor accepts five inputs:
left: left textureright: right texturetop: top texturescale: (optional)scale the output imageinfo: (optional)can pass some data and get bycubeImage.getPixels
Output
cubeImage.toCanvas(element): append a canvas to element.cubeImage.toCanvas(): append a canvas to bodycubeImage.toPng('result.png')output to a png filecubeImage.getPixels(callback(pixels, info)): pixels are the ndarray type of the result image data, info is the data from constructor.