23 record-dc%

▼ |  | The Racket Drawing Toolkit

1 | Overview
2 | bitmap%
3 | bitmap-dc%
4 | brush%
5 | brush-list%
6 | color%
7 | color-database<%>
8 | dc<%>
9 | dc-path%
10 | font%
11 | font-list%
12 | font-name-directory<%>
13 | gl-config%
14 | gl-context<%>
15 | linear-gradient%
16 | pdf-dc%
17 | pen%
18 | pen-list%
19 | point%
20 | post-script-dc%
21 | ps-setup%
22 | radial-gradient%
23 | record-dc%
24 | region%
25 | svg-dc%
26 | Drawing Functions
27 | Drawing Contracts
28 | Signature and Unit
29 | Unsafe Libraries
30 | Drawing Conveniences
31 | Platform Dependencies
| Bibliography
| Index

On this page:

new
get-recorded-datum
get-recorded-procedure
get-ink-extent

Inherited methods:
from dc<%>
cache-font-metrics-key
clear
copy
draw-arc
draw-bitmap
draw-bitmap-section
draw-ellipse
draw-line
draw-lines
draw-path
draw-point
draw-polygon
draw-rectangle
draw-rounded-rectangle
draw-spline
draw-text
end-alpha
end-doc
end-page
erase
flush
get-alpha
get-background
get-backing-scale
get-brush
get-char-height
get-char-width
get-clipping-region
get-device-scale
get-font
get-gl-context
get-initial-matrix
get-origin
get-path-bounding-box
get-pen
get-rotation
get-scale
get-size
get-smoothing
get-text-background
get-text-extent
get-text-foreground
get-text-mode
get-transformation
glyph-exists?
ok?
resume-flush
rotate
scale
set-alignment-scale
set-alpha
set-background
set-brush
set-clipping-rect
set-clipping-region
set-font
set-initial-matrix
set-origin
set-pen
set-rotation
set-scale
set-smoothing
set-text-background
set-text-foreground
set-text-mode
set-transformation
start-alpha
start-doc
start-page
suspend-flush
transform
translate
try-color

Racket
top contents ← prev up next →

class record-dc% : class?
superclass: object%
extends: | dc<%>

A record-dc% object records drawing actions for replay into another drawing context. The recorded drawing operations can be extracted as a procedure via get-recorded-procedure, or the actions can be extracted as a datum (that can be printed with write and recreated with read) via get-recorded-datum.

When drawing recorded actions, the target drawing context’s pen, brush, font, text, background, text background, and text foreground do not affect the recorded actions. The target drawing context’s transformation, alpha, and clipping region compose with settings in the recorded actions (so that, for example, a recorded action to set the clipping region actually intersects the region with the drawing context’s clipping region at the time that the recorded commands are replayed). After recoded commands are replayed, all settings in the target drawing context, such as its clipping region or current font, are as before the replay.

> > constructor
> > (new record-dc% |
> > | [ | [width width] |
> > |  | [height height] |
> > |  | [record-ink? record-ink?]]) |
> → (is-a?/c record-dc%)
> width : (>=/c 0) = 640
> height : (>=/c 0) = 480
> record-ink? : any/c = #f

Creates a new recording DC. The optional width and height arguments determine the result of get-size on the recording DC; the width and height arguments do not clip drawing.

If record-ink? is true, then the get-ink-extent method can report the bounds of a recorded drawing.

Changed in version 1.24 of package draw-lib: Added the record-ink? argument.

> method (send a-record-dc get-recorded-datum) → any/c

Extracts a recorded drawing to a value that can be printed with write and re-read with read. Use recorded-datum->procedure to convert the datum to a drawing procedure.

> method (send a-record-dc get-recorded-procedure)
> → ((is-a?/c dc<%>) . -> . void?)

Extracts a recorded drawing to a procedure that can be applied to another DC to replay the drawing commands to the given DC.

The get-recorded-procedure method can be more efficient than composing get-recorded-datum and recorded-datum->procedure.

> > method
> > (send a-record-dc get-ink-extent) |  | → |  |
> > real? |  | real? |  | real? |  | real?

Returns a rectangle as left, top, width, and height that bounds all drawing into the given DC, as long as ink recording was enabled through the record-ink? initialization argument. Bounding drawing “ink” takes into account the visible effect of drawing with different pen widths and the shape of drawn text, as opposed to just collecting path coordinates and nominal text extents.

If ink record is not enabled, the exn:fail exception is raised.

Added in version 1.24 of package draw-lib.

top contents ← prev up next →