PVector polar( float r, float theta ) { float x = r * cos( radians( theta ) ); float y = r * sin( radians( theta ) ); return new PVector( x, y ); } void regularPolygon( float x, float y, float r, int n ) { beginShape(); for ( int idx = 0; idx < n; ++idx ) { PVector pt = polar( 100, idx * 360 / float(n) ); vertex( pt.x + x, pt.y + y ); } endShape( CLOSE ); } void setup() { size( 500, 500 ); for( int idx = 0; idx < 20; ++idx ) { fill( random(255), random(255), random(255) ); regularPolygon( random(width), random(height), random(250), int( random( 3, 24 ) ) ); } }