Re: NSBezierPath containsPoint question
Re: NSBezierPath containsPoint question
- Subject: Re: NSBezierPath containsPoint question
- From: Tom Bernard <email@hidden>
- Date: Wed, 28 Apr 2004 03:18:01 -0600
Fascinating...
I recently needed to find the point where a line intersected the arc of a
circle. The following worked for me:
gameFlagArcPath = [[NSBezierPath bezierPath] retain];
[gameFlagArcPath
appendBezierPathWithArcWithCenter:gameFlagPivotPoint radius:gameFlagWidth
startAngle:-92.0 endAngle:2.0];
t = minuteHandLength - 1.25 * gameFlagWidth;
contactPoint = NSMakePoint( -t * sin(minuteHandRotation), t *
cos(minuteHandRotation) );
while (![gameFlagArcPath containsPoint:contactPoint])
{
t += 0.1;
contactPoint = NSMakePoint( -t * sin(minuteHandRotation), t
* cos(minuteHandRotation) );
}
I am "walking" the line and testing whether my current point on the line is
contained in the path.
If you define an arc with a long enough radius, the arc becomes a flat line.
Tom Bernard
email@hidden
on 4/26/04 11:00 PM,
>
From: Dominic Edward Feira <email@hidden>
>
Subject: NSBezierPath containsPoint question
>
To: email@hidden
>
>
I am trying to determine wether or not I am clicking on a line...below
>
is a snippet of code. Shouldn't tempBool equal YES? ...
on 4/26/04 11:00 PM, email@hidden at
email@hidden wrote:
>
From: Allan Odgaard <email@hidden>
...
>
Date: Tue, 27 Apr 2004 06:18:44 +0200
>
To: Dominic Edward Feira <email@hidden>
>
>
On 27. Apr 2004, at 5:54, Dominic Edward Feira wrote:
>
...
>
No, it tells if the point is contained by the (closed) path formed by
>
multiple lines in the NSBezierPath.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.