public class Spore { private int amount; private float[] _posX; private float[] _posY; private float angStep; private float posStep; private float curl; private float n = 0.0; private float a = random( 0, TWO_PI ); private int _index; public void Spore() { generate( random( 0.01, 0.05 ), random( 2.0, 3.0 ), random( 0.2, 1.0 ) ); } public void generate( float aStep, float pStep, float c) { amount = int(random( 1, 100 )); _posX = new float[ amount ]; _posY = new float[ amount ]; _index = 0; angStep = aStep; posStep = pStep; curl = c; PVector loc = new PVector( 0, 0 ); while( _index < amount ) { n += random(1) * (angStep - -angStep) + -angStep; n *= 0.9 + curl * 0.1; a += n; loc.x += cos( a ) * posStep; loc.y += sin( a ) * posStep; _posX[ _index ] = loc.x; _posY[ _index ] = loc.y; _index++; } _index = 0; } public void step() { ellipseMode(CENTER); smooth(); fill( 0xFFFF6600 ); stroke( 0xFF000000, 100 ); strokeWeight( 0 ); int c = 1; float radius; while( c < _index ) { //radius = (( _index ) / ( c )) + 2; radius = ( (float)_index / (float)c ) + 1; if( radius > 20 ) radius = 20; ellipse( _posX[ c ] + 256, _posY[ c ] + 256, radius, radius ); c++; //println( _index + " - " + c + " - " + radius); } _index++; if( _index >= amount ) { generate( random( 0.01, 0.05 ), random( 2.0, 3.0 ), random( 0.2, 1.0 ) ); } } }