Diferencia entre revisiones de «Imagen Escrita: Módulo»

De Casiopea
Sin resumen de edición
Sin resumen de edición
 
(No se muestran 2 ediciones intermedias del mismo usuario)
Línea 5: Línea 5:
|Cursos Relacionados=Imagen Escrita 2012,
|Cursos Relacionados=Imagen Escrita 2012,
|Profesor=Herbert Spencer
|Profesor=Herbert Spencer
|Alumnos=Alumnus Exemplar,
|Alumnos=Aalumnus Exemplaris
|Imagen=Captura de pantalla 2012-04-08 a la(s) 20.13.03.PNG
|Imagen=Captura de pantalla 2012-04-08 a la(s) 20.13.03.PNG
}}
}}

Revisión actual - 20:08 8 abr 2012

Módulo



TítuloMódulo
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 3
Del CursoImagen Escrita 2012,
Alumno(s)Aalumnus Exemplaris
ProfesorHerbert Spencer

PFont font, small;       // declaro dos fuentes
int numIn, numOut, mod;  // declaro 3 enteros
color rojo;              // declaro 1 color

void setup(){
  size(300, 300);
  font = createFont("Georgia", 32);  // construyo las fuentes (objetos PFont)
  small = createFont("Georgia", 11);
  textAlign(CENTER);                 // defino que el texto será centrado
  numIn = numOut = 0;                // asigno variables 
  mod = 1;
  rojo = color(255, 100, 100);
}

void draw(){
  background(255);
  numOut = numIn % mod;              // el resultado

  fill(0);                           // dibujo el "serrucho"
  for(int i = 0; i < height; i++){  
                                     // pinte rojo si el menor que i
    if(numIn < i){
      stroke(0);
    }
    else{
      stroke(rojo);
    }

    int x = i % mod;
    line(i, height, i, height-x);
  } 

  fill(rojo);
  textFont(font, 32);
  text(numIn, width*1/6, height/2);
  text("%", width*2/6, height/2);
  text(mod, width*3/6, height/2);
  text("=", width*4/6, height/2);
  text(numOut, width*5/6, height/2);

  fill(0);
  textFont(small, 11);
  text("a [+]", width*1/6, height*2/5);
  text("z [-]", width*1/6, height*3/5-textAscent());
  text("s [+]", width*3/6, height*2/5);
  text("x [-]", width*3/6, height*3/5-textAscent());
}

// entrada del teclado para controlar el programa

void keyPressed(){
  if(key =='a'){
    numIn++;
  }
  if(key =='z'){
    numIn--;
  }
  if(key =='s'){
    mod++;
  }
  if((key =='x') && (mod > 1)){
    mod--;
  }
}