I'm trying to simply overlay some text and a scalebar onto an image. I'm getting (what I perceive to be) completely ridiculous results while trying to do this.
Here's the code:
img = Import@"http://i.imgur.com/PVUXYz5.png"
Manipulate[
overlay =
Graphics[{Text[Style["50 Magnets", White, 30], {250, 250}], {White,
AbsoluteThickness[5], Line[{{i, 200}, {i + 50, 200}}]}}];,
{i, 1, 450, 1}]
Dynamic@Overlay[{img, overlay}]
The only thing I'm Manipulate
ing, as far as I can see, is the x-values of the points where I'd like my Line
to show up. When I increase i
, I expect the Line
just to move from left to right. Instead, the line shrinks and grows in size and translates around.
Not only that, but the Text
moves around, too! I cannot for the life of me see why this is happening. I expect that I have a misunderstanding of how Graphics
is working, but even breaking it up into two Graphics
objects and combining them with Show
results in the exact same behavior.
Does anybody know why this happens and what I could do to fix it? Ostensibly, adding two words and a line to an image (and mapping this operation to a list of images once I figure this out) shouldn't be difficult, but this may be the oddest behavior I've ever seen from Mathematica and I'm just totally clueless.
PlotRange
inGraphcis
;, e.g.,PlotRange -> {{0, 500}, {0, 500}}
? $\endgroup$ImageDimensions
returns 500x500, but that's not how it's rendering. Even forcingImageSize
doesn't change it. $\endgroup$