Re: [guppi-list] point() method of GnomeCanvasArc



> OK, this is currently just a cut-and-paste of GnomeCanvasEllipse's point
> method. The required modification is to check not only whether the point
> is in the ellipse, but also whether it's in the arc of the ellipse we're
> displaying. The return value is the distance from the x, y coordinates to
> the arc.

It seems that it already does?  What is the problem exactly?  Is there a bug,
or is it because the calculations does not match with the rendering of an
ellipse on the screen?

One thing that you could try, is to add "GNOME_CANVAS_EPSILON" to this test:

Instead of
--
        /* If the scaled distance is greater than 1, then we are outside. 
         */
        if (scaled_dist > 1.0)
                return (center_dist / scaled_dist) * (scaled_dist - 1.0);
--

use

--
        /* If the scaled distance is greater than 1, then we are outside. 
         */
        if (scaled_dist > 1.0 + GNOME_CANVAS_EPSILON)
                return (center_dist / scaled_dist) * (scaled_dist - 1.0);
--

and seem it that helps.  In theory, the 1.0 test should be correct, assuming
that we have infinite precision, and there are no bugs in the code, but in
reality, I think life might be different.

As I see it, the approach in the routine is not guaranteed to match a
pixel-rendering of an ellipsis, and so it might fail in a few extreme pixels at
the border, but in real life, that should not be a problem.

Of course, I don't know what the use is.  If you really require pixel exact
results, I think you have to render the ellipsis, and then check the image in
order to be 100% sure, because the ellipsis drawing might be flawed!

Greets,

Asger



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]