We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › more blobs and splatters
Page Index Toggle Pages: 1
more blobs and splatters (Read 785 times)
more blobs and splatters
Sep 23rd, 2009, 4:57pm
 
I posted a while back asking for ways to make fluid-y blobs and splatter shapes. Had some time recently to play with this some more, so here's another try, and one more in the followup. Would appreciate comments, thanks!

In my original post, I played with Perlin noise contours. The results were a bit hard to control (difficult to center, may get lots of blobs etc).

Here's another approach with Perlin noise. I'm basically tracing a circle, but using Perlin noise to modulate the radius. When I get close to the end of the circle, I crossfade back to the starting point.

This gets more controllable results (always one blob, centered correctly). But the shapes are not that fluid-like, if that's what you want. In the Blob constructor class, there are two control parameters to adjust the blob:

maxRadiusDev is the maximum % deviation from the specified radius
noiseInc is the Perlin noise index increment (increase to make the blob edges more jagged)

Code follows...

Bill

// Make irregular blobs
// hit space to get new blob

Blob myBlob;
void setup() {
 size(200, 200);
 myBlob = new Blob(400, 50., width/2, height/2);
}

void draw() {
 smooth();
 background(255);
 myBlob.display();
}

void keyPressed() {
 if (key == ' ')
   myBlob = new Blob(400, 50., width/2, height/2);
}

class Blob {
 
 int [] x;
 int [] y;
 float radius;
 int centerX, centerY;
 
 Blob(int numVertex, float rad, int cX, int cY) {
   radius = rad;
   centerX = cX;
   centerY = cY;
   
   x = new int[numVertex];
   y = new int[numVertex];
   
   float angle = 0;
   float deltaAngle = TWO_PI / numVertex;
   float noiseSample = random(0, 100);  // Perlin noise index
   float noiseInc = .02;    // Perlin noise inc
   float maxRadiusDev = .2; // max radius deviation in percent
   float radFactor;
   float zRad;

   radFactor = 1 + maxRadiusDev * (1 - 2 * noise(noiseSample));
   x[0] = centerX + (int) (radFactor * radius * cos(angle));
   y[0] = centerY + (int) (radFactor * radius * sin(angle));
   zRad = radFactor * radius;
   angle += deltaAngle;
   noiseSample += noiseInc;
   
   int i;
   for (i=1; i<(int) (.9 * numVertex); i++) {
     radFactor = 1 + maxRadiusDev * (1 - 2 * noise(noiseSample));
     x[i] = centerX + (int) (radFactor * radius * cos(angle));
     y[i] = centerY + (int) (radFactor * radius * sin(angle));
     angle += deltaAngle;
     noiseSample += noiseInc;
   }

   int startI = i;
   int remInterval = numVertex - i;
   float rx = x[i-1] - centerX;
   float ry = y[i-1] - centerY;
   float lastRad = sqrt(rx * rx + ry * ry);
   float deltaRad = zRad - lastRad;
   println("last x y " + x[i-1] + " " + y[i-1] + " " + lastRad + " " + zRad + " " + remInterval );
   for (; i<numVertex; i++) {
     float frac = (i-startI + 1) * deltaRad / remInterval;
     x[i] = centerX + (int) ((lastRad + (i-startI + 1) * deltaRad / remInterval) * cos(angle));
     y[i] = centerY + (int) ((lastRad + (i-startI + 1) * deltaRad / remInterval) * sin(angle));
     angle += deltaAngle;
     println("x y " + x[i] + " " + y[i]);
   }
     
   
 }
 
 void display() {
   fill(0);
   beginShape();
   curveVertex(x[0], y[0]);
   for (int i=0; i<x.length; i++) {
     curveVertex(x[i], y[i]);
   }
   curveVertex(x[x.length-1], y[y.length-1]);
   endShape();
 }
}
Re: more blobs and splatters
Reply #1 - Sep 23rd, 2009, 5:14pm
 
Here's another try, after reading

http://processing.org/discourse/yabb2/num_1240929404.html

A lot of the ideas are stolen from Mehmet Akten's lovely branch/drip sketch. I tried to make the blobs less regular, and added more splatter-y effects. Click in the window to start a blob:

http://onesubliminal.googlepages.com/Drippy.html

Problems: some of the shapes and splatter patterns can look unnatural. It's also hard to finetune; to get usable patterns of a much bigger size, a lot of parameters need to be massaged, ack.

Again, comments appreciated.

I'm looking at physics-based simulations now to get more fluid-like blobs/splatters, but that's a lot more work...

Bill
Re: more blobs and splatters
Reply #2 - Sep 23rd, 2009, 5:40pm
 
i think it turns out really good. Only thing i would change. The splatters that go up should allready be there, or at least set the speed really high. Paint doesnt drip upwards. looks strange
Page Index Toggle Pages: 1