Ruby Forum Ruby-Gnome 2 > Drawing with a Cairo context outside an expose signal

Posted by Lucas L. (genericguy)
on 16.06.2008 10:38
Hi,
I'm trying to allow a user to draw to a DrawingArea with Cairo.
The only problem is that I cannot figure out how to draw without using
create_cairo_context in the expose event.
I realize that I need to draw then if I want anything to be displayed,
but I'd like to be able to draw to a 'buffer' in other parts of the
script and then draw the buffer in the expose event.

There are two ways that I can think of doing this.
The first would be to create my own Cairo::Context. Since I don't know
how create_cairo_context links a context to the DrawingArea, is stuck
for that.
The other way would be to draw to a surface and call
context.set_source_surface. For some reason, though, this function
doesn't seem to be present in the ruby binding.

Thanks!
Posted by Kouhei Sutou (Guest)
on 16.06.2008 13:44
(Received via mailing list)
Hi,

In <0d64d569ae573254ef124c22a69de782@ruby-forum.com>
  "[ruby-gnome2-devel-en] Drawing with a Cairo context outside an expose 
signal" on Mon, 16 Jun 2008 10:38:24 +0200,
  "Lucas L." <ruby-forum-incoming@andreas-s.net> wrote:

> The other way would be to draw to a surface and call
> context.set_source_surface. For some reason, though, this function
> doesn't seem to be present in the ruby binding.

Use Cairo::Context#set_source. It's general method. It
accepts (r, g, b), (r, g, b, a), ([r, g, b]), ([r, g, b,
a]), (pattern) or (surface, x, y).


Thanks,
--
kou
Posted by Lucas L. (genericguy)
on 16.06.2008 14:17
Ah, I was searching the docs for surface_source.
rcairo really needs English documentation.

Thanks!

Kouhei Sutou wrote:
> Hi,
> 
> In <0d64d569ae573254ef124c22a69de782@ruby-forum.com>
>   "[ruby-gnome2-devel-en] Drawing with a Cairo context outside an expose 
> signal" on Mon, 16 Jun 2008 10:38:24 +0200,
>   "Lucas L." <ruby-forum-incoming@andreas-s.net> wrote:
> 
>> The other way would be to draw to a surface and call
>> context.set_source_surface. For some reason, though, this function
>> doesn't seem to be present in the ruby binding.
> 
> Use Cairo::Context#set_source. It's general method. It
> accepts (r, g, b), (r, g, b, a), ([r, g, b]), ([r, g, b,
> a]), (pattern) or (surface, x, y).
> 
> 
> Thanks,
> --
> kou
Posted by Kouhei Sutou (Guest)
on 16.06.2008 14:22
(Received via mailing list)
Hi,

In <adfb56f494f5718141ddb92a7a267638@ruby-forum.com>
  "Re: [ruby-gnome2-devel-en] Drawing with a Cairo context outside an 
expose signal" on Mon, 16 Jun 2008 14:17:43 +0200,
  "Lucas L." <ruby-forum-incoming@andreas-s.net> wrote:

> Ah, I was searching the docs for surface_source.
> rcairo really needs English documentation.

I need your help.


Thanks,
--
kou
Posted by Lucas L. (genericguy)
on 16.06.2008 14:30
Kouhei Sutou wrote:
> Hi,
> 
> In <adfb56f494f5718141ddb92a7a267638@ruby-forum.com>
>   "Re: [ruby-gnome2-devel-en] Drawing with a Cairo context outside an 
> expose signal" on Mon, 16 Jun 2008 14:17:43 +0200,
>   "Lucas L." <ruby-forum-incoming@andreas-s.net> wrote:
> 
>> Ah, I was searching the docs for surface_source.
>> rcairo really needs English documentation.
> 
> I need your help.
> 
> 
> Thanks,
> --
> kou

Is there a wiki or something? I'd gladly help.
Right now I just try to make sense of Google's translation of the 
Japanese docs:D
Posted by Kouhei Sutou (Guest)
on 16.06.2008 14:38
(Received via mailing list)
Hi,

In <89d1654261118c2e0f1adff8c5e4a698@ruby-forum.com>
  "Re: [ruby-gnome2-devel-en] Drawing with a Cairo context outside an 
expose signal" on Mon, 16 Jun 2008 14:30:16 +0200,
  "Lucas L." <ruby-forum-incoming@andreas-s.net> wrote:

> >> Ah, I was searching the docs for surface_source.
> >> rcairo really needs English documentation.
> > 
> > I need your help.
> 
> Is there a wiki or something? I'd gladly help.

Thanks!
There is a Subversion repository:
  https://www.cozmixng.org/repos/rcairo-doc/

Could you mail your prefer account name and salted password
(you may use htpasswd) to me?

> Right now I just try to make sense of Google's translation of the 
> Japanese docs:D

The Japanese documentations are based on cairo's documents:
  http://www.cairographics.org/manual/

Most of them will help you.


Thanks,
--
kou