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 › drawing a predefined shape every x amount of pixel
Page Index Toggle Pages: 1
drawing a predefined shape every x amount of pixel (Read 484 times)
drawing a predefined shape every x amount of pixel
Oct 23rd, 2007, 1:21am
 
hi,
in effect i would like to create a grid that contains a predefined shape (a conversion of a cross).
how do i set processing to draw this shape / cross for example every 100 pixels across and every 100 pixels down?
sorry, i know this should be easy but i am a complete beginner.
any help would be greatly appreciated
thanks
Re: drawing a predefined shape every x amount of p
Reply #1 - Oct 23rd, 2007, 8:28am
 
a very basic way to achieve this is to use 'for' loops :
http://processing.org/reference/for.html

Code:
void setup() {

size(400, 400);
background(255);

for (int x = 50; x < width; x+= 100) {
for (int y = 50; y < height; y+= 100) {
drawCross(x, y);
}
}

}

// draw a cross at (x, y) :
void drawCross(int x, int y) {
line(x-2, y, x+2, y);
line(x, y-2, x, y+2);
}


Page Index Toggle Pages: 1