Ruby Forum Ruby-Gnome 2 > Zooming a DrawingArea

Posted by Lucas L. (genericguy)
on 18.06.2008 10:04
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!
Posted by Lucas L. (genericguy)
on 19.06.2008 14:38
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.