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: Ken Ferry <email@hidden>
- Date: Thu, 29 Apr 2010 23:48:15 -0700
On Thu, Apr 29, 2010 at 11:46 PM, Ken Ferry <email@hidden> wrote:
> On Thu, Apr 29, 2010 at 10:28 PM, Graham Cox <email@hidden>wrote:
>
>>
>> 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.
>>
>
> Well, each thread has a stack of contexts, and each context has a stack of
> states. +saveGraphicsState first does [currentGraphicsContext
> saveGraphicsState] which pushes state, then pushes the context itself onto
> the thread's stack of contexts.
>
…which may be what Graham said, or what you said, or both, or I don't know.
Anyway. That. :-)
-Ken
Cocoa Frameworks
>
>
>>
>>
>> > 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
>>
>
>
_______________________________________________
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