# Circular "Selection" with Gdk::Pixbuf or similar

**URL:** <https://www.ruby-forum.com/t/circular-selection-with-gdk-pixbuf-or-similar/127967>\
**Category:** Ruby-Gnome 2\
**Created:** [February 3, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/circular-selection-with-gdk-pixbuf-or-similar/127967 "2008-02-03T14:00:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 3, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/circular-selection-with-gdk-pixbuf-or-similar/127967/1 "2008-02-03T14:00:38Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 3, 2008, 2:53pm UTC](https://www.ruby-forum.com/t/circular-selection-with-gdk-pixbuf-or-similar/127967/2 "2008-02-03T14:53:04Z")

</div>

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/](http://cairographics.org/samples/clip_image/) you will find exactly what  
you want.

Cheers, detlef

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 4, 2008, 3:06pm UTC](https://www.ruby-forum.com/t/circular-selection-with-gdk-pixbuf-or-similar/127967/3 "2008-02-04T15:06:55Z")

</div>

> An other way is to use ruby cairo. Here  
> [http://cairographics.org/samples/clip\_image/](http://cairographics.org/samples/clip_image/) you will find exactly what  
> you want.

Thanks, I think I will use ruby cairo.
