[cairo] Re: cairo_get_current_point bug ?

Mike Emmel mike.emmel at gmail.com
Thu Sep 28 20:46:42 PDT 2006


On 9/28/06, Carl Worth <cworth at cworth.org> wrote:
> On Thu, 28 Sep 2006 13:48:17 -0700, Bill Spitzak wrote:
> > I think "the last location of the current point" and "0,0 when a new
> > cairo_t is created" is pretty well defined and would work for this.
>
> I think that that would be really hard to document. But worse, I think
> it doesn't work.
>
> >                                                                     This
> > would also mean that all the code could just track the current point in
> > device space and most of the if statements you have left to check if
> > there is a current point could be removed.
>
> Let's look at what happens with a current point that is locked into a
> device-space origin of (0,0) when the context is created.
>
> First, let's assume we create a path with a relative path-construction
> operation as the first operation, (since these are the only operations
> that care about the current point). That is, our path creation might
> consists of simply:
>
>         cairo_rel_line_to (cr, 5, 5);
>
> Which, given an identity CTM, we all agree should result in a path
> consisting of MOVE_TO (0, 0) and LINE_TO (5, 5), right?
>
> Now, let's suppose that that path creation exists inside an
> application function and that the calling function wants to transform
> it, (with a simple translation, for example). That is, the final path
> creation will look like:
>
>         cairo_translate (cr, x, y);
>         cairo_rel_line_to (cr, 5, 5);
>
> With your device-space current point you end up with a path of MOVE_TO
> (0, 0) and LINE_TO (x+5, y+5), right? That's nothing like a translated
> version of the path.
>
> However, my rule of making cairo_rel_line_to have an implicit move_to
> (cr, 0, 0) when there's no current point means that the resulting path
> is a translated version of the original, (MOVE_TO (x, y) and LINE_TO
> (x+5, y+5)).
>
> Am I missing anything?
>

I think your right thats the problem with just putting a move_to(0,0)
in by default it does not give correct results.

You actually wan't to only do it implicitly if the first operation
is a relative op as your saying.
And of course if the user does not like the default the simply need to
do a get_current_point once it has a return value and handle the case
of a empty path in some other manner.


> -Carl
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
>
>
>


More information about the cairo mailing list