What I am trying to achieve can be described using following code:
vector = {{0, 0}, {1, 0}};
Graphics[Circle[#, 1] & /@ vector]
In the above, a pure function is applied to Map given vector to construct a set of Circle objects. Same type of logic is applied below, however it does not compile and throws an error:
Coordinate {{0, 0}, {1, 0}} should be a pair of numbers, or a Scaled or Offset form
Code:
DynamicModule[
{vector, range, radius},
(*Parameters*)
radius = 5;
range = {{0, 100}, {0, 100}};
vector = {{0, 0}, {1, 0}};
EventHandler[
Show[
Graphics[{
(*Composition*)
Line[Dynamic[vector]],
Circle[#, radius] & /@ Dynamic[vector] (*Error*)
}],
(*Options*)
PlotRange -> range, Axes -> True],
{
(*Events*)
"MouseClicked" :> (AppendTo[vector, MousePosition["Graphics"]])
}
]
]
Why does MMA generates the error stated above and how can it be bypassed? Essentially, I want to have a Circle around ea. Point which forms part of the Line.
Dynamic[vector]
is incorrect usage. Best way to always think aboutDynamic
is that it dynamically updates pixels on the screen. When you consider that definition it should be apparent whyDynamic[vector]
is incorrect. The next problem that arises from that usage is that the syntax forCircle
becomes incorrect which is why you see the pink boxes. $\endgroup$