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! 