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 › beginner's question: using "width" to modify for()
Page Index Toggle Pages: 1
beginner's question: using "width" to modify for() (Read 1500 times)
beginner's question: using "width" to modify for()
Apr 21st, 2005, 5:13am
 
I am looking at the example "Conditionals 1" by REAS and I don't understand how width and height can be used. I don't know what "width" and "height" they are referring to.

I assume this is a really basic programming question, but still I'm just not seeing the light.

Thanks, Regina

// Conditionals 1
// by REAS <http://reas.com>

// Conditions are like questions.
// They allow a program to decide to take one action if
// the answer to a question is true or to do another action
// if the answer to the question is false.
// The questions asked within a program are always logical
// or relational statements. For example, if the variable 'i' is
// equal to zero then draw a line.

// Created 2 September 2002

size(200, 200);
background(0);

for(int i=10; i<width; i+=10) {
 // If 'i' divides by 20 with no remainder draw the first line
 // else draw the second line
 if(i%20 == 0) {
   stroke(153);
   line(i, 40, i, height/2);
 } else {
   stroke(102);
   line(i, 20, i, 180);
 }
}
Re: beginner's question: using "width" to modify f
Reply #1 - Apr 21st, 2005, 5:34am
 
when you define
Code:
size(200, 200);  



The first number is width, and the second number is height. It refers to the width and height of the applet Smiley
Re: beginner's question: using "width" to modify f
Reply #2 - Apr 22nd, 2005, 1:23am
 
To elaborate, they are measured in pixels. The width is the number of pixels in any horizontal row, while the height is the number of pixels in any vertical column.

Ignoring the oval in the center, this image might help you:
...
Page Index Toggle Pages: 1