Where is the graphics documentation

I’ve read how to create a gtk window and draw a rectangle to it using the draw function. But I can’t find any documentation beyond that.

Please provide some details (which library you are using, etc) and preferably code.

I think he’s referring to this:


Gtk uses Cairo.jl to draw, so you can have look at the examples or Cairo’s doc.

Note that the Cairo context in the Gtk example is called ctx while it’s called cr in Cairo’s, and you have to do using Cairo. E.g.

using Gtk, Graphics, Cairo
c = @GtkCanvas()
win = GtkWindow(c, "Canvas")

@guarded draw(c) do widget

    cr = getgc(c)
    h = height(c)
    w = width(c)

    set_source_rgb(cr,0.8,0.8,0.8);    # light gray
    rectangle(cr,0.0,0.0,256.0,256.0); # background

    ## original example, following here

    move_to(cr, 50.0, 75.0);
    line_to(cr, 200.0, 75.0);

    move_to(cr, 50.0, 125.0);
    line_to(cr, 200.0, 125.0);

    move_to(cr, 50.0, 175.0);
    line_to(cr, 200.0, 175.0);

    set_line_width(cr, 30.0);
    set_line_cap(cr, Cairo.CAIRO_LINE_CAP_ROUND);

    ## mark picture with current date
    set_source_rgb(cr, 0,0,0);

Yeah that’s it. So as for the example of the rectangle function, my question is where exactly does that come from? And are there other functions in the same package? Such as drawing an array of rbg pixels onto the canvas or text or different shapes. Or drawing an image to the canvas? I read somewhere else about opening image files but I don’t recall there being anything related to drawing them to canvas. Can you access the current canvas values such as pixel values? Can you draw individual pixels ( of course you could using the rectangle function but it’s slightly convoluted for that situation.

My question is simply what tools are available beyond rectangle() and where I can read about them

1 Like

Thanks I’ll go through that Cairo documentation