Play with various parameters
[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, ired, igreen, iblue, ringConstant, stainConstant, stainSize, waveConstant, contrastThreshold, bred, bgreen, bblue, intensityConstant, borderConstant) {
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 ired,
27 igreen,
28 iblue,
29 0
30 );
31
32 // make a beautiful point ring
33
34 dynimage.punchWave(width / 2, height / 2, width * stainSize, height * stainSize, Math.floor(stainConstant), width / 3, waveConstant);
35 //dynimage.explosion(width, 50, 0.9, 0.5, 100 + (Math.random() * 100));
36 // dynimage.border(width, height, bred, bgreen, bblue, borderConstant);
37 //dynimage.explosion(width, 50, 0.9, 0.5, 100 + (Math.random() * 100));
38
39 dynimage.character2(width, height);
40 dynimage.explosion(width, 50, 0.9, 0.5, 100 + (Math.random() * 100));
41 dynimage.pointRing(width / 2, height / 2, width, ringConstant, intensityConstant);
42 dynimage.explosion(width, 50, 0.9, 0.5, 100 + (Math.random() * 100));
43 dynimage.punchWave(width / 2, height / 2, width * stainSize, height * stainSize, Math.floor(stainConstant), width / 3, waveConstant);
44 dynimage.character2(width, height);
45
46 dynimage.pointRing(width / 2, height / 2, width, ringConstant, intensityConstant);
47 dynimage.explosion(width, 50, 0.9, 0.5, 100 + (Math.random() * 100));
48 dynimage.punchWave(width / 2, height / 2, width * stainSize, height * stainSize, Math.floor(stainConstant), width / 3, waveConstant);
49 //dynimage.explosion(width, 50, 0.9, 0.5, 100 + (Math.random() * 100));
50 dynimage.recontrast(contrastThreshold, Math.floor(Math.random() * 60));
51
52 dynimage.punchWave(width / 2, height / 2, width * stainSize, height * stainSize, Math.floor(stainConstant), width / 3, waveConstant);
53 dynimage.explosion(width, 50, 0.9, 0.5, 100 + (Math.random() * 100));
54 //dynimage.border(width, height, bred, bgreen, bblue, borderConstant);
55 /*
56 var png = new Png(buffer, width, height, 'rgba');
57 png.encode(function(image) {
58 fs.writeFile(name+".blurry.png", image);
59 });*/
60
61 // dynimage.antialias(width, height);
62
63 var png = new Png(buffer, width, height, 'rgba');
64 png.encode(function(image) {
65 fs.writeFile(name+".png", image);
66 });
67 }
68
69 pretty("output", Math.random() * 255, Math.random() * 255, Math.random() * 255, Math.random() * 6, Math.random() * 170, 0.5 + (0.5*Math.random()), Math.floor(Math.random() * 20), 50 + (Math.random() * 150), Math.random() * 255, Math.random() * 255, Math.random() * 255, Math.random(), Math.random() * 20);
This page took 0.092651 seconds and 4 git commands to generate.