Computer Science Canada Snap To Grid and Draw... |
Author: | TheXploder [ Mon Jan 26, 2004 11:51 am ] | ||
Post subject: | Snap To Grid and Draw... | ||
I'm making a Paint like program and I got a box that moves along with your mouse as you move it, and it snaps to the grid pattern. But when you zoom in or zoom out the box doesn't fit to the grid anymore its offset.
*mousex, and mousey are the positions of the mouse and Zoom is a variable that can be anywhere from 3 to 14. I'm guessing that 'round' makes it not exact as the zoom value increases, yet I want it to be in an integer value. Some values do fit, but I'm guessing the odd ones don't, how do I change that?... |
Author: | McKenzie [ Mon Jan 26, 2004 12:00 pm ] | ||||
Post subject: | Re: Snap To Grid... | ||||
TheXploder wrote:
do the mult first to reduce roundoff error |
Author: | TheXploder [ Mon Jan 26, 2004 12:12 pm ] |
Post subject: | |
hmm that doesn't work, now it's just following the exact position of the mouse, I want it to snap each Zoom value of pixels... |
Author: | TheXploder [ Mon Jan 26, 2004 12:26 pm ] | ||||||
Post subject: | |||||||
here is an example what I'm getting at...
* Try changing the zoom values... If you change this:
To that it works better but the position of the mouse doesn't fit:
|
Author: | McKenzie [ Mon Jan 26, 2004 12:51 pm ] | ||
Post subject: | |||
sorry
|
Author: | TheXploder [ Mon Jan 26, 2004 1:00 pm ] |
Post subject: | |
Thx a lot... I ow you one... |
Author: | TheXploder [ Mon Jan 26, 2004 3:26 pm ] | ||
Post subject: | |||
Another problem came up so thats why I'll just change the topics name... This time when you press down the left mouse button I want it to draw boxes, but that doesn't work, it just moves along... * I'll give some bits for a solution...
|
Author: | McKenzie [ Mon Jan 26, 2004 5:41 pm ] | ||
Post subject: | |||
All too easy... (oops thats Vader not Yoda) |
Author: | thoughtful [ Mon Jan 26, 2004 5:48 pm ] | ||
Post subject: | |||
Okay here, you had the code done pretty good, the only problem was that you proc objDrawWindow was actually coloring the whole field grey and it did that every time the loop executed, thts why it only showed u one box. Here i fixed it up for u, and you can keep the bits, i am always glad to help
|
Author: | the_short1 [ Mon Jan 26, 2004 5:50 pm ] |
Post subject: | |
Can someone post the Final of this with all. corrections as a .t file...????PLease and Thankyou |
Author: | McKenzie [ Mon Jan 26, 2004 5:58 pm ] |
Post subject: | |
thoughtful and I have the same solution, thoughtful was just more well...thoughtful about it so he didnt know that I already posted. He has the full solution in his post. (Hmmm, thoughtful, if yer not a "him" let me know I'll edit) |
Author: | DanShadow [ Mon Jan 26, 2004 9:19 pm ] | ||||
Post subject: | |||||
Maybe instead of all the complexity, use a 1D grid:
Then to draw...do this:
or something similar to that. Hope this helps! |
Author: | TheXploder [ Mon Jan 26, 2004 9:42 pm ] |
Post subject: | |
[edit] oops |