# Zooming a DrawingArea

**URL:** <https://www.ruby-forum.com/t/zooming-a-drawingarea/140758>\
**Category:** Ruby-Gnome 2\
**Created:** [June 18, 2008, 10:04am UTC](https://www.ruby-forum.com/t/zooming-a-drawingarea/140758 "2008-06-18T10:04:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![genericguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@genericguy](https://www.ruby-forum.com/u/genericguy)\
**Post date:** [June 18, 2008, 10:04am UTC](https://www.ruby-forum.com/t/zooming-a-drawingarea/140758/1 "2008-06-18T10:04:04Z")

</div>

Hi,  
I’m writing a raster drawing application that uses a DrawingArea and  
Cairo (for lack of easy to use raster drawing libraries for ruby).

Is there any way to zoom the DrawingArea? I tried a size request, but  
that just extends it past the cairo context.

Also, it’s important that it is a raster zoom, not a vector zoom (a  
pixel is 4 times bigger than normal if 4 times zoom).

If there is no easy way to do this, tips on how to implement it myself  
would be great.

Thanks!

---

<div class="post-metadata">

**Author:** ![genericguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@genericguy](https://www.ruby-forum.com/u/genericguy)\
**Post date:** [June 19, 2008, 2:38pm UTC](https://www.ruby-forum.com/t/zooming-a-drawingarea/140758/2 "2008-06-19T14:38:34Z")

</div>

The best way to do this so far is this:

> c = drawingarea.window.create\_cairo\_context  
> c.antialias = Cairo::ANTIALIAS\_NONE  
> c.scale(@zoom, @zoom)  
> drawingarea.set\_size\_request(@width\*@zoom, @height\*@zoom)  
> c.set\_source(@canvas, 0, 0)  
> c.paint

It makes the pixels kinda round when you zoom in really far, though.
