[Gambas-user] Using gb.Cairo

John Dovey dovey.john at gmail.com
Mon May 17 20:47:51 CEST 2021

I am quite keen to use the Cairo component. I am having no luck though even
The docs tell me that
"Before starting drawing anything, you must call the Begin
<http://gambaswiki.org/wiki/comp/gb.cairo/cairo/begin> method by passing it
the Image <http://gambaswiki.org/wiki/comp/gb.image.effect/image> where you
want to draw."

I figured the simplest way to do this would be to create a Picturebox on a
form, and pass that to Cairo.Begin. That didn't work.
A hint on how to do this would help tremendously.

In fact, if someone could convert this into the Gambas equivalent, it would
give a great start to what I want to do initially:

-- Code --

static void do_drawing(cairo_t *cr, GtkWidget *widget)
  cairo_pattern_t *pat;

  cairo_set_source_rgb(cr, 0.2, 0.2, 0.2);

  gint h = 90;

  cairo_select_font_face(cr, "Serif", CAIRO_FONT_SLANT_ITALIC,
  cairo_set_font_size(cr, h);

  pat = cairo_pattern_create_linear(0, 15, 0, h*0.8);
  cairo_pattern_set_extend(pat, CAIRO_EXTEND_REPEAT);
  cairo_pattern_add_color_stop_rgb(pat, 0.0, 1, 0.6, 0);
  cairo_pattern_add_color_stop_rgb(pat, 0.5, 1, 0.3, 0);

  cairo_move_to(cr, 15, 80);
  cairo_text_path(cr, "ZetCode");
  cairo_set_source(cr, pat);

-- End Code --
It comes from https://zetcode.com/gfx/cairo/cairotext/

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210517/e9b9c280/attachment.htm>

More information about the User mailing list