lunes, 10 de septiembre de 2012

clase del 10 de septiembre

ejercicio 1:


/* graficar linea */

size(480,120); //tamaño del documento
smooth(); //suavisar la linea
strokeWeight(8); //ancho de linea
line(20,40,60,80); //dibujamos la linea en el plano


ejercicio 2:


/* ciclo for */

size(480,120); //tamaño del documento
smooth(); //suavisar la linea
strokeWeight(8); //ancho de linea
line(20,40,60,80); //dibujamos la linea en el plano
line(40,40,80,80);


ejercicio 3:


/* ciclo for (trama repetida de un objeto determinado)*/

size(480,120); //tamano sketch
smooth();
strokeWeight(8); //anchio linea
//el ciclo for es un contador que cuenta
//una cantidad de veces segun una condicion
//determinada
for(int i=20; //variable y valor
    i <400; //si es menora 400
    i +=60) { //le suma i 60
  rect(i,40,i,80);
}


ejercicio 4:

size(480,120); //tamano sketch
background(0);
smooth();
noStroke(); //anchio linea
//for (int y = 0;y <= height; y += 40) {
 //reconoce el ancho total de la aplicacion
for(int x=0; x<= width; x +=40) {
    fill(random(255), random(255), random(255),
    random(255));
    ellipse (x,y,40,40);
}
}

ejercicio 5:

// void= vendria siendo una funcion
//funciuon es una accion que va a cumplir el programa
//siempre la funcion se le da un nombre (){}
//la funcion que cumple siempre va a estar dentro de las llaves
//setup es para setear el programa, es decir,
//cosas que no se van a modificar
void setup() {
  println("estoy partiendo");
}
//aqui los objetos van siendo modificados en la ejecucion
// del programa

void draw() {
  println("estoy ejecutando");
}

ejercicio 6:

void setup() {
  size(480,120);
  fill(0,102);
  smooth();
  noStroke();
}

void draw() {
  //background(204);
  //ellipse(mouseX, mouseY,9,9);
  ellipse(0,0,9,9);
}
  
ejercicio 7:

void setup() {
  size(480,120);
  fill(0,102);
  smooth();
  noStroke();
}

void draw() {
  //background(204);
  ellipse(mouseX, mouseY,9,9);
  ellipse(0,0,9,9);
}
  

ejercicio 8:


void setup () {
  size (240,120);
  smooth ();
  strokeWeight (30);
}
void draw () {
  background (204);
  stroke (103);
  line (40,0,70,height);
  //if (mousePressed == true) {
    // stroke(0);
    //}
    line (0,70,width,50);
}


 ejercicio 9 (ejercicio 8 pero variado):


void setup () {
  size (240,120);
  smooth ();
  strokeWeight (30);
}
void draw () {
  background (204);
  stroke (103);
  line (40,0,70,height);
  if (mousePressed == true) {
    stroke(0);
    }
    line (0,70,width,50);
}

ejercicio 10 (movimiento del teclado):


void setup () {
  size (240,120);
  smooth ();
}
void draw () {
  background (204);
  line (20,20,220,100);
  if (keyPressed) {
    line (220,20,20,100);
}
}

ejercicio 11:


void setup () {
  size (240,120);
  smooth ();
}
void draw () {
  background (204);
  //condicional multiple nos permite trabajar con multiples teclas
  if (keyPressed) {
    if ((key == 'h') || (key == 'H')) {
      line (30,60,90,60);
    }}
    if ((key == 'n') || (key == 'N')) {
    
    line (30,20,30,100);
    line (90,20,90,100);
  }
}

ejercicio 12:


//variable nombre x 215
int x = 215;
void setup () {
size (480,120);
}
void draw () {
 if (keyPressed && (key == CODED)) {
    if (keyCode == LEFT) {
      x--; //restar en un punto el valor de x
    }
    //else if (keyCode == RIGHT) {
      // x++; //suma en un punto el valor de x
      //}
  }
  rect (x,45,50,50);
}



No hay comentarios:

Publicar un comentario