MathGroup Archive 2011

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

Search the Archive

Re: Plotting Locators with Color

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118147] Re: Plotting Locators with Color
  • From: "Alexander Elkins" <alexander_elkins at hotmail.com>
  • Date: Thu, 14 Apr 2011 04:50:06 -0400 (EDT)
  • References: <io17da$i4a$1@smc.vnet.net>

The appearance of the default locator is defined in
"SystemFiles\FrontEnd\TextResources\MiscExpressions.tr".

There are two default definitions, "LocatorDefaultThumb" and
"LocatorDefaultThumbDisabled", the one that is chosen depends
on the locator's Enabled option.

You can use:

InputForm[
 ToExpression[
  StringReplace[
   ToString[
    CurrentValue[
      FEPrivate`FrontEndResource["FEExpressions",
       "LocatorDefaultThumb"]][[1, 1, 1]]], "Box" -> ""]]]

to get the basic locator appearance to start with:

Graphics[{{AbsoluteThickness[1], Antialiasing -> False,
   Line[{{{0, -10}, {0, -2}}, {{0, 2}, {0, 10}}, {{-10, 0}, {-2, 0}},
     {{2, 0}, {10, 0}}}], Antialiasing -> True, Circle[{-0.5, 0.5}, 5]},
  {AbsoluteThickness[3], Opacity[0.3], Circle[{-0.5, 0.5}, 3]}},
ImageSize -> 17,
 PlotRange -> {{-8, 8}, {-8, 8}}]

Here is your example using colored locators:

Needs["Splines`"]

Manipulate[
 LocatorPane[pts; Dynamic@pts,
  Dynamic@Graphics[{Spline[pts, Bezier]}, Axes -> True,
    AxesLabel -> {x, y}, PlotRange -> {{-3, 3}, {-3, 3}},
    Background -> LightOrange],
  Appearance ->
   Table[Graphics[{c, {AbsoluteThickness[1], Antialiasing -> False,
       Line[{{{0, -10}, {0, -2}}, {{0, 2}, {0, 10}}, {{-10, 0}, {-2,
           0}}, {{2, 0}, {10, 0}}}], Antialiasing -> True,
       Circle[{-0.5, 0.5}, 5]}, {AbsoluteThickness[3], Opacity[0.3],
       Circle[{-0.5, 0.5}, 3]}}, ImageSize -> 17,
     PlotRange -> {{-8, 8}, {-8, 8}}], {c, {Blue, Red, Green,
      Brown}}]], {{pts, {{0, 0}, {0, 2}, {2, 0}, {2,
     2}}}, {-3, -3}, {3, 3}, ControlType -> None},
 SaveDefinitions -> True, Initialization :> {Needs["Splines`"]},
 AutorunSequencing -> {2}]

Please note the same result can be achieved in Manipulate without using
LocatorPane and Dynamic as follows:

Needs["Splines`"]

Manipulate[
 Graphics[{Spline[pts, Bezier]}, Axes -> True,
  AxesLabel -> {"x", "y"}, PlotRange -> 3,
  Background ->
   LightOrange], {{pts, {{0, 0}, {0, 2}, {2, 0}, {2, 2}}}, Locator,
  Appearance ->
   Table[Graphics[{c, {AbsoluteThickness[1], Antialiasing -> False,
       Line[{{{0, -10}, {0, -2}}, {{0, 2}, {0, 10}}, {{-10, 0}, {-2,
           0}}, {{2, 0}, {10, 0}}}], Antialiasing -> True,
       Circle[{-0.5, 0.5}, 5]}, {AbsoluteThickness[3], Opacity[0.3],
       Circle[{-0.5, 0.5}, 3]}}, ImageSize -> 17,
     PlotRange -> {{-8, 8}, {-8, 8}}], {c, {Blue, Red, Green,
      Brown}}]}]

Enjoy!

"Bill" <WDWNORWALK at aol.com> wrote in message
news:io17da$i4a$1 at smc.vnet.net...
> Hi:
>
> I'm using Mathematica 8.0.1. on a PC with the following code:
>
> Manipulate[
>  LocatorPane[pts; Dynamic@pts,
>   Dynamic@Graphics[{Spline[pts, Bezier]}, Axes -> True,
>     AxesLabel -> {x, y}, PlotRange -> {{-3, 3}, {-3, 3}},
>     Background -> LightOrange]], {{pts, {{0, 0}, {0, 2}, {2, 0}, {2,
>      2}}}, {-3, -3}, {3, 3}, ControlType -> None},
>  SaveDefinitions -> True, Initialization :> {Needs["Splines`"]},
>  AutorunSequencing -> {2}]
>
> How can I plot this with each locator plotted in a  different color?
>
>
> Thanks,
>
> Bill
>




  • Prev by Date: Re: Workbench question: Is there a $WorkbenchCurrentWorkingDirectory
  • Next by Date: FindFit[] Blues
  • Previous by thread: Re: Plotting Locators with Color
  • Next by thread: Re: Plotting Locators with Color