Sunday, May 31, 2009

Squares

int x = 0;
int y = 0;
int stepx = 10;
int stepy = 10;
int add = 0;
int add2 = 0;

void setup()
{
    size(300,300);
    background(255, 255, 50);
}

void draw()
{
    noStroke();

    for (int i = 0; i < 30; i++)
    {
        int r = add2 + ((add + x) / (y + add2 + 1));
        while (r > 255) r -= 255;
        fill(r);             
        rect(x*stepx, y*stepy, stepx, stepy);      

        add += 3;
        while (add > 255) add -= 255;

        add2 += add * y;
        while (add2 > 255) add2 -= 255;

        x ++;
        if (x >= width/stepx)
        {
            x = 0;
            y ++;
            if (y >= height/stepy) y = 0;
        }
    }
}

info info

submitted by: PsychicTeeth
views: 4249


Tags: noob

comments comment

loading loading...

 

Add a comment: