Circular "Selection" with Gdk::Pixbuf or similar

Hi there,

first a short explanation. I plan to use an image that shows a simple
map, i.e. a google map, or a map from a dungeon or similar. The virtual
hero group (the players) can only see a limited area, either because the
map is so large, or because it is dark inside a cave etc…

For this to simulate, I would like to select a small circle of the map.
Upon keyevents (this part is easy) the circle moves.
So far so good, but I was looking at
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gdk%3A%3APixbuf

I am not entirely sure, is there a way to select circular areas?
copy_area for example speaks only about "Copies a rectangular area from
source pixbuf(self) to dest_pixbuf. " but I would need a circular area.

If anyone has an idea , I would be glad to hear about it!

Hi,

Am Sonntag, den 03.02.2008, 14:00 +0100 schrieb Marc H.:

I am not entirely sure, is there a way to select circular areas?
copy_area for example speaks only about "Copies a rectangular area from
source pixbuf(self) to dest_pixbuf. " but I would need a circular area.

no, Gdk::Pixbuf has nothing like this. A way to go is to use
Gdk::Drawable. There you can copy a rectangulare area into a drawable,
and render this under the use of a clipmask of an Gdk::GC onto an other
drawable. The clipmask you can easily be create with
Gdk::Drawable.draw_arc. This is a quite easy and very fast way, but has
no alpha blending for the edges of the cliping area.

An other way is to use ruby cairo. Here
http://cairographics.org/samples/clip_image/ you will find exactly what
you want.

Cheers, detlef

An other way is to use ruby cairo. Here
http://cairographics.org/samples/clip_image/ you will find exactly what
you want.

Thanks, I think I will use ruby cairo.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs