Click to randomize. Press “M” to change the mouse interaction mode. Press “G” to change the grid size. Press “C” to change colors. Press “P” to pause. Press “L” to turn lines on and off. Press “D” to toggle box growth from the center or side. Press “B” to change the background from light to dark.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
Pylon allPylons[]; int numPylons = 10; boolean cameraOrtho = true; boolean whiteLines = false; boolean lightBackground = false; float minDist = 150; float growMax = 300; int mode = 1; int gridSizeX = 10; int gridSizeY = 10; float rotX = 45; float rotY = 45; boolean isPaused = false; boolean drawsFromCenter = false; void setup() { size(940, 540, P3D); colorMode(HSB); createPylons(); } void draw() { pushMatrix(); translate(0, 0, 10); directionalLight(255, 0, 150, -0.3, 0.5, -1); directionalLight(255, 0, 150, 0.5, -0.3, -1); popMatrix(); if (lightBackground) background(200); else background(50); if (cameraOrtho) ortho(-940/2, 940/2, -540/2, 540/2, -10000, 10000); else perspective(); for (int i=0; i<gridSizeX*gridSizeY; i++) { Pylon pylon = allPylons[i]; pylon.draw(); } } void createPylons() { int index = 0; allPylons = new PVector[gridSizeX*gridSizeY]; float w = 940/gridSizeX; float h = 540/gridSizeY; float hue1 = random(0, 255); float hue2 = random(0, 255); float hue3 = random(0, 255); float hue4 = random(0, 255); float hue5 = random(0, 255); float sat1 = random(0, 255); float sat2 = random(0, 255); float sat3 = random(0, 255); float sat4 = random(0, 255); float sat5 = random(0, 255); float chance = random(1); for (int x=0; x<gridSizeX; x++) { for (int y=0; y<gridSizeY; y++) { Pylon pylon = new Pylon(); pylon.x = x * w + w/2; pylon.y = y * h + h/2; pylon.w = w * 1.0; pylon.h = h * 1.0; pylon.hue = hue1; pylon.sat = sat1; if (random(1) > chance) { pylon.hue = hue2; pylon.sat = sat2; } else if (random(1) > chance) { pylon.hue = hue3; pylon.sat = sat3; } else if (random(1) > chance) { pylon.hue = hue4; pylon.sat = sat4; } else if (random(1) > chance) { pylon.hue = hue5; pylon.sat = sat5; } pylon.time = -dist(mouseX, mouseY, pylon.x, pylon.y) * 0.06; allPylons[index] = pylon; index++; } } } void mousePressed() { gridSizeX = round(random(1, 30)); gridSizeY = round(random(1, 30)); mode = round(random(0, 3)); drawsFromCenter = round(random(0, 1)); float range = 360; rotX = random(0, range); rotY = random(0, range); createPylons(); } void keyPressed() { if (key == 'o') cameraOrtho = !cameraOrtho; if (key == 'l') whiteLines = !whiteLines; if (key == 'b') lightBackground = !lightBackground; if (key == 'd') drawsFromCenter = !drawsFromCenter; if (key == 'p') isPaused = !isPaused; if (key == 'c') createPylons(); if (key == 'm') { mode++; if (mode > 3) mode = 0; } if (key == '=') { gridSizeX++; gridSizeY++; createPylons(); } if (key == '-') { gridSizeX--; gridSizeY--; createPylons(); } if (key == 'g') { gridSizeX = round(random(1, 30)); gridSizeY = round(random(1, 30)); createPylons(); } } |










