gnustep-dev
[Top][All Lists]
Advanced

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

Re: NSBezierPath -containsPoint: (Was: [Gnustep-cvs] gnustep/core/gui Ch


From: Alexander Malmberg
Subject: Re: NSBezierPath -containsPoint: (Was: [Gnustep-cvs] gnustep/core/gui ChangeLog Headers/AppKit/NSBez...)
Date: Wed, 12 Jan 2005 16:46:03 +0100
User-agent: Mozilla Thunderbird 0.9 (X11/20041124)

Fred Kiefer wrote:
[snip]
I really like your new implemetnation of the containsPoint: method and it passes all teh tests I did write when implementing the last one.

Thanks, that's nice to know. :) I have a bunch of automated tests as well (in the "new" test suite; hopefully, there'll be time to work on that soon).

There is just the problem that Banlu thinks that we have implemented the wrong behaviour here. What your code does is a better implementation of the old code, that is, find if the bezier path includes the point in some geometrical sense. What Banlu implemented in his Cairo backend and what he claims to be the actual behaviour for this method, is a Postscript like hit detection:

Postscript has both kinds of inside-ness tests: "instroke" for stroking and "infill" and "ineofill" for filling.

> Will this bezier path with its given line
width, cap style and so on, touch the point, that is would it colour the point when drawing? I am not sure if his interpretation is correct and if so, if this would mean stroke mode or fill mode. The later should be more or less what you have implemented (ignoring the draw attributes).

I was completely convinced that the docs were clear about this, but when I double-check now, I find that this method is either missing or the documentation is too incomplete to tell what it does.

Fortunately, as Banlu confirmed, this is the right behavior. google also agrees (see e.g. http://www.cocoadev.com/index.pl?HitDetection).

I guess an 'instroke' equivalent method would be nice, but doing that right is significantly more complicated. (Note that the 'instroke' implementation in the link above doesn't handle line caps or joins at all, and the curve handling is wrong (you don't want the closest (euclidean distance) point on the curve, you want the point on the curve with the least distance along the curve's normal at that point).)

OTOH, the root solving approach is neat, and the proper problem also reduces to a fifth degree polynomial... Maybe some day when I'm bored. ;)

[snip]
PS: Should the method windingCountAtPoint: be public and if so, shouldn't we mark it as GNUstep extension?

It's intended to be public, and it should be marked as an extension, which I've done now. Thanks for reminding me. :)

- Alexander Malmberg




reply via email to

[Prev in Thread] Current Thread [Next in Thread]