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: Graham Cox <email@hidden>
- Date: Fri, 30 Apr 2010 15:28:31 +1000
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