An object that represents a graphics context.
SDK
- macOS 10.0+
Framework
- App
Kit
Declaration
@interface NSGraphicsContext : NSObject
Overview
You can think of a graphics context as a destination to which drawing and graphics state operations are sent for execution. Each graphics context contains its own graphics environment and state.
The NSGraphics
class is an abstract superclass for destination-specific graphics contexts. You obtain instances of concrete subclasses with the class methods current
, graphics
, graphics
, graphics
, and graphics
.
At any time there is the notion of the current context. The current context for the current thread may be set using setCurrentContext:.
Graphics contexts are maintained on a stack. You push a graphics context onto the stack by sending it a save
message, and pop it off the stack by sending it a restore
message. By sending restore
to a graphics context object you remove it from the stack, and the next graphics context on the stack becomes the current graphics context.