Quartz modifies the results of drawing operations according to the parameters in the current graphics state. The graphics state contains parameters that would otherwise be taken as arguments to drawing routines. Routines that draw to a graphics context consult the graphics state to determine how to render their results. For example, when you call a function to set the fill color, you are modifying a value stored in the current graphics state. Other commonly used elements of the current graphics state include the line width, the current position, and the text font size.
The graphics context contains a stack of graphics states. When Quartz creates a graphics context, the stack is empty. When you save the graphics state, Quartz pushes a copy of the current graphics state onto the stack. When you restore the graphics state, Quartz pops the graphics state off the top of the stack. The popped state becomes the current graphics state.
To save the current graphics state, use the function CGContextSaveGState to push a copy of the current graphics state onto the stack. To restore
a previously saved graphics state, use the function CGContextRestoreGState to replace the current graphics state with the graphics state that’s on top of the stack.
本文介绍了Quartz如何通过图形状态管理来控制绘制操作。Quartz使用当前图形状态中的参数来修改绘制结果,包括填充颜色、线宽、当前位置及字体大小等。此外,还详细解释了如何保存和恢复图形状态。
4536

被折叠的 条评论
为什么被折叠?



