Convert a WebGL context's canvas' pixel data into an image, and write that image to a writable stream. Meant to be used in Node.js
This module is meant to help with testing WebGL components.
Say you have a WebGL component that takes your canvas' WebGL context and a model view matrix and draws
a fire particle effect at a location of your choice. You can verify that that works by rendering it in node
(using something like
require('gl')) and then writing your rendering to a
.png file on your file system
webgl-to-img-stream. You can then use something like
image-diff to make sure that your new
file matches the one that you expect.
$ npm install --save webgl-to-img-stream
var webGlToImgStream =var fs =var canvasWidth = 128var canvasHeight = 128var gl = canvasWidth canvasHeight// ... do whatever you want with your WebGL context ...var outputFile = fs// Your canvas's contents have now been saved to your file system