lunes, 29 de octubre de 2012

CLASE 29-10-2012


EJERCICIO 2


import processing.opengl.*;
void setup(){

  size(600,600,OPENGL);
  noStroke();
}
void draw() {
  background(0);
  translate(width/2,height/2);
  pointLight(150,100,0,200,0,0);
  pointLight(150,100,0,-200,0,0);
  rotateY(map(mouseX,0,width,0,PI));
  rotateX(map(mouseY,0,height,0,PI));
  box(200);
}

EJERCICIO 3



import processing.opengl.*;
PImage img;
void setup(){
  size(640,360,OPENGL);
  img = loadImage("zombie.jpg");
  noStroke();
}

void draw(){
  background(125);
  translate(width/2,height/2);
  rotateY(map(mouseX,0,width,-PI,PI));
  beginShape();
  texture(img);
  vertex(-100,-100,0,0,0);
  vertex(100,-100,0,100,0);
  vertex(100,100,0,200,200);
  vertex(-100,100,0,0,200);
  endShape();
}







lunes, 8 de octubre de 2012

trabajo en clases


PImage pta1;
PImage pta2;
PImage pta3;
PImage pto1;
PImage pto2;
PImage pto3;

float speed = 6.5;

float x;
float y;

void setup() {
  fill(242,141,7);
  size(700,700);
  pta1 = loadImage("camilasilva.jpg");
  pta2 = loadImage("camilasilva2.jpg");
  pta3 = loadImage("camilasilva3.jpg");
  pto1 = loadImage("maximilianopino.jpg");
  pto2 = loadImage("maximilianopino2.jpg");
  pto3 = loadImage("maximiliano3.jpg");
 
  smooth();
  x = width/1;
  y = height/1;

}
void draw() {
  x += random(-speed, speed);
  y += random(-speed, speed);
 
  image(pta1, x-100, y-200, 100, 100);
  image(pta2, x-400, y-500, 100, 100);
  image(pta3, x-300, y-400, 100, 100);
  image(pto1, x-200, y-100, 100, 100);
  image(pto2, x-600, y-700, 100, 100);
  image(pto3, x-700, y-600, 100, 100);
 
 
 
}

clase 08 de octubre


// 00 MOVIMIENTO /////////////////////////////

float a;

void setup() {
  size(640, 360);
  stroke(255);
  a = height/2;
}

void draw() {
  background(51);
  line(0, a, width, a);
  a = a - 0.5;
}


// 01 RECONOCIMIENTO DE BORDE

float a;

void setup() {
  size(640, 360);
  stroke(255);
  a = height/2;
}

void draw() {
  background(51);
  line(0, a, width, a);
  a = a - 0.5;
  if (a < 0) {
    a = height;
  }
}


// 02 RECONOCIMIENTO DE BORDE

 int rad = 60;        // ancho de l figura
float xpos, ypos;    // posiciion inicial  

float xvelocidad = 2.8;  // velocidad en x
float yvelocidad = 2.2;  // velocdad en y

int xdireccion = 1;  // direccion en x
int ydireccion = 1;  // direccion en y


void setup()
{
  size(640, 360);
  noStroke();
  frameRate(30);
  ellipseMode(RADIUS);
 
  xpos = width/2;
  ypos = height/2;
}

void draw()
{
  background(102);
 
  /*
  xpos = xpos + ( xvelocidad * xdireccion );
  ypos = ypos + ( yvelocidad * ydireccion );
 
  if (xpos > width-rad || xpos < rad) {
    xdireccion *= -1;
  }
  if (ypos > height-rad || ypos < rad) {
    ydireccion *= -1;
  }
*/
  ellipse(xpos, ypos, rad, rad);
}


// 03 RANDOM ////////////////////////////////

float speed = 2.5;
int diameter = 20;
float x;
float y;

void setup() {
  size(240, 120);
  smooth();
  x = width/2;
  y = height/2;
}

void draw() {
  x += random(-speed, speed);
  y += random(-speed, speed);
  ellipse(x, y, diameter, diameter);
}

// 04 TIMER


int tiempo1 = 2000;
int tiempo2 = 4000;
float x = 0;

void setup() {
  size(480, 120);
  smooth();
}

void draw() {
  int tiempoActual = millis();
  background(204);
  if (tiempoActual > tiempo2) {
    x -= 0.5;
  } else if (tiempoActual > tiempo1) {
    x += 2;
  }
  ellipse(x, 60, 90, 90);
}


// 06 TRANSLATE

void setup() {
  size(120, 120);
}

void draw() {
  translate(mouseX, mouseY);
  rect(0, 0, 30, 30);
  translate(35, 10);
  rect(0, 0, 15, 15);
}


// 07 ROTATE

float angle = 0.0;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  translate(mouseX, mouseY);
  rotate(angle);
  rect(-15, -15, 30, 30);
  angle += 0.1;
}


// 08 ROBOT


float rango = 0.0;
float velocidad = 0.005;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  background(204);
  translate(20, 25);  
  rotate(rango);
  strokeWeight(12);
  line(0, 0, 40, 0);
  translate(40, 0);    
  rotate(rango * 2.0);
  strokeWeight(6);
  line(0, 0, 30, 0);
  translate(30, 0);    
  rotate(rango * 2.5);
  strokeWeight(3);
  line(0, 0, 20, 0);
 
  rango += velocidad;
 
  if ((rango > 1) || (rango < 0)) {
    velocidad *= -1;
  }

}



// ROTATE

float angle = 0.0;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  translate(mouseX, mouseY);
  rotate(angle);
  rect(-15, -15, 30, 30);
  angle += 0.1;
}



// 07 SCALE

float angle = 0.0;

void setup() {
  size(120, 120);
  smooth();
}

void draw() {
  translate(mouseX, mouseY);
  scale(sin(angle) + 2);
  rect(-15, -15, 30, 30);
  angle += 0.1;
}