Display animation created with Luxor in jupyter notebook

Can I display an animation created with Luxor in a jupyter notebook?

For example if I put something like the example code for animation

using Colors, Luxor
demo = Movie(400, 400, "test")

function backdrop(scene, framenumber)

function frame(scene, framenumber)
    sethue(Colors.HSV(framenumber, 1, 1))
    eased_n = scene.easingfunction(framenumber, 0, 1, scene.framerange.stop)
    circle(polar(100, -π/2 - (eased_n * 2π)), 80, :fill)
    text(string("frame $framenumber of $(scene.framerange.stop)"),
        Point(O.x, O.y-190),

animate(demo, [
    Scene(demo, backdrop, 0:359),
    Scene(demo, frame, 0:359,
        optarg="made with Julia")

in a cell, I would like the created animation to be displayed directly when the cell is executed (like it works for images).

As an (not really good) alternative option I also tried to display the gif in a markdown cell afterwards with

[alt text](anim.gif)

but that only shows a link with the alternate text. But at least if the link is clicked a new page opens where the animation is displayed. So the link seems to work.

1 Like

I don’t think the animate() function returns anything (apart from ‘true’ if successful), so nothing will be automatically displayed. It should be easy to include a link to a file, though. Do you need ! characters somewhere?

(I rarely use Jupyter, sorry…)

Yes, thanks! With

![alt text](anim.gif)

it directly shows the animated gif.

However, it still would be better if there was some Julia method i could call which returns something that jupyter can display as animation directly. That way I wouldn’t need two different cells which need to be in sync.

Edit: Okay, I can use

display(MIME("text/html"), """<img src="anim.gif">""")

after the call to animate to directly display the created gif. It still would be nicer if IJulia could display the animation directly but I couldn’t find out how IJulia decides how to display the return value of a cell. I tried implementing showable and display for an array of Scenes, but that doesn’t seem to be sufficient.