I am attempting to set an EventHandler
to change the radius of a circle by dragging on its circumference. But the response to the dragging is terribly slow. What is wrong with the code?
cnt[p_] := Return[Round /@ p];
grids[min_, max_] :=
Join[Range[Ceiling[min], Floor[max]],
Table[{j + 1, Lighter@Lighter@Lighter@Lighter@Blue}, {j,
Round[min], Round[max - 1], 1}]];
DynamicModule[{pnt = {1, 1}, VPOS = {1, 1}, rad = 1},
Dynamic@Graphics[
{Thick,
EventHandler[
Circle[ cnt[pnt] , rad],
{
"MouseDragged" :> (
VPOS = MousePosition["Graphics"];
rad = EuclideanDistance[pnt, VPOS];
)
},
PassEventsDown -> True
],
Locator[Dynamic[pnt], None]
},
Axes -> True,
GridLines -> grids,
PlotRange -> {{-10, 10}, {-10, 10}}]
]
EventHandler
a need? UsingLocator
might be easier. $\endgroup$EventHandler
. $\endgroup$EuclideanDistance
. $\endgroup$