Trabajos practicos: Processing

TP 1

La creacion del circulo cromatico RGB
Circulo

Codigo

void setup(){

size (400,400);

colorMode( HSB );

colorMode( HSB, 360, 100, 100 );

background (24,0,0);}

void draw (){

noStroke();

fill (0,100,100);

circle (200,45,75); // n1 rojo

fill (337,98,94);

circle (280,60,10); // n2

fill (299,81,99);

circle (330,122,40); // n3 magenta

fill (279,98,74);

circle (375,200,10); // n4 violeta

fill (250,99,99);

circle (335,270,75); // n5 azul

fill (212,85,97);

circle (290,335,10); // n6

fill (176,99,99);

circle (200,360,40); // n7 cyan

fill (147,62,68);

circle (120,335,10); // n8

fill (124,99,99);

circle (70,270,75); // n9 verde

fill (86,65,79);

circle (25,200,10); // n10

fill (60,99,99);

circle (68,122,40); // n11 amarillo

fill (39,97,99);

circle (120,60,10);} // n12

TP 2

Animacion de creditos

Codigo

int posY;

PFont letraryf;

PImage titulo;

PImage fondo;

PImage elenco;

PImage mouse;

PImage actoresprincipales;

PImage fondo2;

PImage salto;

int pantalla;

void setup() {

pantalla=0;

posY= height;

letraryf= loadFont ("Elektronik-Italic-48.vlw");

size (800, 600);

textAlign (CENTER);

imageMode (CENTER);

noCursor();

titulo=loadImage("titulo.png");

fondo=loadImage("fondo.jpg");

elenco=loadImage("elenco.png");

fondo2=loadImage ("fondoo.jpg");

salto=loadImage ("salto.jpg");

textFont (letraryf);

mouse =loadImage ("mouse.png");

}

actoresprincipales=loadImage ("actoresprincipales.jpg");

void draw() {

println(posY,pantalla);

if (posY >= 0 && pantalla <= 5){

posY-=2;

}else{

posY = height;

}

if (posY==0){

pantalla++;

}

if (pantalla == 0) {

background (fondo);

image (titulo,width/2,posY);

}

if (pantalla == 1) {

fill (255,0+posY);

background (actoresprincipales);

textSize (35);

text("Actores principales",width/2,posY);

textSize (26);

text ("Vin Diesel",150,posY+80);

text("Paul Walker",150,posY+120);

text ("Michelle Rodriguez",550,posY+80);

text ("Jordana Brewster",550,posY+120);

}

if(pantalla ==2){

fill (255,0+posY);

background (elenco);

textSize (35);

text ("Actores secundarios",width/2,posY);

textSize (26);

text ("Chad Lindberg",150,posY+80);

text ("Johnny Strong",550,posY+80);

text ("Matt Schulze",150,posY+120);

text ("Rick Yune", 550,posY+120);

text ("Reggie Lee",150,posY+160);

text ("Stanton Rutledge ",550,posY+160);

}

if(pantalla ==3){

background (fondo2);

textSize (random(35,36));

fill (random(200,255),0,0,0+posY);

text("Banda Sonora",width/2,posY);

textSize (26);

fill(255,0+posY);

text ("Good Life",190,posY+80);

text ("POV City Anthem",190,posY+120);

text ("When a Man Does Wrong",190,posY+160);

text ("Race Against Time Part 2",190,posY+200);

text ("Furious",190,posY+240);

text ("Take My Time Tonight",550,posY+80);

text ("Suicide",550,posY+120);

text ("The Prayer",550,posY+160);

text ("Tudunn Tudunn Tudunn",550,posY+200);

text ("Hustlin'",550,posY+240);

}

if(pantalla==4){

background(salto);

fill (255,0+posY);

textSize (35);

text ("Direccion",width/2,posY);

textSize (26);

fill (random(247,252),random(247,258),random(73,85),0+posY);

text ("Rob Cohen",160,posY+80);

text ("Creighton Bellinger",160,posY+120);

text ("Doug Claybourne",550,posY+80);

text ("Neal H. Moritz",550,posY+120);

text ("John Pogue",160,posY+160);

text ("Waldemar Kalinowski",160,posY+200);

text ("Gary Scott Thompson",550,posY+160);

text ("Erik Bergquist",550,posY+200);

text ("David Ayer",550,posY+240);

}

if (pantalla==5){

background (0);

fill (255,0+posY);

textSize(48);

text("FIN.",width/2,posY);

}

image (mouse, mouseX, mouseY);

}

TP 3

Ilusion optica

Codigo

void setup () {

size (800, 800);

}

void draw() {

float enX= map(mouseX, 0, width, 0, width*2);

float enY= map(mouseY, 0, height, 0, height*2);

float col=map(mouseX, 0, width, 20, 255);

float col1=map(mouseY, 0, width, 150, 220);

noStroke();

if (keyPressed) {

if (key == 'r') {

background(200);

enX=0;

enY=0;

mouseX=0;

mouseY=0;

}

}

pushStyle();

fill(0,col1, col);

ellipse (width/2, height/2, enX, enY );

popStyle();

pushStyle();

fill( 0);

for (int x=0; x

for (int y=0; y

ellipse (x, y, 10, 20);

}

}

popStyle();

}

TP 4

Aventura grafica

Codigo

TP 5

Videojuego

Codigo

Flecha