pycairo

How can I "best fit" an arbitrary cairo (pycairo) path?

It seems like given the information in stroke_extents() and the translate(x, y) and scale(x, y) functions, I should be able to take any arbitrary cairo (I'm using pycairo) path and "best fit" it. In other words, center it and expand it to fill the available space. Before drawing the path, I have scaled the canvas such that the origin is...

Rare PyCairo antialias getting directly the surface data

After create a Pycairo context and surface (ImageSurface) I get a diferent export results if I get directly from surface buffer surface.get_data() or from PNG export method surface.write_to_png() The context antialias flag is obviously the same and, yes, the get_data method result has antialiasing, but with much poorer quality. Wh...

How to keep text inside a circle using Cairo?

I a drawing a graph using Cairo (pycairo specifically) and I need to know how can I draw text inside a circle without overlapping it, by keeping it inside the bounds of the circle. I have this simple code snippet that draws a letter "a" inside the circle: ''' Created on May 8, 2010 @author: mrios ''' import cairo, math WIDTH, HEIGHT =...

Using Pycairo to generate images dynamically and serve in Django

I want to generate a dynamically created png image with Pycairo and serve it usign Django. I read this: http://stackoverflow.com/questions/1074200/serve-a-dynamically-generated-image-with-django. Is there a way to transport data from Pycairo surface directly into HTTP response? I'm doing this for now: data = surface.to_rgba() im = Imag...

Cairo context and persistence?

Hi, I am just getting started using pycairo, and I ran into the following interesting error. The program I write creates a simple gtk window, draws a rectangle on it, and then has a callback to draw a random line on any kind of keyboard input. However, it seems that with each keyboard input, I have to create a new context, or I get an er...