Tuesday, March 1, 2011

Project 4- Arrays and shit!

/*

//This is what I used to make and save the images, I just changed the variables from 0 to 14 and saved as such.

int x;
int y;

size(600,600);
background(255,127,0); //background color
stroke(0, 255, 0); //define stroke color
fill(0,0,255); //define fill color


for(y=0;y<14;y++)
{
for(x=0;x<14;x++)
{
rect(x*30,y*30,20,20);
}
}

save("boxes14.jpg"); */

// and the actual code-

PImage boxes[]= new PImage[14]; //use array object as a "container" for all our images
int counter;


void setup()
{
size(500,500);
//load my faces in
for(int a=0;a<boxes.length;a++)
{
boxes[a]=loadImage("boxes"+a+".jpg");
println("loaded "+"boxes"+a+".jpg");
}
counter=0;

}


void draw()
{

//println(counter);
image(boxes[counter],mouseX,mouseY);

counter++;
if(counter>=boxes.length)
{
counter=0;
}

delay(10);
frameRate(20);

}

Thursday, February 24, 2011

Project 3 Code

//This should rotate an image in a random pattern at 90 degree turns.

PImage b;

void setup()
{

size(500,500);
frameRate(10);


b = loadImage("dino.png");
}

void draw ()
{

int a;
float x,y;

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


for(a=0;a<20;a++)
{
x=random(-100,400);
y=random(-100,400);

pushMatrix();
{
translate(x,y);

rotate(radians(90));
image(b,x,y);

rotate(radians(90));
image(b,x,y);

rotate(radians(90));
image(b,x,y);

rotate(radians(90));
image(b,x,y);

popMatrix();
}
}
noLoop();
}

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
}
}

Monday, February 7, 2011

John Cage

On Silence


27 Kitchen Sounds


Cacti and Plants


Variations V


Dream


4'33


HPSCHD

Thursday, February 3, 2011

Random Rotating Pattern

I want to make a rotation pattern and combine it with the random function to make a random rotating pattern. So here's the first step, pasted both the "random" code and the "rotation" code,
and replace the dinoimage with a photo of a painting. I shrunk it to 75 x 100 pixels and uploaded it to photobucket for ease of use and transfer between computers.

I also notated the random code (which works, by itself).
****************************************************************

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

size(800,800);

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

for(a=0;a<100;a++)
{
x=random(0,726); //keeps everything inside the window, no running over
y=random(0,700);
image(abstract1,x,y); //draw images at random points
}
}
*/

//Figure out how to rotate things in 2D in Processing
//back to our friend the cartoon face

//Processing Copyright info http://processing.org/copyright.html
//This code copyright BitMonkey Labs under Creative Commons Licence: http://creativecommons.org/licenses/by/2.5/
//01/25/2007


void CartoonFace(float x_coord, float y_coord)
//draw a cartoon face at the specified coordinates
{
ellipse(x_coord,y_coord,100,100);
ellipse(x_coord-20,y_coord-20,30,50);
ellipse(x_coord+20,y_coord-20,30,50);
ellipse(x_coord-20,y_coord-10,10,10);
ellipse(x_coord+20,y_coord-10,10,10);
curve(x_coord+70,y_coord+10,x_coord-10,y_coord+35,x_coord+10,y_coord+35,x_coord-70,y_coord+10);
}


void setup()
{
int a,x,y;

size(500,500);
background(255,100,0);
noFill();

smooth();

stroke(255,0,0);

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

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

translate(x,y); //move the matrix to the middle of the screen
rect(0,0,100,100); //draw a rectangle into the matrix
rotate(radians(45)); //rotate the matrix

stroke(0,255,255);
rect(0,0,100,100); //draw another rectangle into the matrix

stroke(0,255,0);
CartoonFace(0,0); //draw our cartoon face into the matrix

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

stroke(0,0,0); //we are off the matrix and things are back to normal :)
rect(0,0,100,100);
CartoonFace(0,0);

}

Dino Checkers

void setup ()
{

PImage dinoImage_1, dinoImage_2;
dinoImage_1 = loadImage("http://www.b1t-m0nkey.com/code/intro_code/ex_015_images/data/dino.png");
dinoImage_2 = loadImage("http://www.b1t-m0nkey.com/code/intro_code/ex_015_images/data/dino2.png");

size(500,500);
int y,x;



for(y=0;y<5;y++)
{
for(x=0;x<5;x++)
{
if(y%2==0) //determine if you are on an even row
{
if(x%2==1) //determine if you are on an even column
{
image(dinoImage_1,x*100,y*100,100,100);
}
else
{
image(dinoImage_2,x*100,y*100,100,100);
}
}
else
{
if(x%2==1)
{
image(dinoImage_2,x*100,y*100,100,100);
}
else
{
image(dinoImage_1,x*100,y*100,100,100);
}
}
}
}
}

Thursday, January 27, 2011

WTF Triangles!

//this is way better than the plaid sketch.

int x;
int y;

size(1200,1200);
background (45,80,130);

for(y=4;y<40;y++)
{
for(x=4;x<40;x++)
{
triangle(x*30,y*30,50,70,80,20); //don't know exactly how this works, but it look cool
stroke(0,0,0);
fill(200,230,0);
}
}


int a;
int b;

stroke(0,0,0);
fill(150,0,50);

for(b=8;b<15;b++)
{
for(a=8;a<15;a++)
{
quad(a*30,b*20,a*40,b*30,a*32,b*28,a*31,b*40); /*grid points might be wonky, but I still
don't know why it cuts them into the star trek logo*/

}
}

save("triangle.jpg");

Wednesday, January 26, 2011

Plaid Sketch 1

//stretched the checkerboard pattern out of shape and recolored it.
//very, very rough. mostly changed values only.

void setup ()
{
size(1000,1000);
int y,x;

int square_height=6;
int square_width=6;

for(y=0;y<200;y++)
{
for(x=0;x<200;x++)
{
if(y%13==0) //oddly, only a good range between the x% and y% here are interesting.
{
if(x%3==1) //values too close together are too close and "busy", color-wise
{
fill(0,90,170);
}
else
{
fill(0,50,200);
}
}
else
{
if(x%2==1)
{
fill(180,0,0);
}
else
{
fill(100,20,200);
}
}
rect(x*square_width,y*square_height,square_width,square_height);
}
}
}

Monday, January 24, 2011

Monday, January 17, 2011