// Metaball Class class Metaball{ // Shape Members float x,y; float radius; color value; // Motion Members float mspeedx, msizex, mcenterx; float mspeedy, msizey, mcentery; // Constructor Metaball (float cw, float ch){ mspeedx = random(1,20); mspeedy = random(1,20); msizex = random(cw/32,cw/3); msizey = random(ch/32,ch/3); mcenterx = random(msizex, cw-msizex); mcentery = random(msizey, ch-msizey); radius = random((cw+ch)/16,(cw+ch)/8); colorMode(HSB,1.0); value = color(random(1.0),random(0.75,1.0),random(0.75,1.0)); Move(0.0); } // motion control void Move (float t){ x = (cos(time*d2r*mspeedx) * msizex) + mcenterx; y = (cos(time*d2r*mspeedy) * msizey) + mcentery; } // influence float Influence(float a, float b){ float d = sqrt(((a-x)*(a-x)) + ((b-y)*(b-y))); if (d