The drawing methods, such as draw-rectangle, accept real number values as arguments, but the results are only well-defined when the drawing coordinates are in the range -16383 to 16383. This restriction applies to the coordinates both before and after offsets and scaling factors are applied.
(send a-dc cache-font-metrics-key) → exact-integer? |
A 0 result indicates that the current configuration of a-dc does not fit into a common category, and so no key is available for caching text-extent information.
| ||||||||||||||||||||||||||||||||||||||||||
x : real? | ||||||||||||||||||||||||||||||||||||||||||
y : real? | ||||||||||||||||||||||||||||||||||||||||||
width : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||||
height : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||||
start-radians : real? | ||||||||||||||||||||||||||||||||||||||||||
end-radians : real? |
The current pen is used for the arc. If the current brush is not transparent, it is used to fill the wedge bounded by the arc plus lines (not drawn) extending to the center of the inscribed ellipse.
If both the pen and brush are non-transparent, the wedge is filled with the brush before the arc is drawn with the pen. The wedge and arc meet so that no space is left between them, but the precise overlap between the wedge and arc is platform- and size-specific. Typically, the regions drawn by the brush and pen overlap. More generally, the pen is centered over the outline of the arc, rounding toward the center in unsmoothed mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
| ||||||||||||||||||||||||||||||||||||||||||
source : (is-a?/c bitmap%) | ||||||||||||||||||||||||||||||||||||||||||
dest-x : real? | ||||||||||||||||||||||||||||||||||||||||||
dest-y : real? | ||||||||||||||||||||||||||||||||||||||||||
style : (one-of/c 'solid 'opaque 'xor) = 'solid | ||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||
mask : (or/c (is-a?/c bitmap%) false/c) = #f |
For color bitmaps, the drawing style and color arguments are ignored. For monochrome bitmaps, draw-bitmap uses the style and color arguments in the same way that a brush uses its style and color settings to draw a monochrome stipple (see brush% for more information).
If a mask bitmap is supplied, it must have the same width and height as the bitmap to display, and its ok? must return true, otherwise an exn:fail:contract exception is raised. The bitmap to draw and the mask bitmap can be the same object, but if the drawing context is a bitmap-dc% object, both bitmaps must be distinct from the destination bitmap, otherwise an exn:fail:contract exception is raised.
If the mask bitmap is monochrome, drawing occurs in the target dc<%> only where the mask bitmap contains black pixels.
If the mask bitmap is grayscale and the bitmap to draw is not monochrome, then the blackness of each mask pixel controls the opacity of the drawn pixel (i.e., the mask acts as an inverted alpha channel), at least on most platforms. (Non-monochrome masks are collapsed to monochrome under X when the RENDER extension is not available, and under Windows 95 and NT when "msing32.dll" is not available.) Other combinations involving a non-monochrome mask (i.e., a non-grayscale mask or a monochrome bitmap to draw) produce platform-specific results.
The current brush, current pen, current text, and current alpha settings for the DC have no effect on how the bitmap is drawn, but the bitmap is scaled if the DC has a scale.
For post-script-dc% output, the mask bitmap is currently ignored, and the 'solid style is treated the same as 'opaque. (However, mask bitmaps and 'solid drawing may become supported for post-script-dc% in the future.)
The result is #t if the bitmap is successfully drawn, #f otherwise (possibly because the bitmap’s ok? method returns #f).
See also draw-bitmap-section.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
source : (is-a?/c bitmap%) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dest-x : real? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dest-y : real? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
src-x : real? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
src-y : real? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
src-width : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
src-height : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
style : (one-of/c 'solid 'opaque 'xor) = 'solid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mask : (or/c (is-a?/c bitmap%) false/c) = #f |
The src-x, src-y, src-width, and src-height arguments specify a rectangle in the source bitmap to copy into this drawing context.
See draw-bitmap for information about dest-x, dest-y, style, color, and mask.
(send a-dc draw-ellipse x y width height) → void? |
x : real? |
y : real? |
width : (and/c real? (not/c negative?)) |
height : (and/c real? (not/c negative?)) |
If both the pen and brush are non-transparent, the ellipse is filled with the brush before the outline is drawn with the pen. The filling and outline meet so that no space is left between them, but the precise overlap between the filling and outline is platform- and size-specific. Typically, the regions drawn by the brush and pen overlap. More generally, the pen is centered over the outline of the ellipse, rounding toward the center in unsmoothed mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
In unsmoothed mode, the points correspond to pixels, and the line covers both the start and end points. For a pen whose scaled width is larger than 1, the line is drawn centered over the start and end points.
See also set-smoothing for information on the 'aligned smoothing mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
| |||||||||||||||||||||
points : (listof (is-a?/c point%)) | |||||||||||||||||||||
xoffset : real? = 0 | |||||||||||||||||||||
yoffset : real? = 0 |
See also set-smoothing for information on the 'aligned smoothing mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
| ||||||||||||||||||||||||||||
path : (is-a?/c dc-path%) | ||||||||||||||||||||||||||||
xoffset : real? = 0 | ||||||||||||||||||||||||||||
yoffset : real? = 0 | ||||||||||||||||||||||||||||
fill-style : (one-of/c 'odd-even 'winding) = 'odd-even |
If both the pen and brush are non-transparent, the path is filled with the brush before the outline is drawn with the pen. The filling and outline meet so that no space is left between them, but the precise overlap between the filling and outline is platform- and size-specific. Thus, the regions drawn by the brush and pen may overlap. More generally, the pen is centered over the path, rounding left and down in unsmoothed mode.
The fill-style argument specifies the fill rule: 'odd-even or 'winding. In 'odd-even mode, a point is considered enclosed within the path if it is enclosed by an odd number of sub-path loops. In 'winding mode, a point is considered enclosed within the path if it is enclosed by more or less clockwise sub-path loops than counter-clockwise sub-path loops. In unsmoothed mode, the 'winding fill rule is not supported under Mac OS X and it is not supported when path contains multiple sub-paths; the 'winding fill rules is always supported when smoothing is enabled (see set-smoothing).
See also set-smoothing for information on the 'aligned smoothing mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
(send a-dc draw-point x y) → void? |
x : real? |
y : real? |
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
| ||||||||||||||||||||||||||||
points : (listof (is-a?/c point%)) | ||||||||||||||||||||||||||||
xoffset : real? = 0 | ||||||||||||||||||||||||||||
yoffset : real? = 0 | ||||||||||||||||||||||||||||
fill-style : (one-of/c 'odd-even 'winding) = 'odd-even |
If both the pen and brush are non-transparent, the polygon is filled with the brush before the outline is drawn with the pen. The filling and outline meet so that no space is left between them, but the precise overlap between the filling and outline is platform- and shape-specific. Thus, the regions drawn by the brush and pen may overlap. More generally, the pen is centered over the polygon lines, rounding left and down in unsmoothed mode.
The fill-style argument specifies the fill rule: 'odd-even or 'winding. In 'odd-even mode, a point is considered enclosed within the polygon if it is enclosed by an odd number of loops. In 'winding mode, a point is considered enclosed within the polygon if it is enclosed by more or less clockwise loops than counter-clockwise loops. The 'winding fill rule is not supported under Mac OS X, except when smoothing is enabled (see set-smoothing).
See also set-smoothing for information on the 'aligned smoothing mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
(send a-dc draw-rectangle x y width height) → void? |
x : real? |
y : real? |
width : (and/c real? (not/c negative?)) |
height : (and/c real? (not/c negative?)) |
If both the pen and brush are non-transparent, the rectangle is filled with the brush before the outline is drawn with the pen. In unsmoothed mode, when the pen is size 0 or 1, the filling precisely overlaps the entire outline. As a result, if a rectangle is drawn with a size-0 or size-1 'xor pen% and an 'xor brush%, the outline is xored twice (first by the brush, then by the pen), leaving it unchanged. More generally, the pen is centered over the outline of the rectangle, rounding toward the center in unsmoothed mode.
See also set-smoothing for information on the 'aligned smoothing mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
| |||||||||||||||||||||||||||||||||||
x : real? | |||||||||||||||||||||||||||||||||||
y : real? | |||||||||||||||||||||||||||||||||||
width : (and/c real? (not/c negative?)) | |||||||||||||||||||||||||||||||||||
height : (and/c real? (not/c negative?)) | |||||||||||||||||||||||||||||||||||
radius : real? = -0.25 |
If radius is positive, the value is used as the radius of the rounded corner. If radius is negative, the absolute value is used as the proportion of the smallest dimension of the rectangle.
If radius is less than -0.5 or more than half of width or height, an exn:fail:contract exception is raised.
If both the pen and brush are non-transparent, the rectangle is filled with the brush before the outline is drawn with the pen. The filling and outline meet so that no space is left between them, but the precise overlap between the filling and outline is platform- and size-specific. Thus, the regions drawn by the brush and pen may partially overlap. More generally, the pen is centered over the outline of the rounded rectangle, rounding toward the center in unsmoothed mode.
See also set-smoothing for information on the 'aligned smoothing mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
(send a-dc draw-spline x1 y1 x2 y2 x3 y3) → void? |
x1 : real? |
y1 : real? |
x2 : real? |
y2 : real? |
x3 : real? |
y3 : real? |
See also set-smoothing for information on the 'aligned smoothing mode. See also dc-path% and draw-path for drawing more complex curves.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
| ||||||||||||||||||||||||||||||||||||||||||
text : string? | ||||||||||||||||||||||||||||||||||||||||||
x : real? | ||||||||||||||||||||||||||||||||||||||||||
y : real? | ||||||||||||||||||||||||||||||||||||||||||
combine? : any/c = #f | ||||||||||||||||||||||||||||||||||||||||||
offset : exact-nonnegative-integer? = 0 | ||||||||||||||||||||||||||||||||||||||||||
angle : real? = 0 |
The text string is drawn starting from the offset character, and continuing until the end of text or the first null character.
If combine? is #t, then text may be measured with adjacent characters combined to ligature glyphs, with Unicode combining characters as a single glyph, with kerning, with right-to-left rendering of characters, etc. If combine? is #f, then the result is the same as if each character is measured separately, and Unicode control characters are ignored.
The string is rotated by angle radians counter-clockwise. If angle is not zero, then the text is always drawn in transparent mode (see set-text-mode).
The current brush and current pen settings for the DC have no effect on how the text is drawn.
See get-text-extent for information on the size of the drawn text.
See also set-text-foreground, set-text-background, and set-text-mode.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
For printer or PostScript output, an exception is raised if end-doc is called when the document is not started with start-doc, when a page is currently started by start-page and not ended with end-page, or when the document has been ended already.
For printer or PostScript output, an exception is raised if end-page is called when a page is not currently started by start-page.
(send a-dc get-background) → (is-a?/c color%) |
Unlike most methods, this method can be called for a bitmap-dc% object without a bitmap installed.
Unlike most methods, this method can be called for a bitmap-dc% object without a bitmap installed.
(send a-dc get-gl-context) |
→ (or/c (is-a?/c gl-context<%>) false/c) |
See gl-context<%> for more information.
|
See also set-origin.
See also set-scale.
(send a-dc get-smoothing) |
→ (one-of/c 'unsmoothed 'smoothed 'aligned) |
(send a-dc get-text-background) → (is-a?/c color%) |
| ||||||||||||||||||||||||||||||||
string : string? | ||||||||||||||||||||||||||||||||
font : (or/c (is-a?/c font%) false/c) = #f | ||||||||||||||||||||||||||||||||
combine? : any/c = #f | ||||||||||||||||||||||||||||||||
offset : exact-nonnegative-integer? = 0 |
Returns the size of str at it would be drawn in the drawing context, starting from the offset character of str, and continuing until the end of str or the first null character. The font argument specifies the font to use in measuring the text; if it is #f, the current font of the drawing area is used. (See also set-font.)
The result is four real numbers:
the total width of the text (depends on both the font and the text);
the total height of the font (depends only on the font);
the distance from the baseline of the font to the bottom of the descender (included in the height, depends only on the font); and
extra vertical space added to the font by the font designer (included in the height, and often zero; depends only on the font).
The returned width and height define a rectangle is that guaranteed to contain the text string when it is drawn, but the fit is not necessarily tight. Some undefined number of pixels on the left, right, top, and bottom of the drawn string may be “whitespace,” depending on the whims of the font designer and the platform-specific font-scaling mechanism.
If combine? is #t, then text may be drawn with adjacent characters combined to ligature glyphs, with Unicode combining characters as a single glyph, with kerning, with right-to-left ordering of characters, etc. If combine? is #f, then the result is the same as if each character is drawn separately, and Unicode control characters are ignored.
Unlike most methods, this method can be called for a bitmap-dc% object without a bitmap installed.
(send a-dc get-text-foreground) → (is-a?/c color%) |
(send a-dc get-text-mode) → (one-of/c 'solid 'transparent) |
Due to automatic font substitution when drawing or measuring text, the result of this method does not depend on the given font, which merely provides a hint for the glyph search. If the font is #f, the drawing context’s current font is used. The result depends on the type of the drawing context, but the result for canvas% dc<%> instances and bitmap-dc% instances is always the same for a given platform and a given set of installed fonts.
See also screen-glyph-exists? .
pen- and brush-based drawing when get-smoothing produces 'smoothed or 'aligned, and when the drawing context is not an instance of post-script-dc%; and
text drawing for most platforms (Mac OS X, X with Xft/fontconfig; transparency approximated under Windows by fading the drawing color), and when the drawing context is not an instance of post-script-dc.
A value of 0.0 corresponds to completely transparent (i.e., invisible) drawing, and 1.0 corresponds to completely opaque drawing. For intermediate values, drawing is blended with the existing content of the drawing context.
(send a-dc set-background color) → void? |
color : (is-a?/c color%) |
(send a-dc set-brush brush) → void? | |||||||||||
brush : (is-a?/c brush%) | |||||||||||
(send a-dc set-brush color style) → void? | |||||||||||
color : (is-a?/c color%) | |||||||||||
| |||||||||||
(send a-dc set-brush color-name style) → void? | |||||||||||
color-name : string? | |||||||||||
|
| ||||||||||||||||||||||||||||
x : real? | ||||||||||||||||||||||||||||
y : real? | ||||||||||||||||||||||||||||
width : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||
height : (and/c real? (not/c negative?)) |
See also set-clipping-region and get-clipping-region.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
The clipping region must be reset after changing a dc<%> object’s origin or scale (unless it is #f); see region% for more information.
See also set-clipping-rect and get-clipping-region.
(send a-dc set-origin x y) → void? |
x : real? |
y : real? |
Changing a dc<%> object’s origin or scale does not affect region% objects that were previously created. See region% for more information.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
(send a-dc set-pen pen) → void? | ||||||||||
pen : (is-a?/c pen%) | ||||||||||
(send a-dc set-pen color width style) → void? | ||||||||||
color : (is-a?/c color%) | ||||||||||
width : (real-in 0 255) | ||||||||||
| ||||||||||
(send a-dc set-pen color-name width style) → void? | ||||||||||
color-name : string? | ||||||||||
width : (real-in 0 255) | ||||||||||
|
The current pen does not affect text drawing; see also set-text-foreground.
While a pen is selected into a drawing context, it cannot be modified.
(send a-dc set-scale x-scale y-scale) → void? |
x-scale : (and/c real? (not/c negative?)) |
y-scale : (and/c real? (not/c negative?)) |
Changing a dc<%> object’s origin or scale does not affect region% objects that were previously created. See region% for more information.
Restrictions on the magnitude of drawing coordinates are described with dc<%>.
(send a-dc set-smoothing mode) → void? |
mode : (one-of/c 'unsmoothed 'smoothed 'aligned) |
Smoothing is supported under Windows only when Microsoft’s "gdiplus.dll" is installed (which is always the case for Windows XP). Smoothing is supported under Mac OS X always. Smoothing is supported under X only when Cairo is installed when GRacket is compiled. Smoothing is never supported for black-and-white contexts. Smoothing is always supported (and cannot be disabled) for PostScript output.
The smoothing mode is either 'unsmoothed, 'smoothed, or 'aligned. Both 'aligned and 'smoothed are smoothing modes.
In 'smoothed mode for a canvas or bitmap drawing context, integer drawing coordinates correspond to the boundary between pixels, and pen-based drawing is centered over a given line or curve. Thus, drawing with pen width 1 from (0, 10) to (10, 10) draws a 2-pixel wide line with 50% opacity.
The 'aligned smoothing mode is like 'smoothed, but it paints pixels more like 'unsmoothed mode. Since it aligns shapes to pixel boundaries, 'aligned mode often produces better results than 'smoothed, but the results depend on the application. The 'aligned mode is defined in terms of 'smoothed mode, except that drawing coordinates are rounded down (via floor, after scaling and origin translation). For line drawing, coordinates are then shifted right and down by the floor of half a pen width. In addition, for pen drawing through draw-rectangle, draw-ellipse, draw-rounded-rectangle, and draw-arc, the given width and height are each decreased by 1.0.
In either smoothing mode, brush and pen stipples are ignored (except for PostScript drawing), and 'hilite and 'xor drawing modes are treated as 'solid. If smoothing is not supported, then attempting to set the smoothing mode to 'smoothed or 'aligned will have no effect, and get-smoothing will always return 'unsmoothed. Similarly, get-smoothing for a post-script-dc% always returns 'smoothed.
(send a-dc set-text-background color) → void? |
color : (is-a?/c color%) |
For monochrome drawing, all non-white colors are treated as black.
(send a-dc set-text-foreground color) → void? |
color : (is-a?/c color%) |
For monochrome drawing, all non-black colors are treated as white.
(send a-dc set-text-mode mode) → void? |
mode : (one-of/c 'solid 'transparent) |
'solid – Before text is drawn, the destination area is filled with the text background color (see set-text-background).
'transparent – Text is drawn directly over any existing image in the destination, as if overlaying text written on transparent film.
For printer or PostScript output, an exception is raised if start-doc has been called already (even if end-doc has been called as well). Furthermore, drawing methods raise an exception if not called while a page is active as determined by start-doc and start-page.
(send a-dc start-page) → void? |
For printer or PostScript output, an exception is raised if start-page is called when a page is already started, or when start-doc has not been called, or when end-doc has been called already. In addition, in the case of PostScript output, Encapsulated PostScript (EPS) cannot contain multiple pages, so calling start-page a second time for a post-script-dc% instance raises an exception; to create PostScript output with multiple pages, supply #f as the as-eps initialization argument for post-script-dc%.