Mathematica's native Manipulate and Animate #389
Replies: 9 comments 2 replies
-
ok, sorry. I updated to the latest and it looks good now! With MMAView and
this update, (and so many other changes), this is an absolutely impressive
piece of work!
Any chance, MMAView can be integrated into animation like Manipulate?
Thanks a bunch!
gani -
On Wed, May 7, 2025 at 12:03 PM Gani Ganapathi ***@***.***>
wrote:
… Very nice! But my output looks different.
[image: Screenshot 2025-05-07 at 12.01.09 PM.png]
I got a bunch of warnings (which vanish very quickly) and then this output.
gani --
On Wed, May 7, 2025 at 5:29 AM Kirill Vasin ***@***.***>
wrote:
> *JerryI* left a comment (WLJSTeam/wolfram-js-frontend#184)
> <#184 (comment)>
>
> Finally made it works after 1 year ;)
> Screenshot.2025-05-07.at.10.32.16.png (view on web)
> <https://github.com/user-attachments/assets/7a5bf0f1-dc37-4ef5-8ace-80299b076085>
>
> —
> Reply to this email directly, view it on GitHub
> <#184 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AK7NNIVPLRPDZWWB24MX5E325H4BRAVCNFSM6AAAAAB4TX566WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNJYGM4TMMRXGQ>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
-
Thanks! :)
this is a small problem with a async operations in Wolfram Kernel, since Anyway we will think about that. However for the animations this must be possible using raster animation (sort of a live video) frames = Table[MMAView @ Plot[Sin[y x], {y,0,10}], {x, 0.1, 1.0, 0.05}];
Module[{buffer = ImageData[frames//First, "Byte"]},
Animate[Image[buffer // Offload, "Byte"], {i, 1, Length[frames], 1},
"UpdateFunction" -> Function[i,
(* stabilize raw image size *)
buffer = ImageData[ImageCrop[frames[[i]], ImageDimensions[frames // First]], "Byte"];
False (* prevent full refresh *)
]
]
] |
Beta Was this translation helpful? Give feedback.
-
We should make somewhat like |
Beta Was this translation helpful? Give feedback.
-
With a bit of a polishing it can become quite useful proof of concept With[{function = Plot[Sin[#1 x], {x,0,10}]&},
With[{firstImage = MMAView[function[1]]},
With[{dims = ImageDimensions[firstImage]},
Module[{buffer = ImageData[firstImage, "Byte"]},
{
EventHandler[InputRange[0, 2, 0.1, "Label"->"w"], Function[w,
Then[ParallelSubmitFunctionAsync[Function[{args, cbk},
cbk @ ImageData[ImageCrop[Rasterize[function @ w], dims], "Byte"]
], {all}], Function[imgData,
buffer = imgData;
]];
]],
Image[buffer // Offload, "Byte"]
} // Column
]
]
]
] challenge.mov |
Beta Was this translation helpful? Give feedback.
-
Nice! It works exactly like how I would have wanted it to be! The next
frontier - 3D plots? Is that even possible? Like viewing it from different
angles with mouse movement?
gani -
…On Wed, May 7, 2025 at 12:54 PM Kirill Vasin ***@***.***> wrote:
*JerryI* left a comment (WLJSTeam/wolfram-js-frontend#184)
<#184 (comment)>
With a bit of a polishing it can become quite useful
*proof of concept*
With[{function = Plot[Sin[#1 x], {x,0,10}]&},
With[{firstImage = MMAView[function[1]]},
With[{dims = ImageDimensions[firstImage]},
Module[{buffer = ImageData[firstImage, "Byte"]},
{
EventHandler[InputRange[0, 2, 0.1, "Label"->"w"], Function[w,
Then[ParallelSubmitFunctionAsync[Function[{args, cbk},
cbk @ ImageData[ImageCrop[Rasterize[function @ w], dims], "Byte"]
], {all}], Function[imgData,
buffer = imgData;
]];
]],
Image[buffer // Offload, "Byte"]
} // Column
]
]
]
]
https://github.com/user-attachments/assets/9c594c7d-052e-427a-aa10-8d66220e0ca2
—
Reply to this email directly, view it on GitHub
<#184 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK7NNIQGOY7NRYS3Q3O47AL25JQHLAVCNFSM6AAAAAB4TX566WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNRQGA3DINJYGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Yep. One can overlay it with Graphics, then it is possible to attach event listeners to the mouse position and clicks. The rest is the same as for the previous example I gave. I will try it tomorrow |
Beta Was this translation helpful? Give feedback.
-
Looks ugly, but as proof of concept it works ;) MMAPlot-ezgif.com-gif-maker.mp4getAngles[angles_] := 3.0{Cos[-angles[[1]]]Sin[angles[[2]]], Sin[-angles[[1]]]Sin[angles[[2]]], Cos[angles[[2]]]}
With[{function = Function[{w, vec},
Plot3D[Sin[w x] Cos[(2 - w) y], {x,0,10}, {y,0,10}, ViewPoint->vec]
]},
With[{firstImage = MMAView[function[1, getAngles[{-Pi/4, Pi/3}]]]},
With[{dims = ImageDimensions[firstImage]},
Module[{
buffer = ImageData[firstImage, "Byte"],
target = {0,0}, start = {0,0}, moving = False,
framesSkip = 0, args = {1.0, getAngles[{-Pi/4, Pi/3}]}//N, recalc,
angles = {-Pi/4, Pi/3}
},
recalc := With[{},
Then[ParallelSubmitFunctionAsync[Function[{arguments, cbk},
cbk @ ImageData[ImageCrop[Rasterize[function @@ arguments], dims, Padding->White], "Byte"]
], args], Function[imgData,
buffer = imgData;
]];
];
{
EventHandler[InputRange[0, 2, 0.1, "Label"->"w"], Function[w,
args[[1]] = w;
recalc;
]],
EventHandler[Graphics[{
Inset[Image[buffer // Offload, "Byte"], {0,0}]
},
ImageSizeRaw -> ImageDimensions[firstImage],
PlotRange->{{-1,1}, {-1,1}},
"Controls"->False
], {
"mousemove" -> Function[xy,
target = xy; framesSkip++;
If[Mod[framesSkip, 3] == 0 && moving,
With[{dir = (target - start)/5.0},
angles += dir;
args[[2]] = getAngles[angles];
];
recalc;
]
],
"mousedown" -> Function[xy, start = xy; moving = True],
"mouseup" -> Function[xy, moving = False]
}]
} // Column
]
]
]
] |
Beta Was this translation helpful? Give feedback.
-
Added in a new release |
Beta Was this translation helpful? Give feedback.
-
Very nice! Keep up the great work!
gani -
…On Sat, May 10, 2025 at 11:20 AM Kirill Vasin ***@***.***> wrote:
Added in a new release
https://wljs.io/frontend/Reference/GUI/MMAView
—
Reply to this email directly, view it on GitHub
<#389 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK7NNIVNORTBFBPVNDNNOIL25Y7NTAVCNFSM6AAAAAB4XQYWUGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJQGEZTIMY>
.
You are receiving this because you authored the thread.Message ID:
<WLJSTeam/wolfram-js-frontend/repo-discussions/389/comments/13101343@
github.com>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions