// inspired by some of reas's work, and some of watz's work // all code by seltar: // patterns generated by sinus and cosinus values for each bug, then visualized postFile p = new postFile(); PImage bs = new PImage(500,500); String savedImage = ""; Bugs[] bugs; void setup() { size(500,500); bugs = new Bugs[50]; background( color(random(255),random(255),random(255))); for(int i = 0; i < bugs.length; i++) bugs[i] = new Bugs(width/2,random(height)); } void mousePressed() { if(mouseButton == LEFT){ background( color(random(255),random(255),random(255))); for(int i = 0; i < bugs.length; i++) bugs[i] = new Bugs(width/2,random(height)); } } void draw() { if(!mousePressed) { for(int i = 0; i < bugs.length; i++) bugs[i].draw(); } } class Bugs { float shadeVal,shadeOffset; float px, py, x, y, r, z, speed; float[] arrVal; color c; Bugs(float x, float y) { this.speed = random(1,5); this.shadeVal = random(30,80); this.shadeOffset = random(1); this.px = x; this.py = y; this.x = x; this.y = y; this.arrVal = new float[(int)random(50,200)]; this.r = random(TWO_PI); this.c = color(random(255),random(255),random(255)); setVals(); } void draw() { z++; x += sin(arrVal[(int)z%arrVal.length])*speed; y += cos(arrVal[(int)z%arrVal.length])*speed; strokeWeight((z%arrVal.length)/20); stroke(color(red(c)-shadeVal,green(c)-shadeVal,blue(c)-shadeVal)); bezier(px+shadeOffset,py+shadeOffset,x+shadeOffset,y+shadeOffset,px+shadeOffset,py+shadeOffset,x+shadeOffset,y+shadeOffset); stroke(c); bezier(px,py,x,y,px,py,x,y); px = x; py = y; } void setVals() { for(int i = 0; i < arrVal.length; i++) arrVal[i] = random(-PI,PI); } } void keyPressed() { if(key=='s'){ loadPixels(); arraycopy(pixels,bs.pixels); p.saveJPG(); } }