Thanks for pointing out that I shouldn't snap off a reply early in the
morning. Obviously I meant

     snappedX  = userCoord.x*Math.round( gridSizeX/gridSizeX );

Which makes a lot more sense than what I said before.

G. Wade

On Thu, 17 Nov 2005 13:08:50 +0000
Martyn Eggleton <[EMAIL PROTECTED]> wrote:

> G. Wade Johnson wrote:
> > Sorry to break in on this, but ...
> >
> > On Thu, 17 Nov 2005 10:34:18 +0000
> > Martyn Eggleton <[EMAIL PROTECTED]> wrote:
> >
> >   
> >> Ok I'll try (forgive if i end up patronising or not clear)
> >>
> >>     
> >
> > [snip]
> >
> >   
> >> function mousemove(evt)
> >> {
> >>
> >>     var gridSizeX = 1;  //The length of each element of the grid in the 
> >> userCordinate space, 0 is now snapping;
> >>     var gridSizeY= 1;
> >>     var userCoord = getUserCoordinate(evt.ClientX, evt.ClientY)  //you 
> >> will either have your own getUserCoordinate equivelant or go look one up 
> >> (eg kevlindev), I'm assuming it returns a point);   
> >>     var snappedX = userCoord.x;
> >>     var snappedY = userCoord.y;
> >>
> >>   if (gridSizeX)
> >>   {
> >>     snappedX  = Math.round(userCoord.x*gridSizeX)/gridSizeX;
> >>     
> >
> > shouldn't this be
> >
> >      snappedX  = Math.round( userCoord.x*gridSizeX/gridSizeX );
> >
> > You want to round after the divide.
> >   
> Sorry but mathatically that its the same as
> 
> snappedX  = Math.round( userCoord.x);
> 
> which doesn't allow you to specify the gridSizre at all
> 
> 
> >   
> >>   }
> >>
> >>   if (gridSizeY)
> >>   {
> >>     snappedY  = Math.round(userCoord.y*gridSizeY)/gridSizeY;
> >>     
> >
> > And, equivalently,
> >
> >      snappedY  = Math.round( userCoord.y*gridSizeY/gridSizeY );
> >
> >   
> >>   }
> >>
> >>    // do what you want from here on out.
> >>
> >> }
> >>     
> >
> > G. Wade
> >
> >   
> 
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> 
> -----
> To unsubscribe send a message to: [EMAIL PROTECTED]
> -or-
> visit http://groups.yahoo.com/group/svg-developers and click "edit my
> membership"---- 
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 


-- 
Results are what you wanted, consequences are what you got.
                                                 -- Michael VanDusen


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page
http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/1U_rlB/TM
--------------------------------------------------------------------~-> 

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to