MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: locator snap

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88266] Re: locator snap
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Wed, 30 Apr 2008 04:23:54 -0400 (EDT)
  • Organization: University of Bergen
  • References: <fv6ukg$rmt$1@smc.vnet.net>

Maarten van der Burgt wrote:
> Dear all,
> 
> In the example below the locator can be moved to any position in the graphic.
> Can the locator be made to snap to multiples of say 0.1?
> 
>  Manipulate[Column@{Graphics[{}, Axes -> True], p}, {{p, {0, 0}}, Locator}]
> 

Hi Maarten,

I am not aware of any way to do this directly with Manipulate. (Of 
course this does not mean that there doesn't exist a way!)

Here is an example of doing it directly with Dynamic:

Graphics[
  Locator[Dynamic[{x, y}, ({x, y} = Round[#, 0.1]) &]],
  PlotRange -> 1, Frame -> True,
  GridLines -> {#, #} & @
   Table[{x, If[Mod[x, 1/2] == 0, Black, Gray]}, {x, -1, 1, 1/10}]
  ]

Szabolcs

P.S.  Sorry for the convoluted grid line construction


  • Prev by Date: Re: 3D Arrows
  • Next by Date: Re: Does Mathematica really need more printed, introductory documentation?
  • Previous by thread: Re: locator snap
  • Next by thread: Re: locator snap