Saltar al contenido Saltar a la navegación

Constanza Valdivia: Ciclo For


TítuloCiclo For
Palabras Clavetarea 2
AsignaturaImagen Escrita,
Del CursoImagen Escrita 2013 - DIS,
CarrerasDiseño Gráfico"Diseño Gráfico" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property., Diseño Industrial"Diseño Industrial" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property.
Alumno(s)Constanza Valdivia



float margen, xSpace, ySpace;
int xElems, yElems;
void setup() {
  
  size(500, 500);
    margen = 80;
  xElems = 20;
  yElems = 20;
  calc();
   mouseX = xElems;
  mouseY = yElems;
  }

void draw() {
  
  background(255);
  stroke(242,172,115);
  strokeWeight(4);
  fill(237,99,86);
  
  xElems = (int) mouseX / 10;
  yElems = (int) mouseY / 10;
  calc();
  for (float y = margen; y <= height-margen; y += ySpace) {
    for (float x = margen; x <= width-margen; x += xSpace) {
      rect(x,y,10,10); 
    }
  }
}

void calc() {
  xSpace = (width - 2 * margen) / (float)(xElems - 1);
  ySpace = (height - 2 * margen) / (float)(yElems - 1);
}