Click anywhere to restart the animation. Press “C” to clear the canvas. Press “P” to pause.
Simple accumulation of shapes can lead to complex forms. Here we see what happens when a faint circle is painted on the canvas each frame. The circle’s positions and sizes wander with smoothed easing. Arachnocampa Luminosa is latin for “glow worm”.
|
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 |
Part[] allParts; int numParts = 10; boolean isPaused = false; Part part; void setup() { size(940, 540); colorMode(HSB, 1.0, 1.0, 1.0, 1.0); background(0.0); strokeWeight(1.01); createParts(); } void draw() { updateParts(); } void createParts() { numParts = round(random(3, 10)); allParts = new Part[numParts]; for (int i=0; i<numParts; i++) { Part part = new Part(width/2, height/2, 0.05); allParts[i] = part; } } void updateParts() { if (!isPaused) { for (int i=0; i<allParts.length; i++) { allParts[i].update(); } } } void mousePressed() { background(0); firstTime = true; createParts(); } void keyPressed() { if (key == 'c') { background(0); } if (key == 'p') { isPaused = !isPaused; } } class Part { PVector pos = new PVector(0,0,0); PVector vel = new PVector(0,0,0); float size = 10; float scale; float accelMod = 0.1; float hue = 0.0; float sat = 0.0; Part(float _x, float _y, float _accelMod) { accelMod = _accelMod; pos.set(_x, _y, 0); vel.set(random(-1, 1), random(-1, 1), 0); scale = random(5, 100); hue = random(0, 1); sat = random(0, 1); } void update() { PVector accel = PVector.random3D(); accel.mult(accelMod); vel.add(accel); vel.mult(0.995); pos.add(vel); size += (vel.mag() * scale - size) * 0.02; wrap(); noFill(); stroke(hue, sat, 1.0, 0.05); ellipse(pos.x, pos.y, size, size); } void wrap() { float radius = size/2; float top = 0 - radius; float bottom = height + radius; float left = 0 - radius; float right = width + radius; if (pos.x > right) { pos.x = left; } else if (pos.x < left) { pos.x = right; } if (pos.y > bottom) { pos.y = top; } else if (pos.y < top) { pos.y = bottom; } } } |





