Re: Yet another NSAffineTransform problem
Re: Yet another NSAffineTransform problem
- Subject: Re: Yet another NSAffineTransform problem
- From: Corbin Dunn <email@hidden>
- Date: Wed, 11 Jan 2006 14:06:07 -0800
Off the top of my head (not sure if this is right):
[[NSGraphicsContext currentContext] saveGraphicsState];
NSAffineTransform * at = [NSAffineTransform transform];
[at rotateByDegrees:180.0f];
[at translateXBy:[aLabel size].width/2 yBy:[aLabel size].height/2];
[at translateXBy:NSMidX(imgRect) yBy:NSMidY(imgRect)];
[at concat];
// [aLabel drawAtPoint:NSMakePoint(NSMidX(imgRect), NSMidY(imgRect)];
[aLabel drawAtPoint:NSZeroPoint];
[[NSGraphicsContext currentContext] restoreGraphicsState];
If I don't "concat" the transform, the label draws just fine,
dead-centered in the image. What on earth am I misunderstanding here?
Basically, if you want to rotate the image around the center of it,
then the origin needs to be at the center.
What you had was a rotation of the point NSMakePoint(NSMidX(imgRect),
NSMidY(imgRect) around the label size.
-corbin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden