[Date Index]
[Thread Index]
[Author Index]
Re: How Can I Change the Appearance of a Locator in Manipulate
*To*: mathgroup at smc.vnet.net
*Subject*: [mg132268] Re: How Can I Change the Appearance of a Locator in Manipulate
*From*: Gregory Lypny <gregory.lypny at videotron.ca>
*Date*: Tue, 28 Jan 2014 06:14:23 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: l-mathgroup@wolfram.com
*Delivered-to*: mathgroup-outx@smc.vnet.net
*Delivered-to*: mathgroup-newsendx@smc.vnet.net
*References*:
Hi Alexei,
Thanks. Exactly what I needed!
Gregory
On Mon, Jan 27, 2014, at 3:50 AM, Alexei Boulbitch <Alexei.Boulbitch at iee.lu> wrote:
> Hello everyone,
>
> Is it possible to change the appearance of a locator in a Manipulate? The only change I've been able to make is to make it invisible using Appearance -> None, as in
>
> {{pt2, {80, 80}}, Locator, Appearance -> None}
>
> but other appearance options, such as Small or Large, do not work.
>
> Gregory
>
>
>
>
> Hallo, Gregory,
>
> you can form a custom appearance of Locator by unifying a graphics object (here named "loc") with a graphics operator as follows:
> Locator[{x,y}, loc]. The object "loc" should be constructed as any other stand-alone graphics object. That is it must be wrapped by the Graphics statement. The only unusual thing is that the size of this object should be rather small, controlled by the ImageSize option, as usually. According to my taste that is 30. Below three custom-defined locators loc1, loc2 and loc3 are built as examples:
>
> loc1 = Graphics[{Red,
> Thick, {Line[{{-0.01, 0}, {-0.002, 0}}],
> Line[{{0.002, 0}, {0.01, 0}}], Line[{{0, -0.01}, {0, -0.002}}],
> Circle[{0, 0}, 0.007]}}, ImageSize -> 30];
>
> loc2 = Graphics[{{Blue, Thick, Circle[{0, 0}, 2]}, {Blue, Thin,
> Circle[{0, 0}, 1]}}, ImageSize -> 20];
>
> loc3 = Graphics[{White, Circle[{0, 0}, 0.01, {0, 2 \[Pi]}], Thick,
> Arrowheads[0.4], {Red, Arrow[{{-0.02, 0}, {-0.002, 0}}]}, {Red,
> Arrow[{{0.02, 0}, {0.002, 0}}]}, {Red,
> Arrow[{{0, -0.02}, {0, -0.002}}]}}, ImageSize -> {30, 30}];
>
> Here they are combined with a graphics by using the Show statement:
>
> Show[{Plot[Sin[x], {x, 0, \[Pi]}],
> Graphics[Locator[{1.5, 0.6}, loc1]],
> Graphics[Locator[{1.5, 0.8}, loc2]],
> Graphics[Locator[{1.7, 0.3}, loc3]]}]
>
> Of course, you may use any graphics object as the locator. For example, evaluate the famous Wolfram "Lena" image as the locator:
>
> locLena = Import["ExampleData/lena.tif"];
>
> DynamicModule[{pt2 = Scaled[{0.5, 0.2}]},
> Show[{
> Plot[Sin[x], {x, 0, \[Pi]}],
> Graphics[Line[{Scaled[{0.5, 0.5}], Dynamic@pt2}]],
> Graphics[Locator[Dynamic@pt2, locLena]]
> }, ImageSize -> 600]
> ]
>
> The same one can do within Manipulate (by simply wrapping Manipulate around the graphics containing locator). For example, evaluate this:
>
> Manipulate[
> (* This defines a custom locator *)
> loc = Graphics[{Red,
> Thick, {Line[{{-0.01, 0}, {-0.002, 0}}],
> Line[{{0.002, 0}, {0.01, 0}}], Line[{{0, -0.01}, {0, -0.002}}],
> Circle[{0, 0}, 0.007]}}, ImageSize -> 30];
> (* End of the locator definition *)
>
> (* Beginning of the graphics *)
> DynamicModule[{pt = Scaled[{0.5, 0.5}]},
> Show[{Plot[Sin[k*x], {x, 0, 2 \[Pi]}],
> Graphics[Line[{Scaled[{0.5, 0.5}], Dynamic@pt}]],
> Graphics[Locator[Dynamic@pt, loc]]}
> ]]
> (* End of the graphics*),
> {k, 1, 2}
> ]
>
>
> Here the locator degree of freedom, pt, does not interfere with the Manipulate parameter k. However, Manipulate also offers an additional possibility to cope with the locator degree of freedom as its own parameter. It is achieved by the Appearance->locator option, where "locator" is the custom-built locator. Below please find below two examples of custom locators in the two manipulate statements of this latter sort. I arranged them in a row to visualize them simultaneously:
>
> locator1 = Graphics[{Red, Disk[{0, 0}, .1]}, ImageSize -> 10];
> locator2 =
> Graphics[{Red, Table[Circle[{0, 0}, i], {i, 3}]}, ImageSize -> 20];
>
> Row[{
> Manipulate[
> Graphics[{Line[{{0, 0}, pt}]}, ImageSize -> 200,
> PlotRange -> 2], {{pt, {0, 0}}, {-2, -2}, {2, 2}, Locator,
> Appearance -> locator1}],
> Manipulate[
> Graphics[{Line[{{0, 0}, pt}]}, ImageSize -> 200,
> PlotRange -> 2], {{pt, {0, 0}}, {-2, -2}, {2, 2}, Locator,
> Appearance -> locator2}]
> }]
>
> Evaluate this and have a look.
>
> Have fun and success, Alexei
>
>
> Alexei BOULBITCH, Dr., habil.
> IEE S.A.
> ZAE Weiergewan,
> 11, rue Edmond Reuter,
> L-5326 Contern, LUXEMBOURG
>
> Office phone : +352-2454-2566
> Office fax: +352-2454-3566
> mobile phone: +49 151 52 40 66 44
>
> e-mail: alexei.boulbitch at iee.lu
>
>
Prev by Date:
**Re: Need Help With Locator in a Manipulate**
Next by Date:
**Re: switching axes in Plot?**
Previous by thread:
**Re: How Can I Change the Appearance of a Locator in Manipulate**
Next by thread:
**Re: How Can I Change the Appearance of a Locator in Manipulate**
| |