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);
}
No comments:
Post a Comment