With[{source = ExampleData[{"TestImage", "Lena"}]},
With[{dimensions = ImageDimensions[source]},
n = 10;
sub = Subdivide[-1, 1, n];
grid =
Graphics[{},
GridLines -> {sub, sub},
PlotRangePadding -> None,
GridLinesStyle -> Directive[White, Thick],
ImageSize -> ImageDimensions @ source];
Manipulate[
Overlay[{source, grid}],
{{r, .05,Style["r", Bold, 15]}, .02, .5, .01, ImageSize -> 500},
{{pt, dimensions/2}, Locator, Appearance -> disk[r]},
Dynamic @
Row[{Style["Posición = ", Bold, 15], Style[{pt[[1]], pt[[2]]}, Bold, 15]}],
ControlPlacement -> Top,
Initialization :> (
disk[r_] :=
Graphics[
{White, Opacity[.4], EdgeForm[Black], Disk[{0, 0}, ImageScaled[r]]},
ImageSize -> dimensions])]]]
1) I am trying to add a 3rd option:
Overlay[{source, grid, text}],
Where text
has to be a lot of references with a static positions over the image.
I tried with:
text = Graphics[{}, Text["Reference1"], {p1x, p1y}];
But it doesn't work! the text appears anywhere!
In this case "Reference1" is the name of a city or place. It has to be static even if I change the scale of the image.
2) I tried to change this too:
{{pt0, {dimensions[[1]], dimensions[[2]]}}, Locator,
Appearance -> disk[(r0/dimensions)/proporcion, White]},
I want to see the coordinates over the locator disk. I tried to add Text
inside the Disk
, outside, and even in the locator itself but it doesn't work.
I saw too that the text can be add inside the Disk
but I think that Appearance
doesn't support it.
In this case "Reference" is the coordinate of the Locator
.
EDIT: (with Answer 1)
My code has 4 disk:
{{pt0, {dimensions[[1]] (0.51), dimensions[[2]] (0.525)}}, Locator, Appearance -> disk[(r0/dimensions)/proporcion, White, pt0]},
{{pt1, {dimensions[[1]] (0.59), dimensions[[2]] (0.6)}}, Locator, Appearance -> disk[(r1/dimensions)/proporcion, Red, pt1]},
{{pt2, {dimensions[[1]] (0.465), dimensions[[2]] (0.47)}}, Locator, Appearance -> disk[(r2/dimensions)/proporcion, Green, pt2]},
{{pt3, {dimensions[[1]] (0.44), dimensions[[2]] (0.6)}}, Locator, Appearance -> disk[(r3/dimensions)/proporcion, Blue, pt3]},
And I introduced a change (for color):
Initialization -> (
disk[r_, color_, pt_] :=
Graphics[{{Opacity[.4, color], EdgeForm[Black],
Disk[{0, 0}, Scaled[r]]}, {Thick,
Line[{Scaled@{.5 - r/8, .5}, Scaled@{.5 + r/8, .5}}],
Line[{Scaled@{.5, .5 - r/8}, Scaled@{.5, .5 + r/8}}]}, {Text[
Framed[Style[Row[pt, ","], Bold, 12], FrameMargins -> Tiny,
Background -> Opacity[.4, White]], Scaled@{.5, .52 + r}]}},
ImageSize -> dimensions])]]]
Before:
Initialization -> (disk[r_, color_, pt_] :=
Graphics[{color, Opacity[.4], EdgeForm[Black],
Disk[{0, 0}, ImageScaled[r]]}, ImageSize -> dimensions])]]]
With the 1st initialization each disk creates a gigant red square and no text.
I correct it like this:
Initialization -> (
disk[r_, color_, pt_] :=
Graphics[{{Opacity[.4, color], EdgeForm[Black],
Disk[{0, 0}, Scaled[r]]}, {Thick(*,Line[{Scaled@{.5-r/8,.5},
Scaled@{.5+r/8,.5}}],Line[{Scaled@{.5,.5-r/8},Scaled@{.5,.5+
r/8}}]*)}, {Text[
Framed[Style[Row[pt, ","], Bold, 12], FrameMargins -> Tiny ,
Background -> Opacity[.4, White]](*,Scaled@{.5,.52+
r}*)]}}, ImageSize -> dimensions])]]]
All the commented code brokes the program itself.
Anyway to "move" the label over the disk? not inside.