We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › making a basic modular grid
Page Index Toggle Pages: 1
making a basic modular grid (Read 1450 times)
making a basic modular grid
Dec 26th, 2009, 8:13am
 
hello everyone,
first of all i am totally new to this. i'm a graphic designer and just recently started playing around with Processing (i know, i know, needy n0obie).
i need to make a simple grid (for now), and seeing as i have specific pixel values for the lines

but i found a post here about a grid, the sketch is far too complex for my beginner skills, so i was wondering is someone knows a simple way to draw such grid (and being able to assign the pixel values) knowing that later, if i manage to learn more i would hope to make this grid interactive somehow, making the lines fall and collapse etc)
i would REALLY appreciate any help. Thanks :)

Re: making a basic modular grid
Reply #1 - Dec 26th, 2009, 9:22am
 
Can you give an example of what you have in mind ?
Re: making a basic modular grid
Reply #2 - Dec 26th, 2009, 10:10am
 
Something like this?

Code:

int nbOfHorizontalLines = 10;
int nbOfVerticalLines = 20;

void setup()
{
 size (1000,500);
}

void draw()
{
 background (100,100,100);
 stroke(255,0,0);

 float distanceBetweenHorizontalLines = (float)height/nbOfHorizontalLines;
 float distanceBetweenVerticalLines = (float)width/nbOfVerticalLines;

 for(int i = 0; i < nbOfHorizontalLines; i++)
 {
   line(0, i*distanceBetweenHorizontalLines, width, i*distanceBetweenHorizontalLines);

 }

 for(int i = 0; i < nbOfVerticalLines; i++)
 {
   line (i*distanceBetweenVerticalLines,0,i*distanceBetweenVerticalLines, height);
 }
}
Re: making a basic modular grid
Reply #3 - Jan 2nd, 2010, 2:19am
 
THANK YOU!
i had reached the same result but with hundreds of pasted values for ++ straight lines, this was very helpful, will now try to figure out how you got to that Smiley
Cheers!
Page Index Toggle Pages: 1