• 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: 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


  • Follow-Ups:
    • Re: Yet another NSAffineTransform problem
      • From: "I. Savant" <email@hidden>
References: 
 >Yet another NSAffineTransform problem (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: Force an Application to crash : possible ?
  • Next by Date: Re: Getting WebView and JavaScript to communicate. MFC can do it.
  • Previous by thread: Yet another NSAffineTransform problem
  • Next by thread: Re: Yet another NSAffineTransform problem
  • Index(es):
    • Date
    • Thread