Array2D.js canvas demonstration
var canvas = demo.canvas; var w = demo.width; var h = demo.height; // Convert a row-column coordinate to a value. function coordinateToCell(r, c) { return r * c % 255; } // Convert a cell's value to a color array. function cellToPixel(cell) { return [cell, cell, cell, 255]; // [r,g,b,a] } var grid = Array2D.buildWith(w, h, coordinateToCell); Array2D.toCanvas(grid, canvas, cellToPixel);
Evaluate
API reference →
Source code on GitHub →
Copyright © 2014 Matthew Trost