I’m always amazed at how much you can do with Perlin noise. It can lead to the illusion of coordination without the computational cost usually associated with large interdependent systems. In this example, I’m using a 2 dimensional Perlin noise call to generate the hues and rotations for the shapes. The grid consists of overlapping rectangles that are exactly twice the size of the grid spacing. When these rectangles are rendered with fractional opacity, the overlapping shapes blend and create new forms.
|
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 |
float cellSize = 50; Node[] nodes; int xRes, yRes; float currentHue = 0.0; void setup() { size(940, 540); colorMode(HSB, 100); background(0); ellipseMode(CENTER); rectMode(CENTER); createNodes(); } void draw() { background(0); currentHue += 0.01; currentHue = currentHue%100; updateNodes(); } void createNodes() { xRes = ceil(width/cellSize) + 2; yRes = ceil(height/cellSize) + 2; nodes = new Node[(xRes)*(yRes)]; for (int i=0; i<yRes; i++) { for (int j=0; j<xRes; j++) { float cx = j*cellSize + cellSize/2; float cy = i*cellSize + cellSize/2; cx -= cellSize; cy -= cellSize; Node node = new Node(cx, cy); nodes[i*xRes+j] = node; } } } void updateNodes() { float noiseScale = 0.01; for (int i=0; i<yRes; i++) { for (int j=0; j<xRes; j++) { Node node = nodes[i*xRes+j]; node.setEnergy(noise(i*noiseScale, j*noiseScale, frameCount*0.0008)); node.update(); } } } class Node { float x, y, energy, ve; float size = 300; float rotation; Node(float _x, float _y) { x = _x; y = _y; energy = 0.5; ve = 0.0; rotation = PI / 4; } void update() { float edgeSoftness = 50; noStroke(); fill(energy*400%100, 100, 100, 30); pushMatrix(); translate(x, y); rotate(energy*TWO_PI*4); rect(0, 0, cellSize*2, cellSize*2); popMatrix(); } void setEnergy(float e) { float de = e - energy; ve += de * 0.001; ve *= 0.95; energy += ve; } } |



