[Gambas-user] Using gb.Cairo
tobs at taboege.de
Mon May 17 21:33:35 CEST 2021
On Mon, 17 May 2021, John Dovey wrote:
> 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.
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
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 11844 bytes
Desc: not available
More information about the User