[Kde-graphics-devel] Re: [cairo] Qt example in cairo-demo

Zack Rusin zack at kde.org
Thu Jan 27 02:18:29 CET 2005


On Wednesday 26 January 2005 18:43, Richard Moore wrote:
> On Wed, 26 Jan 2005 11:17:09 -0500, Zack Rusin <zack at kde.org> wrote:
> > 2) Because of 1 that means that we'd be looking into just creating
> > a class that abstracts Cairo calls. But the question is: is it
> > really easier to do:
> > QCairoPainter painter(cairo);
> > painter.moveto(20,0);
> > painter.relLineTo(40, 40);
> > painter.relLineTo(-40,0);
> > painter.closePath();
> > rather than
> > cairo_move_to( cr, 20, 0 );
> > cairo_rel_line_to( cr, 40,  40 );
> > cairo_rel_line_to( cr, -40, 0 );
> > cairo_close_path( cr );
>
> One big difference is that with the first example I can switch
> back-ends with a single line of code. This is a big deal when you try
> to do something you hadn't thought of when you wrote the code. The
> first example is also easier to read if you're used to working with
> Qt style APIs as you don't need to 'change gear'.

The first one actually isn't true. You really wouldn't be able to change 
the backend. With my initial proposition you'd be able to do that 
(implementing the qpaintengine). With this you couldn't because 
QCairoPainter would be a thin wrapper around Cairo functions. 
lineTo, moveTo methods don't exist in QPainter. They are part of 
QPainterPath though. 
The second also depends on your point of view, because this strategy 
would mean introducing a parallel painter with methods not present in 
the normal QPainter and encompassing most of what QPainterPath does. 

Zack

-- 
I considered atheism but there weren't enough holidays.


More information about the Kde-graphics-devel mailing list