Re: rotating NSBezierPath objects
Re: rotating NSBezierPath objects
- Subject: Re: rotating NSBezierPath objects
- From: Roland King <email@hidden>
- Date: Sat, 07 Jul 2012 08:51:44 +0800
On 7 Jul, 2012, at 8:10 AM, William Squires <email@hidden> wrote:
> Okay, I see in the doc set that you can perform an NSAffineTransform on an NSBezierPath, but how do I perform a rotation of the NSBezierPath about an arbitrary CGPoint and with a specified angle in radians? Is this something deep in CoreGraphics, or CoreAnimation? If not, I can do the trigonometry myself if I can get the list of points that make up the NSBezierPath, but it seems these aren't exposed, only NSBezierPathElement objects. Help!
Make one affine transform which translates the point you want to rotate around to the origin, rotates, then translates it back. Just use the NSAffineTransrorm functions to concatenate the three operations and apply it.
> Also, what is the formula for calculating the area of an arbitrary triangle defined by three non-collinear points in 2D space? (i.e. I can't assume the triangle even has a 90 degree angle in it, or any other such shortcuts…)
Google it, I just did. There's 100s of answers. Pick the one which suits you best.
> Finally, If an NSBezierPath consisting of a closed circuit of points:
>
> …
> NSBezierPath *mySquarePath = [NSBezierPath bezierPath];
>
> [mySquarePath setLineWidth:1.0];
> [mySquarePath moveToPoint:CGPointMake(0.0, 0.0)];
> [mySquarePath lineToPoint:CGPointMake(10.0, 0.0)];
> [mySquarePath lineToPoint:CGPointMake(10.0, 10.0)];
> [mySquarePath lineToPoint:CGPointMake(0.0, 10.0)];
> [mySquarePath closePath];
> …
>
> will [mySquarePath containsPoint:CGPointMake(5.0, 5.0)] return YES even before I fill or stroke the path, or do I have to fill the path first?
>
>
Yes it will return YES. Why not just write the code and confirm it for yourself.
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden