Re: Getting a bezier path for a character
Re: Getting a bezier path for a character
- Subject: Re: Getting a bezier path for a character
- From: "danchik" <email@hidden>
- Date: Thu, 29 Apr 2010 22:41:28 -0700
did not get restored without inverting and concating the transform (not
until adding another save/restore after loading new context)
----- Original Message -----
From: "Graham Cox" <email@hidden>
To: "danchik" <email@hidden>
Cc: "Cocoa-Dev List" <email@hidden>
Sent: Thursday, April 29, 2010 10:28 PM
Subject: Re: Getting a bezier path for a character
On 30/04/2010, at 2:21 PM, danchik wrote:
mine did not,
Did not what?
so I think I might have used context incorrectly:
I had a different context to draw into so the code was :
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:MyActualContext];
// do the text draw/rotate
[NSGraphicsContext restoreGraphicsState];
I was under impression that [... restoreGraphicsState] would restore the
last context at the time it was [... saveGraphicsState]ed?
Or does each context have its own state stack?
No. Each thread has its own state stack, so what you said is right - it will
restore the graphics context that was current when +saveGraphicsState was
invoked.
Would the proper way to draw to a different context be to save the current
context first???
Yes, which is what your code above will do.
What it won't do is to 'undo' the transform of the second context. Rather
than bother doing that, it might be easier just to reset it at the start, or
use -set instead of -concat. If the second context has no other
transformations needed on it, (as a view's context must do) then that should
work. On the other hand, a view's context is always set up before -drawRect:
is called so you usually don't have to worry about undoing additional
transforms there either if nothing else draws following your rotated
drawing.
To reset the transform completely:
[[NSAffineTransform transform] set];
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden