// Nov 2009 // http://www.abandonedart.org // http://www.zenbullets.com // // This work is licensed under a Creative Commons 3.0 License. // (Attribution - NonCommerical - ShareAlike) // http://creativecommons.org/licenses/by-nc-sa/3.0/ // // This basically means, you are free to use it as long as you: // 1. give http://www.zenbullets.com a credit // 2. don't use it for commercial gain // 3. share anything you create with it in the same way I have // // These conditions can be waived if you want to do something groovy with it // though, so feel free to email me via http://www.zenbullets.com //================================= global vars import traer.physics.*; Particle guide; Particle[] chasers; ParticleSystem physics; PImage img; int ang; int num = 2500; float halfheight, halfwidth, radNoise, rotNoise; //================================= init void setup() { size(500, 300); smooth(); physics = new ParticleSystem(0, 0.3); guide = physics.makeParticle(); guide.makeFixed(); restart(); } void restart() { background(200); chasers = new Particle[num]; for ( int i = 0; i < chasers.length; i++ ) { chasers[i] = physics.makeParticle(1.0, random(width+100)-100, random(width+100)-100, 0); physics.makeAttraction(guide, chasers[i], 5500, 50); } ang = 0; halfheight = height/2; halfwidth = width/2; radNoise = random(1); rotNoise = random(1); } //================================= interaction void mousePressed() { restart(); } //================================= frame loop void draw() { physics.tick(); background(200); radNoise += 0.2; rotNoise += 0.1; ang += 12 + ((noise(rotNoise) * 10) - 5); if (ang > 360) { ang = 0; } float rad = radians(ang); physics.tick(); float radius = 100 + (noise(radNoise) * 100); float x = halfwidth + (radius * cos(rad)); float y = halfheight + (radius * sin(rad)); guide.position().set(x, y, 0); physics.tick(); fill(255, 230); for ( int i = 0; i < chasers.length; i++ ) { Particle p = chasers[i]; float diff = dist(x, y, p.position().x(), p.position().y()); strokeWeight(0.7); stroke(116, 9, 9, 5); if (diff > 50) { fill(255, diff-150); } else { fill(255, 100-diff); } ellipse(p.position().x(), p.position().y(), diff/5 + 4, diff/5 + 4); } }