lunes, 9 de junio de 2014

Taller Funciones + For Loop

A continuación les dejo el código con el que vamos a trabajar hoy en clase:


/*----------------------------------------*/
//ForLoop
int varA;

void setup(){
size(1024,768);
}

void draw(){
  background(240);
  smooth();
  for(varA=10; varA < width-1; varA+=10){
  line(varA,0,varA,height);
  }
  for(varA=10; varA < height-1; varA+=10){
  line(0,varA,width,varA);
  }
}

/*----------------------------------------*/
// FuncionSinVoid
  int tiempo;
 
  int multiplicarPorDos(int valor){
  return valor*2; 
  }
  
  boolean evaluarTiempo(int tiempoTesteado){
    
    if(tiempoTesteado>tiempo){
    return false;
    } else{
    return true;
    }
  }

void setup(){
frameRate(1);
} 

void draw(){
  tiempo=millis();
  multiplicarPorDos(1);
//  println(multiplicarPorDos(1));
  println("evaluarTiempo= " + evaluarTiempo(10000) + "  tiempo= "+tiempo);

}

/*----------------------------------------*/
// FuncionConVoid
void setup() {
  size(500, 500);
  noStroke();
  smooth();
}
void draw() {
background(50);
eye(mouseX,mouseY);
eye(100,100);
eye(300,180);

eyeColor(200,200,86,48,222);

}

void eye(int eyeX, int eyeY){
  fill(255); 
  ellipse(eyeX, eyeY, 60, 60);
  fill(0);
  ellipse(eyeX+10, eyeY, 30, 30); // Black circle
  fill(255);
  ellipse(eyeX+16, eyeY-5, 6, 6);  // Small, white circle
}

void eyeColor(int eyeX,int eyeY,int colorEyeR,int colorEyeG,int colorEyeB){
  fill(colorEyeR,colorEyeG,colorEyeB); 
  ellipse(eyeX, eyeY, 60, 60);
  fill(255);
  ellipse(eyeX+10, eyeY, 30, 30); // Black circle
  fill(colorEyeR,colorEyeG,colorEyeB);
  ellipse(eyeX+16, eyeY-5, 6, 6);  // Small, white circle
}