martes, 25 de mayo de 2010

Poccessing

Bueno, como tampoco sé subir los ejercicios de proccessing al blog, o al menos no por ahora, subiré los códigos.

Ejercicio 1:

size (400,320);
background (20,60,75);
smooth ();
strokeWeight (2);
fill (90);
rectMode (CENTER);
rect (300,160,50,50);
fill (60,150,38);
ellipse (100,160,90,300);

Ejercicio 2:

void setup() {
size (400,320);
background (300);
}
void draw () {
strokeWeight (0);
smooth ();
fill (200);
rectMode (CENTER);
rect ((random(400)),(random(160)),50,50);
fill (50,100,18);
ellipse ((random(200)),(random(320)),50,50);
}

Ejercicio 3:

void setup() {
size (400,320);
background (255);
}
void draw () {
strokeWeight (2);
smooth ();
fill (20,20,random(200));
rectMode (CENTER);
rect ((random(400)),(random(320)),400,50);
fill (random(200),200,18);
ellipse ((random(400)),(random(320)),100,100);
}

Ejercicio 4:

void setup() {
size (400,320);
background (255);
}
void draw () {
strokeWeight (2);
smooth ();
fill (0,0,0);
rectMode (CENTER);
rect ((random(400)),(random(320)),50,400);
fill (random(200),random(200),0);
ellipse ((random(400)),(random(320)),100,100);
}

Ejercicio 5:

void setup() {
size (400,320);
background (255);
}
void draw () {
strokeWeight (0);
smooth ();
fill (random(200),random(200),random(200));
rectMode (CENTER);
rect ((random(400)),(random(320)),random(200),random(200));
fill (random(200),random(200),random(200));
ellipse ((random(400)),(random(320)),random(200),random(200));
}

Ejercicio 6:

void setup() {
size (600,400);
background (255);
}
void draw () {
stroke (0);
fill (random(150),random(150));
rectMode (CORNER);
rect (random(600),random(400),random(300),random(300));
fill (0);
ellipse (mouseX,mouseY,60,60);
}

Ejercicio 7:

// declare global variables
int xspeed, yspeed;
int xpos,ypos,wdth,ht;
// initialize sketch
void setup() {
// set sketch window size + background color
size(600,400);
background(50);
// ball speed
xspeed=10;
yspeed=2;
// ball size
wdth = 80;
ht=60;
// turn off shapestroke rendering
noStroke ();
// initial ball placement
xpos=width/2;
ypos=height/2;
frameRate(30);
}
// begin animation loop
void draw(){
// draw ball
smooth ();
fill ((random (100)),(random (256)),(random (256)));
ellipse(xpos,ypos,wdth,ht);
// upgrade position values
xpos+=xspeed;
ypos+=yspeed;
/*conditionals
detects ball collission with sketch window edges
also accounts for thickness of ball
*/
if(xpos>=width-wdth/2 || xpos<=wdth/2){
xspeed*=-1;
}
if (ypos>=height-ht/2 || ypos<=ht/2){
yspeed*=-1;
}
}

Ejercicio 8:


void setup() {
size (400,320);
background (200,0,0);
}
void draw () {
}
void mousePressed() {
strokeWeight (4);
smooth ();
fill (random (256), random (256), random (256));
rectMode (CORNER);
rect (mouseX,mouseY,random(70),random(70));
}
void keyPressed () {
background (255);
}

No hay comentarios:

Publicar un comentario