I was quite happy when I managed to set up the Julia kernel for Quarto documents in RStudio, following the instructions on the Quarto website, and I reproduced the Plots demo in Quarto - Using Julia
However, when I installed the Julia package Luxor, I rendered my Quarto document without any errors, but it did not produce a plot of the turtle graphics (only the value true) I was trying to reproduce from Turtle graphics · Luxor
I did modify the Julia code in their example and removed the turtle emoji and the turtle image (turtles.png). I thought that maybe the issue was related to the graphics device, but I tried using dev="CairoSVG", after installing the Cairo package. I tried several other devices but nothing seems to work. I would love to be able to render vector graphics produced by the Julia Luxor package in Quarto documents.
After installing first the Luxor and Colors Julia packages, here is an example of a Julia code chunk with a Luxor turtle graphics in a Quarto document:
using Luxor, Colors
Drawing(600, 400)
origin()
background("midnightblue")
t = Turtle()
Pencolor(t, "cyan")
Penwidth(t, 1.5)
global n = 5
for i in 1:400
Forward(t, n)
Turn(t, 89.5)
HueShift(t)
n += 0.75
end
fontsize(20)
finish()
After looking into this a bit more, it appears that the drawing function creates a file with the drawing, and the file name can be specified in the function Drawing(600, 400, :png, "test.png"), where the file name is test.png, but the drawing function also creates the png file in the memory, specified by the argument :png.
There must be a way to capture the image from memory and embed it into the Quarto document as well as the output HTML or PDF file, after rendering the Quarto document.
Also, how can I suppress the value true being returned when I render the qmd document? The chunk option results='hide' does not suppress it.
It would be great if we can use the Luxor package to create amazing Turtle Graphics for educational purpose. I wish there were a Turtle Graphics package based on ggplot2!