|
method
(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.
method
x : real? y : real? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?)) x2 : real? y2 : real?
Changed in version 1.12 of package draw-lib: Allow overlapping source and destination.
method
(send a-dc draw-arc x y width height start-radians end-radians) → void? 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. In unsmoothed or aligned mode, the path for the outline is adjusted by shrinking the bounding ellipse width and height by, after scaling, one drawing unit divided by the alignment scale.
method
(send a-dc draw-bitmap source dest-x dest-y [ style color mask]) → boolean? source : (is-a?/c bitmap%) dest-x : real? dest-y : real? style : (or/c 'solid 'opaque 'xor) = 'solid
color : (is-a?/c color%) = (send the-color-database find-color "black") mask : (or/c (is-a?/c bitmap%) #f) = #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 source, and its ok? must return true, otherwise an exn:fail:contract exception is raised. The source bitmap and 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 (independent of style, which controls how the white pixels of a monochrome source are handled).
If the mask bitmap is color with an alpha channel, its alpha channel is used as the mask for drawing source, and its color channels are ignored.
If the mask bitmap is color without an alpha channel, the color components of a given pixel are averaged to arrive at an inverse alpha value for the pixel. In particular, if the mask bitmap is grayscale, then the blackness of each mask pixel controls the opacity of the drawn pixel (i.e., the mask acts as an inverted alpha channel).
The current brush, current pen, and current text for the DC have no effect on how the bitmap is drawn, but the bitmap is scaled if the DC has a scale, and the DC’s alpha setting determines the opacity of the drawn pixels (in combination with an alpha channel of source, any given mask, and the alpha component of color when source is monochrome).
For post-script-dc% and pdf-dc% output, opacity from an alpha channel in source, from mask, or from color is rounded to full transparency or opacity.
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.
method
(send a-dc draw-bitmap-section source dest-x dest-y src-x src-y src-width src-height [ style color mask]) → boolean? 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 : (or/c 'solid 'opaque 'xor) = 'solid
color : (is-a?/c color%) = (send the-color-database find-color "black") mask : (or/c (is-a?/c bitmap%) #f) = #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.
method
(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?))
Brush filling and pen 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. In unsmoothed or aligned mode, the path for the outline is adjusted by, after scaling, shrinking the ellipse width and height by one drawing unit divided by the alignment scale.
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.
method
(send a-dc draw-lines points [ xoffset yoffset]) → void?
points :
(or/c (listof (is-a?/c point%)) (listof (cons/c real? real?))) xoffset : real? = 0 yoffset : real? = 0
See also set-smoothing for information on the 'aligned smoothing mode.
method
(send a-dc draw-path path [ xoffset yoffset fill-style]) → void? path : (is-a?/c dc-path%) xoffset : real? = 0 yoffset : real? = 0 fill-style : (or/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.
See also set-smoothing for information on the 'aligned smoothing mode.
method
(send a-dc draw-point x y) → void?
x : real? y : real?
method
(send a-dc draw-polygon points [ xoffset yoffset fill-style]) → void?
points :
(or/c (listof (is-a?/c point%)) (listof (cons/c real? real?))) xoffset : real? = 0 yoffset : real? = 0 fill-style : (or/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.
See also set-smoothing for information on the 'aligned smoothing mode.
method
(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?))
In unsmoothed or aligned mode, when the pen is size 0 or 1, the filling precisely overlaps the entire outline. More generally, in unsmoothed or aligned mode, the path for the outline is adjusted by shrinking the rectangle width and height by, after scaling, one drawing unit divided by the alignment scale.
See also set-smoothing for information on the 'aligned smoothing mode.
method
(send a-dc draw-rounded-rectangle x y width height [ radius]) → void? 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.
Brush filling and pen 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. In unsmoothed or aligned mode, the path for the outline is adjusted by, after scaling, shrinking the rectangle width and height by one drawing unit divided by the alignment scale.
See also set-smoothing for information on the 'aligned smoothing mode.
method
(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.
method
(send a-dc draw-text text x y [ combine-mode offset angle]) → void? text : string? x : real? y : real? combine-mode : 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-mode is #f, then the result is the same as if each character is drawn separately, and Unicode control characters are ignored. If combine-mode is 'grapheme, then the result is the same as if each Unicode grapheme cluster is drawn separately, but multiple characters of text that form a grapheme cluster may be drawn as a single glyph. Otherwise, for combine-mode as any true value except 'grapheme, text may be drawn with adjacent characters combined to form ligature glyphs, with Unicode combining characters as a single glyph, with kerning, with right-to-left rendering of characters, etc.
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.
Changed in version 1.20 of package draw-lib: Changed to treat combine-mode as 'graheme different than other true values.
For relevant devices, 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 relevant devices, an exception is raised if end-page is called when a page is not currently started by start-page.
method
(send a-dc get-background) → (is-a?/c color%)
method
(send a-dc get-backing-scale) → (>/c 0.0)
Added in version 1.12 of package draw-lib.
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.
method
(send a-dc get-clipping-region) → (or/c (is-a?/c region%) #f)
A post-script-dc% or pdf-dc% object returns scaling factors determined via get-scaling in ps-setup% at the time that the DC was created. A printer-dc% may also have a user-configured scaling factor.
method
(send a-dc get-gl-context) → (or/c (is-a?/c gl-context<%>) #f)
See gl-context<%> for more information.
The vector content corresponds to a transformation matrix in the following order:
xx: a scale from the logical x to the device x
yx: a scale from the logical y added to the device x
xy: a scale from the logical x added to the device y
yy: a scale from the logical y to the device y
x0: an additional amount added to the device x
y0: an additional amount added to the device y
See also set-initial-matrix and get-transformation.
method
(send a-dc get-origin) →
real? real?
See also set-origin and get-transformation.
method
(send a-dc get-path-bounding-box path type)
→
real? real? real? real? path : (is-a?/c dc-path%) type : (or/c 'path 'stroke 'fill)
For the type 'stroke the rectangle covers the area that would be affected (“inked”) when drawn with the current pen by draw-path in the drawing context (with a transparent brush). If the pen width is zero, then an empty rectangle will be returned. The size and clipping of the drawing context is ignored.
For the type 'fill the rectangle covers the area that would be affected (“inked”) by draw-path in the drawing context (with a non-transparent pen and brush). If the line width is zero, then an empty rectangle will be returned. The size and clipping of the drawing context are ignored.
For the type 'path the rectangle covers the path, but the pen and brush are ignored. The size and clipping of the drawing context are also ignored. More precisely: The result is defined as the limit of the bounding boxes returned by the 'stroke type for line widths approaching 0 with a round pen cap. The “limit process” stops when an empty rectangle is returned. This implies that zero-area segments contributes to the rectangle.
For all types if the path is empty, then an empty rectangle (values 0 0 0 0) will be returned.
method
(send a-dc get-rotation) → real?
See also set-rotation and get-transformation.
See also set-scale and get-transformation.
method
(send a-dc get-smoothing)
→ (or/c 'unsmoothed 'smoothed 'aligned)
method
(send a-dc get-text-background) → (is-a?/c color%)
method
(send a-dc get-text-extent string [ font combine-mode offset])
→
(and/c real? (not/c negative?)) (and/c real? (not/c negative?)) (and/c real? (not/c negative?)) (and/c real? (not/c negative?)) string : string? font : (or/c (is-a?/c font%) #f) = #f combine-mode : any/c = #f offset : exact-nonnegative-integer? = 0
Returns the size of str as 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-mode is #f, then the result is the same as if each character is measured separately, and Unicode control characters are ignored. If combine-mode is 'grapheme, then the result is the same as if each Unicode grapheme cluster is measured separately, but multiple characters of text that form a grapheme cluster may be measured as a single glyph. Otherwise, for combine-mode as any true value except 'grapheme, text may be measured with adjacent characters combined to form ligature glyphs, with Unicode combining characters as a single glyph, with kerning, with right-to-left rendering of characters, etc.
Unlike most methods, this method can be called for a bitmap-dc% object without a bitmap installed.
> (define text-size-dc (new bitmap-dc% [bitmap (make-object bitmap% 1 1)])) > (send text-size-dc get-text-extent "Pickles")
54.0
19.0
4.0
0.0
Changed in version 1.20 of package draw-lib: Changed to treat combine-mode as 'graheme different than other true values.
method
(send a-dc get-text-foreground) → (is-a?/c color%)
method
(send a-dc get-text-mode) → (or/c 'solid 'transparent)
method
(send a-dc get-transformation)
→
(vector/c (vector/c real? real? real? real? real? real?) real? real? real? real? real?)
The vector content is as follows:
the initial transformation matrix; see get-initial-matrix;
the X and Y origin; see get-origin;
the X and Y scale; see get-origin;
a rotation; see get-rotation.
method
(send a-dc glyph-exists? c) → boolean?
c : char?
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? .
method
(send a-dc resume-flush) → void?
Afterward, the drawing context’s transformation is represented in the initial transformation matrix, and the separate origin, scale, and rotation settings have their identity values.
Afterward, the drawing context’s transformation is represented in the initial transformation matrix, and the separate origin, scale, and rotation settings have their identity values.
method
(send a-dc set-alignment-scale scale) → void?
scale : (>/c 0.0)
The default alignment scale is 1.0, which means that drawing coordinates and pen sizes are aligned to integer values.
An alignment scale of 2.0 aligns drawing coordinates to half-integer values. A value of 2.0 could be suitable for a bitmap-dc% whose destination is a bitmap with a backing scale of 2.0, since half-integer values correspond to pixel boundaries. Even when a destinate context 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.
Added in version 1.1 of package draw-lib.
method
(send a-dc set-background color) → void?
color : (is-a?/c color%) (send a-dc set-background color-name) → void? color-name : string?
method
brush : (is-a?/c brush%) (send a-dc set-brush color style) → void? color : (is-a?/c color%)
style :
(or/c 'transparent 'solid 'opaque 'xor 'hilite 'panel 'bdiagonal-hatch 'crossdiag-hatch 'fdiagonal-hatch 'cross-hatch 'horizontal-hatch 'vertical-hatch) (send a-dc set-brush color-name style) → void? color-name : string?
style :
(or/c 'transparent 'solid 'opaque 'xor 'hilite 'panel 'bdiagonal-hatch 'crossdiag-hatch 'fdiagonal-hatch 'cross-hatch 'horizontal-hatch 'vertical-hatch)
method
(send a-dc set-clipping-rect x y width height) → void? 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.
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.
See get-initial-matrix for information on the matrix as represented by a vector m.
See also transform, which adds a transformation to the current transformation, instead of changing the transformation composition in the middle.
method
(send a-dc set-origin x y) → void?
x : real? y : real?
See also translate, which adds a translation to the current transformation, instead of changing the transformation composition in the middle.
method
pen : (is-a?/c pen%) (send a-dc set-pen color width style) → void? color : (is-a?/c color%) width : (real-in 0 255)
style :
(or/c 'transparent 'solid 'xor 'hilite 'dot 'long-dash 'short-dash 'dot-dash 'xor-dot 'xor-long-dash 'xor-short-dash 'xor-dot-dash) (send a-dc set-pen color-name width style) → void? color-name : string? width : (real-in 0 255)
style :
(or/c 'transparent 'solid 'xor 'hilite 'dot 'long-dash 'short-dash 'dot-dash 'xor-dot 'xor-long-dash 'xor-short-dash 'xor-dot-dash)
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.
method
(send a-dc set-rotation angle) → void?
angle : real?
See also rotate, which adds a rotation to the current transformation, instead of changing the transformation composition.
See also scale, which adds a scale to the current transformation, instead of changing the transformation composition in the middle.
method
(send a-dc set-smoothing mode) → void?
mode : (or/c 'unsmoothed 'smoothed 'aligned)
The smoothing mode is either 'unsmoothed, 'smoothed, or 'aligned. Both 'aligned and 'smoothed are smoothing modes that enable anti-aliasing, while both 'unsmoothed and 'aligned adjust drawing coordinates to match pixel boundaries. For most applications that draw to the screen or bitmaps, 'aligned mode is the best choice.
Conceptually, 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) in 'smoothed mode draws a 2-pixel wide line with 50% opacity.
In 'unsmoothed and 'aligned modes, drawing coordinates are truncated based on the alignment scale of the drawing context. Specifically, when the alignment scale is 1.0, drawing coordinates are truncated to integer coordinates. More generally, drawing coordinates are shifted toward zero so that the result multipled by the alignment scale is integral. For line drawing, coordinates are further shifted based on the pen width and the alignment scale, where the shift corrsponds to half of the pen width (reduced to a value such that its multiplication times the alignment scale times two produces an integer). 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 divided by the alignment scale.
method
(send a-dc set-text-background color) → void?
color : (is-a?/c color%) (send a-dc set-text-background color-name) → void? color-name : string?
For monochrome drawing, all non-white colors are treated as black.
method
(send a-dc set-text-foreground color) → void?
color : (is-a?/c color%) (send a-dc set-text-foreground color-name) → void? color-name : string?
For monochrome drawing, all non-black colors are treated as white.
method
(send a-dc set-text-mode mode) → void?
mode : (or/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.
method
(send a-dc set-transformation t) → void?
t :
(vector/c (vector/c real? real? real? real? real? real?) real? real? real? real? real?)
For relevant devices, 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.
method
(send a-dc start-page) → void?
Relevant devices, 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%.
method
(send a-dc suspend-flush) → void?
See get-initial-matrix for information on the matrix as represented by a vector m.
Afterward, the drawing context’s transformation is represented in the initial transformation matrix, and the separate origin, scale, and rotation settings have their identity values.
Afterward, the drawing context’s transformation is represented in the initial transformation matrix, and the separate origin, scale, and rotation settings have their identity values.