Message Boards Message Boards

Do Dynamic locators work on the cloud?

GROUPS:

In Stephen Wolfram's book (Elementary Introduction...) he says "...in a web page you'll be able to use active sliders... though they'll run slower than if they were directly on your computer" (1st ed., p.218). Fair enough, but I wonder if other objects such as dynamic locators actually work on the cloud at all. I just deployed a notebook with a dynamic locator which should move when dragged, but it simply doesn't seem to work at all. Sliders work, although somewhat slow, as expected.

POSTED BY: Tomas Garza
Answer
10 days ago

A support for Locator on WPC is limited but exists. From my experience the only way to make it work is to use LocatorPane or to use Manipulate with its variable having Locator control type.

Also, Arrow[{{0, 0}, Dynamic@x}] won't work out of the box, you need to have whole Graphics wrapped with Dynamic, otherwise it won't update.

So while on a desktop this works:

DynamicModule[{x = {1, 1}},
 Graphics[{Gray, Arrow[{{0, 0}, Dynamic@x}], Locator@Dynamic@x}, PlotRange -> 1, Frame -> True]
 ]

it won't on a cloud and you need:

Manipulate[
  Graphics[{Gray, Arrow[{{0, 0}, x}]}, PlotRange -> 1, Frame -> True],
  {{x, {1, 1}}, Locator}
] // CloudDeploy[#, Permissions -> "Public"] &

(*notice no Dynamic on x, instead the body of the manipulate is taking care about updates*)

or

CloudDeploy[
   DynamicModule[{x = {1, 1}},
     LocatorPane[Dynamic[x], 
       Dynamic@Graphics[{Gray, Circle[], Arrow[{{0, 0}, x}]}]]
  ], Permissions -> "Public"
]
POSTED BY: Kuba Podkalicki
Answer
10 days ago

Thanks very much, Kuba. Both the approaches you suggest work, but the latency time is too large. For all intents and purposes, working with a dynamic locator on the cloud seems to be out of the question. The following piece of code is a small part of the kind of situation I'm dealing with, where the red vertex at the top should move smoothly as you drag it around. So far, I have changed the control to a 2D slider, which improves only slightly on the locator performance.

Manipulate[Module[{pA = {-1, 0},
pB = {1, 0}},
loc = Locator[
Dynamic[pC, (pC = {Min[Max[#[[1]], -1.5], 1], 
Min[Max[#[[2]], 0.3], 2]}) &], 
Graphics[{Red, EdgeForm[Black], Disk[{0, 0}, 0.1]}, 
ImageSize -> 10]];

Graphics[{Style[Text["A", pA, {1, 1}], 12], 
Style[Text["B", pB, {-1.5, 0}], 12], 
Style[Text["C", pC, {0, -2}], 12], {Yellow, 
Triangle[{pA, pB, pC}]},
{Thickness[0.005], Line[{pC, pA, pB, pC}]},
loc},
PlotRange -> {{-2, 2}, {-0.5, 3.0}}, 
ImageSize -> 500]], {{pC, {0.22, 1.1}}, ControlType -> None}]
POSTED BY: Tomas Garza
Answer
10 days ago

The problem is that only locator is handled client side and everything is sent to the cloud for a new polygon. In general it may be possible to make simple primitives work client side but I haven't heard any news about that from WRI.

POSTED BY: Kuba Podkalicki
Answer
10 days ago

Ok, so it´s better to forget about dynamic locators on the cloud. Thanks, anyway.

POSTED BY: Tomas Garza
Answer
9 days ago

Group Abstract Group Abstract