More pretty things
[Dynartic.git] / main.js
1 /*
2 * Dynartic main.js
3 * Performs the bulk of the operation for Dynartic
4 * Dynartic is a tool for automatically generating beautiful yet abstract art
5 * Think of it as Lorem Ipsum for images
6 */
7
8 var fs = require("fs");
9 var Png = require("png").Png;
10 var DynImage = require("./DynImage");
11
12 // fetch configuration values
13 // TODO: better way of doing this, maybe
14 var width = process.argv[2]*1;
15 var height = process.argv[3]*1;
16
17 function pretty(name, ringConstant) {
18 // buffer size is: width * height * 4 (RGBA is 4 bytes)
19 var buffer = new Buffer(width * height * 4);
20
21 // bare calculations are offset to DynImage
22 var dynimage = new DynImage(width, height, buffer);
23
24 // fill the image with a random, opaque color to start with
25 dynimage.fillColor(
26 Math.floor(Math.random() * 255),
27 Math.floor(Math.random() * 255),
28 Math.floor(Math.random() * 255),
29 0
30 );
31
32 // make a beautiful point ring
33
34 dynimage.punchImage(width / 2, height / 2, width, height, (Math.floor(Math.random() * 96)), width / 3);
35
36 dynimage.pointRing(width / 2, height / 2, width, ringConstant)
37
38 var png = new Png(buffer, width, height, 'rgba');
39 png.encode(function(image) {
40 fs.writeFile(name+".png", image);
41 });
42 }
43
44 pretty("output", Math.E);
This page took 0.069806 seconds and 5 git commands to generate.