Hi,
How can one image be rotated with axis of rotation as image centre using NSAffineTransform.
Hi,
How can one image be rotated with axis of rotation as image centre using NSAffineTransform.
You need to translate the origin to the point you want to rotate around, do the rotation and then translate the origin back:
@implementation NSAffineTransform (Rotation)
+ (NSAffineTransform *)transformRotatingAroundPoint:(NSPoint) p byDegrees:(CGFloat) deg
{
NSAffineTransform * transform = [NSAffineTransform transform];
[transform translateXBy: p.x yBy: p.y];
[transform rotateByDegrees:deg];
[transform translateXBy: -p.x yBy: -p.y];
return transform;
}
@end