Skip to content

Instantly share code, notes, and snippets.

@ramayac
Created April 29, 2013 21:13
Show Gist options
  • Save ramayac/5484810 to your computer and use it in GitHub Desktop.
Save ramayac/5484810 to your computer and use it in GitHub Desktop.
Ejemplo de una clase sencilla para generar un "grid" en Processing
class Grid{
float x, y;
int lineas_h = 3;
int lineas_v = 3;
int ancho;
Grid(int _x, int _y, int _lh, int _lv, int _a){
x = _x;
y = _y;
lineas_h = _lh;
lineas_v = _lv;
ancho = _a;
}
void draw(){
//Primero horizontales
float yy = y;
for(int i = 0; i < lineas_h; i++){
float auy = yy + ancho;
line(x, yy, x+width, yy);
yy = auy;
}
//Luego verticales
for(int i = 0; i < lineas_v; i++){
float aux = x + ancho;
line(x, y, x, y + height);
x = aux;
}
}
}
void setup(){
noLoop();
size(500, 500);
}
void draw(){
background(0);
stroke(255);
//Try different values
Grid g = new Grid(0, 0, 10, 10, 50);
g.draw();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment