Re: Yet another NSAffineTransform problem
Re: Yet another NSAffineTransform problem
- Subject: Re: Yet another NSAffineTransform problem
- From: "I. Savant" <email@hidden>
- Date: Wed, 11 Jan 2006 18:07:16 -0500
Thanks, Corbin ... no joy. I modified the lines you mentioned and
still no label unless I remove the transform.
Any other ideas? I've been hammering away at this problem for four
hours now and counting. :-/
--
I.S.
On Jan 11, 2006, at 5:06 PM, Corbin Dunn wrote:
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