Tuesday, February 8, 2011

Abstract rotation pattern, random.

//An endless draw loop that makes a rotating random patterns of 4 paintings.

PImage b,c,d,e;

void setup()
{

size(1000,1000);
background(180,0,0);
frameRate(10);


String url = "http://i84.photobucket.com/albums/k25/Stickchair68/abstractmini.png?t=1296774852"; //set source file
b = loadImage(url, "jpg");

String url2 = "http://i84.photobucket.com/albums/k25/Stickchair68/lanternmini.png?t=1297312108";
c = loadImage(url2, "jpg");

String url3 ="http://i84.photobucket.com/albums/k25/Stickchair68/gabrielmini.png?t=1297312109";
d = loadImage(url3, "jpg");


String url4 = "http://i84.photobucket.com/albums/k25/Stickchair68/dragonmini.png?t=1297312110";
e = loadImage(url4, "jpg");


}


void draw ()
{

int a;
float x,y; //random function returns a float (a number with a decimal point,) so we must have float vars

x=width/2;
y=height/2;


//---------------------------------

for(a=0;a<7;a++)
{
x=random(0,700); //keeps everything inside the window, no running over
y=random(0,700);

pushMatrix(); //load all the pixels in the window into a transformation matrix

translate(x,y); //move the matrix to the middle of the screen

rotate(radians(random(-180,180))); //rotate the matrix
image(b,x,y); //draw images at random points

rotate(radians(random(-180,180)));
image(c,x,y);

rotate(radians(random(-180,180)));
image(d,x,y);

rotate(radians(random(-180,180)));
image(e,x,y);

popMatrix(); //unload all the pixels from the transformation matrix
}
}

2 comments:

  1. //Or a neverending draw loop!

    void setup()
    {

    size(1000,1000);
    background(180,0,0);
    frameRate(10);
    }
    void draw ()
    {
    int a,q;
    float x,y; //random function returns a float (a number with a decimal point,) so we must have float vars



    PImage abstract1; //create an image object
    abstract1 = loadImage("http://i84.photobucket.com/albums/k25/Stickchair68/abstractmini.png?t=1296774852"); //set source file


    x=width/2;
    y=height/2;

    //---------------------------------

    for(a=0;a<100;a++)
    {
    x=random(0,700); //keeps everything inside the window, no running over
    y=random(0,700);

    pushMatrix(); //load all the pixels in the window into a transformation matrix

    translate(x,y); //move the matrix to the middle of the screen

    rotate(radians(random(-180,180))); //rotate the matrix
    image(abstract1,x,y); //draw images at random points

    popMatrix(); //unload all the pixels from the transformation matrix
    }
    }

    ReplyDelete
  2. //Or, even slower!!

    void setup()
    {

    size(1000,1000);
    background(180,0,0);
    frameRate(2); /*here, how fast the loop runs*/
    }
    void draw ()
    {
    int a,q;
    float x,y; //random function returns a float (a number with a decimal point,) so we must have float vars



    PImage abstract1; //create an image object
    abstract1 = loadImage("http://i84.photobucket.com/albums/k25/Stickchair68/abstractmini.png?t=1296774852"); //set source file


    x=width/2;
    y=height/2;

    //---------------------------------

    for(a=0;a<2;a++) /*the "2" here means it will draw 2 images per frame, at the same time*/
    {
    x=random(0,700); //keeps everything inside the window, no running over
    y=random(0,700);

    pushMatrix(); //load all the pixels in the window into a transformation matrix

    translate(x,y); //move the matrix to the middle of the screen

    rotate(radians(random(-180,180))); //rotate the matrix
    image(abstract1,x,y); //draw images at random points

    popMatrix(); //unload all the pixels from the transformation matrix
    }
    }

    ReplyDelete