JuliaGraphics / Luxor.jl

Simple drawings using vector graphics; Cairo "for tourists!"

Home Page:http://juliagraphics.github.io/Luxor.jl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[VSCode, notebooks] `preview()` doesn't work when drawing in loop

kilacoda opened this issue · comments

Hi,

When I try to preview an individual SVG image in a Jupyter notebook in VSCode, it shows the preview as expected:

image

However, if I try to run a loop generating multiple SVGs (I want to save them for reference later) I don't get any such preview. I'd expect at least the last generated preview to display, but that doesn't happen.
Example:
image

Is this expected behavior? If not, is there any workaround I can use at the moment to display the previews using Luxor?

Hi! I think for loops in Julia don't return values. Also, you can't use preview in @svg because the macro already does it.

Perhaps:

for i in 1:4
    d = @svg begin
        circle(O, 100i, :fill)
    end 600 600 "/tmp/luxor-$(i)"
    sleep(0.1)
    display(d)
end

works. On Atom (I'm still using Atom) it displays each of four drawings consecutively. Without the sleep it happens too quickly... ;)

Yep, that works on VSCode as well, and is exactly what I require! Thanks for the quick response!