//
//  TN+NSBezierPath.m
//  GraphicsUtilities
//
//  Created by Tommy Nordgren (tommy.nordgren@comhem.se  http://www.tommynordgren.com) on 2008-11-09.
//  Copyright 2008 Tommy Nordgren. All rights reserved.
//

#import "TN+NSBezierPath.h"
#import "TN+NSAffineTransform.h"

@implementation NSBezierPath (TNGraphics)

+(NSBezierPath *) bezierPathWithOvalInRectOfWidth:(CGFloat) w height:(CGFloat) h centeredAt:(NSPoint) p rotatedByDegrees:(CGFloat) d
{
	NSBezierPath * result = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(p.x - w/2, p.y - h/2,w,h)];
	[result transformUsingAffineTransform:[NSAffineTransform transformRotatedAroundPoint:p degrees:d]];
	return result;
}

+(NSBezierPath *) bezierPathWithOvalInRectOfWidth:(CGFloat) w height:(CGFloat) h centeredAt:(NSPoint) p rotatedByRadians:(CGFloat) r
{	
	NSBezierPath * result = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(p.x - w/2, p.y - h/2,w,h)];
	[result transformUsingAffineTransform:[NSAffineTransform transformRotatedAroundPoint:p radians:r]];
	return result;
}

+(NSBezierPath *) bezierPathWithRectOfWidth:(CGFloat) w height:(CGFloat) h centeredAt:(NSPoint) p rotatedByDegrees:(CGFloat) d
{
	NSBezierPath * result = [NSBezierPath bezierPathWithRect:NSMakeRect(p.x - w/2, p.y - h/2, w, h)];
	[result transformUsingAffineTransform:[NSAffineTransform transformRotatedAroundPoint:p degrees:d]];
	return result;
}

+(NSBezierPath *) bezierPathWithRectOfWidth:(CGFloat) w height:(CGFloat) h centeredAt:(NSPoint) p rotatedByRadians:(CGFloat) r
{
	NSBezierPath * result = [NSBezierPath bezierPathWithRect:NSMakeRect(p.x - w/2, p.y - h/2, w, h)];
	[result transformUsingAffineTransform:[NSAffineTransform transformRotatedAroundPoint:p radians:r]];
	return result;	
}

@end
