How to display on screen using Cairo.jl?

I want to show the graph on the screen (maybe a window)

I wonder which surface function I should choose and how to fill the arguments,since there’s an error every time I try.

I hope there’s an example :grinning:

1 Like

nobody?
I’m going to ask it in the repo.

Hi! Perhaps you could tell us a bit more about what you’re trying to do, and what you’ve done so far.

Most people make figures and graphs using Plots.jl/Makie.jl/Lightgraphs.jl, so it’s not that common (although perfectly possible) to want to do the extra work in Cairo.jl.

well, I want to draw sets of points (from images and maybe do operations before showing),but using GLFW is too complicated

Probably start with Makie.jl - you can see some of the possibilities on this amazing page: https://lazarusa.github.io/BeautifulMakie/

but I don’t want x,y-axis

You can almost certainly choose to not show them. I haven’t read the documentation, but you probably will! :joy:

1 Like

But I need a lightweight one, Makie is designed to plot,so it contains too much things I don’t need, making it slow to load.

I read the docs and haven’t seen an option on axises.

OK, so Gtk.jl may be the best way to draw graphics into a window.

3 Likes

For other searching how to do that in Makie,
hidespines! and hidedecorations! are described here.

2 Likes

but there’s still a rectangle

but there’s still a rectangle

Not here (CairoMakie v0.6.2),


Generated in a Pluto.jl notebook with two cells:

using CairoMakie

let
	fig = Figure(backgroundcolor=RGBf0(0.95, 0.95, 0.95), resolution=(800, 200))
	ax = Axis(fig[1, 1])
	xs = [0.0, 1.0]
	ys = [0.0, 1.0]
	ar = lines!(ax, xs, ys)
	hidespines!(ax)
	hidedecorations!(ax)
	fig
end

In Makie, you can also generate a raw Scene and just use that as a canvas, no Axis needed. But axes are still nice for auto-scaling to your data if you don’t want to draw in pixel coordinates.

s = Scene(camera = campixel!, show_axis = false)
lines!(s, ...

s

How about Luxor?

using Luxor
width = height = 100
Drawing(width, height)
background("white")
sethue("black")
circle(Point(width/2, height/2), 10, :fill)
finish()
preview()

but

Luxor is designed primarily for drawing static pictures.

that’s not what I want

Check out the animate function and the @play macro. I’ve been playing around with both recently and enjoying them a lot. I agree static is boring!

1 Like

So what if (similar) I’m making a 2D game?
After all,I’m going to use GtkReactive

Note that:

new projects are encouraged to consider GtkObservables instead.

2 Likes