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 › Coordinates adding and subtracting HELP
Page Index Toggle Pages: 1
Coordinates adding and subtracting HELP (Read 651 times)
Coordinates adding and subtracting HELP
Aug 14th, 2009, 5:41am
 
I need either a tutorial or help with fixing this code...
rectMode(CENTER)
mousePressed() {
 rect(mouseX, mouseY,mouseX + 1,mouseY + 1);
 fill(#BCBCBC);
}

to make it draw a square the same size anywhere on my screen with the center point being my mouse.

Re: Coordinates adding and subtracting HELP
Reply #1 - Aug 14th, 2009, 6:09am
 
Ravagence wrote on Aug 14th, 2009, 5:41am:
I need either a tutorial or help with fixing this code...
rectMode(CENTER)
mousePressed() {
 rect(mouseX, mouseY,mouseX + 1,mouseY + 1);
 fill(#BCBCBC);
}

...to make the two highlighted parts actually work.

I just want a small square around the center point of the rectange.



With rectMode(CENTRE), you specify the width and height of the rect, as the 3rd and 4th arguments, not the bottom right corner coords, so:

rect(mouseX,mouseY,10,10); is probably more what you're looking for.
Re: Coordinates adding and subtracting HELP
Reply #2 - Aug 14th, 2009, 6:21am
 
Thanks, and your right on about the measurements of the rectangle, That's exactly it. Cheesy
Page Index Toggle Pages: 1