Skip to main content

Prototyping

AF is build on top of the existing concepts of Dynamics used in WLJS Notebook ecosystem. Therefore, you can use Command palette's gizmos as well as everything what is mentioned in the guide Prototyping.

For example, you planning a scene and you are not sure about the scale of your image:

Needs["AnimationFramework`" -> "af`"] // Quiet
s = af`Scene[];
Framed[s]
round[i_, r_] :=
Module[{w, h},
{w, h} = ImageDimensions@i;
With[{
f = Reverse,
p = PadRight[DiskMatrix[r][[;; r, ;; r]], {h, w}, 1]},
i~ImageAdd~ColorNegate@Image[p f /@ p f@p f[f /@ p]]]]

image = round[Colorize[Blur[RandomImage[LaplaceDistribution[0.1, .1], {200, 200}],20]], 30];

next = InputButton[]

AsyncFunction[scene, Module[{object},
object = af`AddTo[scene, Scale[Inset[image, {0,0}], 0.5]];
next // Await;
af`Remove[object];
]][s];

Now select the scaling value 0.1

and then call a Command palette using top-bar or Ctrl/Cmd + P:

Now it is interactive and you can re-evaluate this cell:

The same can be done with dragging and etc, positioning the text, objects:

Here we used drag gizmo with added offset to prevent overlapping:

Offload or Hold is needed to prevent Wolfram Kernel from applying vector math and adding our control box to each coordinate of the vector.

Here is another example with Rectangle and rounding radius with a slider helper: