Background
DynamicLocation
can be very useful:
LocatorPane[Dynamic@x,
Graphics[
{ EdgeForm @ Thick, FaceForm @ None, Rectangle[BoxID -> "box"]
, Arrow[{Dynamic[x], DynamicLocation["box", Automatic]}]
}
, PlotRange -> 2
]
]
but I don't know much about it. It was introduced to me by Szabolcs somewhere around this topic: Find inset bounding box in plot coordinates. It is extensively used in Graph
related plots, e.g. to make edge arrows pointing neatly to the edge of a vertex shape.
As shown above it can be used to specify position in Graphics
with respect to primitives' boxes. So we can point e.g. Arrow to a Recangle, without knowing it's position, which was previously marked by BoxID
. (see more: BoxID in InputField focus)
It also accepts more arguments which can e.g. automatically point to the closest point on marked primitive. Something that would normally cost us calling the kernel for some region related procedures.
Question
But what arguments does it accept and what do they do? What are possible pitfalls in using it?
What did I try?
From Graph related documentation pages I extracted only examples with:
DynamicLocation[id_String, Automatic | None, _alignmentSpec]}]
Where alignmentSpec
is {Left, Center}
etc.
I also noticed that its behavior depends of parent graphics primitive (not id's owner):
LocatorPane[Dynamic@x,
Graphics[
{EdgeForm@Thick, FaceForm@None, Rectangle[BoxID -> "box"]
, Rectangle[Dynamic[x], DynamicLocation["box", Automatic]]
, Arrow[{Dynamic[x], DynamicLocation["box", Automatic]}]
}
, PlotRange -> 2]
]
So the same DynamicLocation is points to different positions for Rectangle and Arrow, keep that in mind in your answer.
Comments
Post a Comment