Forum: Ruby-Gnome 2 issue with Cairo mask function in a Gtk Window

59504b1b262cc1637b52b1c147112b62?d=identicon&s=25 67Daidalos .. (67daidalos_)
on 2013-10-12 13:50
Attachment: essai.rb (2 KB)
Hi !
I'm trying to do smth a little tricky that is explain only in one
tutorial I found on the net (and it's a C tuto) It's to use a pixbuf, or
eventually a png file as a mask. All seems to work well, except the last
line.

If I use
mask = Cairo::ImageSurface.from_png("my image_filepath.png")
cr.mask_surface(mask, x, y).
The interpreter said there is no mask_surface method for Cairo::Context
object.

If I use
mask = Cairo::ImageSurface.from_png("my image_filepath.png")
cr.mask(mask)
It says that mask is not a Cairo pattern. And it's the same when I tried
all I could have imagined to set the mask from a pixbuf.

So has anyone an idea of how I can solve this problem ?
I attach my code to the message if it could be of any help.
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2013-10-13 07:18
(Received via mailing list)
Hi,

In <22ee7f35031cf7ea70470e6548ce347e@ruby-forum.com>
  "[ruby-gnome2-devel-en] issue with Cairo mask function in a Gtk
Window" on Sat, 12 Oct 2013 13:50:48 +0200,
  "67Daidalos .." <ruby-forum-incoming@andreas-s.net> wrote:

> If I use
> mask = Cairo::ImageSurface.from_png("my image_filepath.png")
> cr.mask_surface(mask, x, y).
> The interpreter said there is no mask_surface method for Cairo::Context
> object.

Try:

  cr.mask(mask, x, y)

Cairo::Context#mask accepts both pattern and surface.


Thanks,
--
kou
59504b1b262cc1637b52b1c147112b62?d=identicon&s=25 67Daidalos .. (67daidalos_)
on 2013-10-13 07:51
Kouhei Sutou wrote in post #1124423:

> Try:
>
>   cr.mask(mask, x, y)
>
> Cairo::Context#mask accepts both pattern and surface.
>
>
> Thanks,
> --
> kou

Thank you ! It works great !
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.