//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();
}
Thursday, February 24, 2011
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
}
}
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
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);
}
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);
}
}
}
}
}
{
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);
}
}
}
}
}
Subscribe to:
Posts (Atom)