2 Drawing State
Drawing operations on a DC depend on its current pen, brush, and other state.
property | |||
| |||
property | |||
property | |||
| |||
property | |||
property | |||
property | |||
This effect is different than setting DC.alpha (times the current DC.alpha result) in the case that drawing between DC.start_alpha and DC.end_alpha produces overlapping output. In that case, adjusting DC.alpha would affect the drawing operations separately, while DC.start_alpha creates an opacity adjustment on the overlapped result, instead.
The DC.using_alpha form returns the result of the body sequence, but adds a DC.start_alpha(alpha) call before and DC.end_alpha() call afterward.
property | |||
| |||
| |||
property | |||
|
Beware that getting and setting DC.transformation does not save and restore precisely the same internal transformation state of dc. For cases where that is needed, DC.layered_transformation produces and consumes an opaque value representing the internal state The DC.save and DC.restore methods use DC.layered_transformation, for example.
method | |
| |
method | |
| |
| |
method | |
| |
method | |
| |
| |
method | |
| |
method | |
|
method | |||
| |||
method | |||
| |||
expression | |||
|
The DC.save method pushes the current drawing state (pen, brush, clipping region, and transformation) onto an internal stack, and DC.restore pops the stack and restores the popped drawing state. The DC.save_and_restore form wraps a body sequence to save the drawing state on entry to the sequence and restore it on exit, returning the value(s) produced by the body sequence; entry and exit cover continuation jumps, like try.
property | ||||
| ||||
property | ||||
| ||||
enumeration | ||||
|
#'smoothed: The default smoothing mode, which uses anti-aliasing and does not adjust drawing coordinates to align them.
#'unsmoothed: Draws without anti-aliasing. Drawing coordinates are rounded to the nearest pixel after the alignment scale, after taking into account scaling after the drawing context’s current transformation.
#'aligned: Draws with anti-aliasing, but drawing coordinates are rounded to the nearest pixel after the alignment scale, after taking into account scaling after the drawing context’s current transformation.
An alignment scale of 2.0 aligns drawing coordinates to half-integer values. A value of 2.0 could be suitable for drawing to a bitmap with a backing scale of 2.0, since half-integer values correspond to pixel boundaries. Even when a destination bitmap has a backing scale of 2.0, however, an alignment scale of 1.0 may be desirable to maintain consistency with drawing contexts that have a backing scale and alignment scale of 1.0.