Sunday 11 January 2009

Lotsa processing, not a lotta blogging

Showing my age by failing to share my life with the world.

Just gots to do more blogging about my Processing progress!

I finally shipped the ECA for TT282 on cut off date of December 23 and so started spending much more time with Greenberg & the Processing IDE. I start M362 in February, so I had better get on with it! Don't want conflicting loyalties in my life.

I asked for my chunk choice tonight and will see if I can get it.

Below is some code that plays with color value as described on Greenberg page 402:
The apparent brightness of the colored rectangles varies with the background, apparently in an inverse relation to the luminance being allowed through the mid range alpha values.

Lower luminance pastels on a visible dark background look "brighter" than higher luminance pastels on a light background.

Some voodoo going on here with matrix transforms and rotation too. More than I fully comprehend yet.

Processing makes it so easy to experiment with stuff and then reverse engineer why it displays "that way" later. Very enjoyable stuff.



/* Spiral pastel rects 03 Jan 2008 */

float theta = TWO_PI/30;
int x, y, bkg = 255, bkgstep = 64;

void setup(){
size(1024,768);
background(255);
frameRate(12);
translate(width/2,height/2);
pushMatrix();
}

void draw(){
// fade background from light to dark
// clear screen and step each time spiral hits right window edge
if(x > width){

bkg = abs((bkg - bkgstep)%255);
background(bkg);
// reverse bkg fader at limits
if ((bkg < 32)||(bkg > 224)) bkgstep = -bkgstep;
x = 0;
y = 0;
// change spiral direction
theta = -theta;
}

noStroke();
popMatrix();

// random pastel shade r,g & b = (64-255) with varying alpha (64 - 96)
fill(
64+random(191), 64+random(191),
64+random(191), 64+random(32)
);
// rect specfied with x, y centres and height & width
rectMode(CENTER);
rect(
// x & y creep out and then mod into 0 again
(x+=3)%(width/2),(y+=3)%(height/2),
// rect side sizes are random between 50 - 100 (in steps of 10)
50+random(5)*10, 50+random(5)*10
);
// rotate with a creeping x & y rect offset = spiral
rotate(theta);
pushMatrix();
}

No comments: