[Gambas-user] Using gb.Cairo

Tobias Boege tobs at taboege.de
Mon May 17 21:33:35 CEST 2021


On Mon, 17 May 2021, John Dovey wrote:
> Hi,
> I am quite keen to use the Cairo component. I am having no luck though even
> starting.
> 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.
> 

A PictureBox is a control which displays a Picture. You cannot draw on
a PictureBox directly. You have to draw with Cairo on a Picture object
and then display the result in a PictureBox (actually, you draw on an
Image object, which is slightly different from a Picture). Alternatively,
you can draw on a DrawingArea, but not with the Cairo component, only
with the (GUI toolkit-specific) Paint class whose interface is very
similar to Cairo...

If that was too confusing, don't worry. I have also attached a project
which implements most(!) of your C code in Gambas. I think once you have
figured out how to start drawing, the translation is straightforward.

The only thing I could not copy is the cairo_pattern_set_extend()
setting, so the result looks different (the gradient is not repeating).
There is only one mention of this function in the gb.cairo source code
and that is limited to Cairo.ImagePattern(). Apparently you cannot
apply an Extend to a LinearGradient currently.

This is probably an oversight and you should file a feature request
at http://gambaswiki.org/bugtracker

Best,
Tobias

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-0.0.1.tar.gz
Type: application/gzip
Size: 11844 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210517/162ec200/attachment-0001.gz>


More information about the User mailing list