Simple DynImage structure and command-line API
[Dynartic.git] / DynImage.js
1 /*
2 * DynImage.js
3 * node.js module to perform the bulk of the calculations used in Dynartic
4 * main.js is a light frontend to this data structure
5 */
6
7 function DynImage(width, height, buffer) {
8 this.width = width;
9 this.height = height;
10 this.buffer = buffer;
11
12 // prefill with black as opposed to nonsense from memory
13 this.fillColor(0, 0, 0, 0);
14 }
15
16 // blindly fills the entirety of the buffer with a given color
17 // used for initialization, etc.
18 DynImage.prototype.fillColor = function(r, g, b, a) {
19 for(var i = 0; i < (this.width * this.height * 4); i += 4) {
20 this.buffer[i + 0] = r;
21 this.buffer[i + 1] = g;
22 this.buffer[i + 2] = b;
23 this.buffer[i + 3] = a;
24 }
25 }
26
27 module.exports = DynImage;
This page took 0.067389 seconds and 5 git commands to generate.