• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Yet another NSAffineTransform problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Yet another NSAffineTransform problem
      • From: Douglas Davidson <email@hidden>
References: 
 >Yet another NSAffineTransform problem (From: "I. Savant" <email@hidden>)
 >Re: Yet another NSAffineTransform problem (From: Corbin Dunn <email@hidden>)

  • Prev by Date: NSDocument Ignoring Advisory Locks?
  • Next by Date: Re: Run application from code
  • Previous by thread: Re: Yet another NSAffineTransform problem
  • Next by thread: Re: Yet another NSAffineTransform problem
  • Index(es):
    • Date
    • Thread