In addition to its color and style, a brush can have a stipple bitmap. This stipple is used only in unsmoothed mode (see set-smoothing) or in a PostScript drawing context. Painting with a stipple brush is similar to calling draw-bitmap with the stipple bitmap in the filled region, except that the bitmap may not be scaled in the same way (depending on the platform and device).
A brush’s style is one of the following:
'transparent – Draws with no effect (on the interior of the drawn shape).
'solid – Draws using the brush’s color. If a monochrome stipple is installed into the brush, black pixels from the stipple are transferred to the destination using the brush’s color, and white pixels from the stipple are not transferred.
'opaque – Same as 'solid, except when a monochrome stipple is installed for unsmoothed or PostScript drawing; in that case, white pixels from the stipple are transferred to the destination using the destination’s background color.
'xor – In a smoothing mode or if a color stipple is installed, 'xor is treated as 'solid. Otherwise, the brush’s color or colored (monochrome) stipple is xor-ed with existing destination pixel values. The 'xor mapping is unspecified for arbitrary color combinations, but the mapping provides two guarantees:
Black-and-white drawing to a color or monochrome destination always works as expected: black xor white = black, white xor black = black, black xor black = white, and white xor white = white.
Performing the same drawing operation twice in a row with 'xor is equivalent to a no-op.
'hilite – In unsmoothed mode, existing destination pixels are “highlighted” in a platform-specific way when the brush color is black. Under Windows and X for a color drawing context, the inverted RGB components of destination pixel are combined with the RGB components of the system-wide highlight color using a bitwise “or”, and the combination is used. (Under X, the color is specified by the 'GRacket:hiliteColor preference preference; see Preferences.) Under Mac OS X for a color drawing context, the inverted RGB components of the system-wide highlight color are subtracted from the RGB components of each destination pixel, and the difference (or 0 for a negative result) is used. For any monochrome drawing context, 'hilite is the same as 'xor. For PostScript output, 'hilite uses a stipple that is an array of small dots (essentially a halftone), otherwise 'hilite is treated like 'solid in a smoothing mode.
'panel – In unsmoothed mode, draws with the same color and pattern as a top-level panel background, if the brush’s color is the same as the color returned by get-panel-background and if the brush has no stipple. To create a canvas% object that is drawn like a control, use the 'transparent canvas style instead, because certain kinds of nested panels have different background colors (e.g., a tab-panel% under Mac OS X). In a smoothing mode, 'panel is treated as 'solid.
The following modes correspond to built-in stipples drawn in 'solid mode:
However, when a specific stipple is installed into the brush for when drawing with a smoothing mode into a non-PostScript context, the above modes are ignored and 'solid is used, instead.
To draw outline shapes (such as unfilled boxes and ellipses), use the 'transparent brush style. See set-style for more information about styles.
To avoid creating multiple brushes with the same characteristics, use the global brush-list% object the-brush-list, or provide a color and style to set-brush in dc<%>.
(make-object brush%) → (is-a?/c brush%) | |||||||||||
(make-object brush% color style) → (is-a?/c brush%) | |||||||||||
color : (is-a?/c color%) | |||||||||||
| |||||||||||
(make-object brush% color-name style) → (is-a?/c brush%) | |||||||||||
color-name : string? | |||||||||||
|
(send a-brush get-style) | |||||||||
|
(send a-brush set-color color) → void? |
color : (is-a?/c color%) |
(send a-brush set-color color-name) → void? |
color-name : string? |
(send a-brush set-color red green blue) → void? |
red : (integer-in 0 255) |
green : (integer-in 0 255) |
blue : (integer-in 0 255) |
For the case that the color is specified using a string, see color-database<%> for information about color names.
A bitmap cannot be used as a stipple if it is selected into a bitmap-dc% object; if the given bitmap is selected into a bitmap-dc% object, an exn:fail:contract exception is raised. A brush cannot be modified if it was obtained from a brush-list% or while it is selected into a drawing context.
A pen’s stipple is not used in a smoothing mode, except for a post-script-dc% (which is always in a smoothing mode).
(send a-brush set-style style) → void? | |||||||||||
|