Where is the graphics documentation


#1

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.


#2

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


#3

I think he’s referring to this:

http://juliagraphics.github.io/Gtk.jl/latest/manual/canvas.html

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)

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

    save(cr);
    ## 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);
    stroke(cr);

    ## mark picture with current date
    restore(cr);
    move_to(cr,0.0,12.0);
    set_source_rgb(cr, 0,0,0);
    show_text(cr,Libc.strftime(time()));
end
show(c)

#4

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


#5

Thanks I’ll go through that Cairo documentation