|
Author |
Topic: question on an example-program (Read 396 times) |
|
der_rabe
|
question on an example-program
« on: Dec 26th, 2003, 12:21pm » |
|
i browsed through the example-codes which came with processing and found the following: Code: void setup() { size(200, 200); background(102); } void loop() { stroke(255); if(mousePressed && pmouseX != 0 && pmouseY != 0) { line(mouseX, mouseY, pmouseX, pmouseY); } } |
| this is a simple drawing-programm. what i don't understand is, why the if-brackets contain the conditions: pmouseX and pmouseY. It does not make sense to me. either i am in the field or i am out of the field. and 0 is in the field, am i right. so why shouldn't the pmouse-Value != 0? Can you follow me? i changed the code, just erasing the pmouse-conditions and the programm worked as good as before. maybe you can help me to understand?
|
Bernd Salewski student of digital media Hochschule Bremen
|
|
|
kevin
|
Re: question on an example-program
« Reply #1 on: Dec 26th, 2003, 10:33pm » |
|
Hi, I'm not 100% sure on this, but I expect that it's to save processing power. e.g. if the position is registered as 0, then the mouse is off the screen and there's no need to draw the line? - Kevin
|
|
|
|
arielm
|
Re: question on an example-program
« Reply #2 on: Dec 26th, 2003, 10:41pm » |
|
i think the reason for this trick is to avoid an unecessary line to be drawn from the top-left corner in case the user is pressing the mouse at startup...
|
Ariel Malka | www.chronotext.org
|
|
|
|