Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luxor, Cairo, and Turtle graphics #2

Open
chrisvwx opened this issue Aug 20, 2019 · 5 comments
Open

Luxor, Cairo, and Turtle graphics #2

chrisvwx opened this issue Aug 20, 2019 · 5 comments

Comments

@chrisvwx
Copy link
Member

Chapter 4 and other chapters use turtle graphics via the Luxor package which wraps Cairo. Apparently Cairo.jl is not building right now.

I wish there were a 100% Julia graphics package that we could use for the Turtle business.

@BenLauwens
Copy link
Contributor

Hi Christian

I had the same problem that Cairo.jl was not building.
So I implemented a small native svg backend.
The basic turtle graphics primitives are also available. Output is visible in Atom and Vscode (plotplane) and Jupyter.

using NativeSVG
t = Turtle()
forward(t, -200)
penup(t)
turn(t, -90)
forward(t, 200)
turn(t, 90)
pendown(t)
for c in (:black, :red, :orange, :yellow, :green, :blue, :indigo, :violet)
    pencolor(t, c)
    forward(t, 100)
    turn(t, 45)
end
Drawing(t)

Can you look at it and give me some feedback? I really like to replace the Luxor dependency with something else;)

Kind regards

Ben

@chrisvwx
Copy link
Member Author

Hey Ben,

It looks good! It looks like a small, clean package. I tried it out in Jupyter, and it works very well there. I tried a few of the examples form Chapter 4, and they all seem to work well.

I looked around a bit to understand what would need to happen to display an SVG from the REPL. I guess one option is to to display the svg in a web browser window; is this the approach you're thinking of?

Chris

@BenLauwens
Copy link
Contributor

Hi Christian

Checkout NativeSVG. It should work now also from a REPL (to a web browser window).
Kind regards

Ben

@chrisvwx
Copy link
Member Author

Wonderful! The example works well from the REPL; that's quick work on your part.

I have wondered if an introduction to a more typical plotting package would be more useful than turtle graphics. It seems the turtle graphics is targeting children; I wonder at what age or in what situations an introduction to something like Plots.jl would be as enjoyable. I don't have plans to change this in PiensaEnJulia; even so, I'm interested to learn if you have comments on this topic.

@chrisvwx
Copy link
Member Author

chrisvwx commented Sep 6, 2019

I was able to use this PR on Cairo.jl to get ThinkJulia.jl working. I was able to run the code in Chapter four of ThinkJulia.

Ben, do you plan to modify the book to use NativeSVG? If so, do you know when?

pambus added a commit that referenced this issue Aug 6, 2020
Actualización 5 de Agosto 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants