// Alien Blob 2.1 (Feb 15 '06) // - Ryan Govostes, Jim Bumgardner // based on formula by Jim Bumgardner float xoff = 0, yoff = 0, zoff = 0; float sineTable[]; float dTable[]; void setup() { size(256, 256); colorMode(HSB, 2); background(0); noiseDetail(1); // framerate(24); // precalculate 1 period of the sine wave (360 degrees) sineTable = new float[360]; for (int i = 0; i < 360; i ++) sineTable[i] = sin(radians(i)); dTable = new float[width*height]; float cx = width/2; float cy = height/2; int n = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (x == cx && y == cy) { dTable[n] = 0; } else { // dTable[n] = log(dist(x,y,cx,cy)); // another fun one... dTable[n] = dist(x,y,cx,cy) * .05; } ++n; } } } void draw() { float d, h, s, b, n; float xx; float yy = yoff; int w2 = width / 2; int h2 = height / 2; int offset = 0; int lm = 8; blend(lm, lm, width-lm*2, height-lm*2, 0, 0, width, height, BLEND); // filter(BLUR, 2); float varH = sineTable[(millis()>>3)%360]; float varS = sineTable[(millis()>>4)%360]; float varN = sineTable[(millis()>>5)%360]; for (int y = 0; y < height; y ++) { xx = xoff; for (int x = 0; x < width; x ++) { d = dTable[offset]; if (d < 2) { n = noise(xx, yy, zoff)*(1+varN*.5); // noise only needs to be computed once per pixel // use pre-calculated sine results h = 1 + sineTable[int(degrees(d + n *(3+varH*2))) % 360]; s = sineTable[int(degrees(d + n * (5+varS*4))) % 360] + 1; b = sineTable[int(degrees(d + n * 3)) % 360] + 1; // determine pixel color // pixels[offset] = color(h, s, b); set(x,y,color(h,s,b)); } offset++; // increment xx xx += 0.0625; // = x/16.0 } // this value only needs to be changed once per pixel line yy += 0.0625; } // move through noise space -> animation xoff += 0.3; yoff += 0.07; zoff += 0.1; }