Change the color of a Locator in a Manipulate
Use Appearance->SomeGraphicsObject
:
l = Graphics[{Red, Disk[{0, 0}, .1]}, ImageSize -> 10];
Manipulate[Graphics[{Line[{{0,0},pt}]},PlotRange->2],
{{pt,{0,0}},{-2,-2},{2,2},Locator,Appearance->l}]
You can use any Graphics
or Graphics3D
object for this, i.e.:
l = Graphics[{Red, Table[Circle[{0, 0}, i], {i, 3}]}, ImageSize -> 20];
or
l=Graphics3D[{Blue,Cylinder[],Red,Sphere[{0,0,2}],Black,Thick,Dashed,
Line[{{-2,0,2},{2,0,2},{0,0,4},{-2,0,2}}],Yellow,
Polygon[{{-3,-3,-2},{-3,3,-2},{3,3,-2},{3,-3,-2}}],Green,
Opacity[.3],Cuboid[{-2,-2,-2},{2,2,-1}]},ImageSize->50];
As far as I know, you can't change the colour of the default locator directly, but you could use the specification for the default locator to create a coloured version of the default locator. These specifications can be found in the file MiscExpressions.tr
located in $InstallationDirectory\SystemFiles/FrontEnd/TextResources
. It turns out that the locator is specified as
GraphicsBox[
InsetBox[GraphicsBox[{col, {AbsoluteThickness[1],
Antialiasing -> False,
LineBox[{{{0, -10}, {0, -2}}, {{0, 2}, {0, 10}}, {{-10, 0}, {-2,
0}}, {{2, 0}, {10, 0}}}], Antialiasing -> True,
CircleBox[{-0.5, 0.5}, 5]}, {AbsoluteThickness[3], Opacity[0.3],
CircleBox[{-0.5, 0.5}, 3]}}, ImageSize -> 17,
PlotRange -> {{-8, 8}, {-8, 8}}], {0, 0}, Center]]
So using this you could create a coloured locator by doing something like
loc[col_] := Rasterize[
ToExpression@
GraphicsBox[{col, {AbsoluteThickness[1], Antialiasing -> False,
LineBox[{{{0, -10}, {0, -2}}, {{0, 2}, {0, 10}}, {{-10, 0}, {-2,
0}}, {{2, 0}, {10, 0}}}], Antialiasing -> True,
CircleBox[{-0.5, 0.5}, 5]}, {AbsoluteThickness[3], Opacity[0.3],
CircleBox[{-0.5, 0.5}, 3]}}, ImageSize -> 17,
PlotRange -> {{-8, 8}, {-8, 8}}],
Background -> None]
Graphics[{Disk[], Locator[{0, 0}, loc[Darker[Green]]]}]
You could simply draw the locator with crosshairs. Color of circle, crosshairs and inner disk can be set as desired.
Manipulate[
Graphics[{Line[{{0, 0}, pt}]}, PlotRange -> 2],
{{pt, {0, 0}}, {-2, -2}, {2, 2}, Locator,
Appearance -> Graphics[{Black,
Line[{{0, 1.5}, {0, 3}}],Line[{{0, -1.5}, {0, -3}}],
Line[{{-1.5, 0}, {-3, 0}}], Line[{{1.5, 0}, {3, 0}}],
Circle[{0, 0}, 2], Blue, Disk[]}, ImageSize -> 20]}]
If you don't require a replica of the default locator and a single color suffices, you might use \[CircleDot]
or \[CirclePlus]
. For example,
Manipulate[Graphics[{Line[{{0, 0}, pt}]}, PlotRange -> 2],
{{pt, {0, 0}}, {-2, -2}, {2, 2}, Locator,
Appearance -> Style["\[CircleDot]", Blue, 24]}]