On this page:
Record  DC
Record  DC.get_  draw
Record  DC.get_  record
Record  DC.record_  to_  draw
Record  DC.ink_  extent
0.45+9.1

4.4 Recording Drawing Contexts🔗ℹ

class

class draw.RecordDC():

  implements DC

  constructor (

    size :: SizeLike,

    ~record_ink: record_ink :: Any.to_boolean = #false

  )

Creates a drawing context that records drawing operations for replay later. The size argument merely determines the result of DC.size, and it does not clip drawing operations.

If record_ink is true, then drawing records ink effects so that RecordDC.ink_extent can report ink bounds.

Use RecordDC.get_draw to get a drawing function that replays the recorded drawing, or use RecordDC.get_record to get a value that can be serialized, deserialized, and converted to a drawing function with RecordDC.record_to_draw.

method

method (dc :: draw.RecordDC).get_draw()

  :: DC -> Void

Returns a drawing function that plays a recorded drawing (as of the point where RecordDC.get_draw is called) onto a given DC. The function can be called any number of times.

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.

method

method (dc :: draw.RecordDC).get_record() :: Any

 

function

fun draw.RecordDC.record_to_draw(rec :: Any) :: DC -> Void

The RecordDC.get_record method returns a serializable value that represents a recorded drawing (as of the point where RecordDC.get_record is called). The RecordDC.record_to_draw function takes such a value and returns a function that performs the drawing into a given DC.

A drawing function returned by RecordDC.record_to_draw behaves like one from RecordDC.get_draw.

method

method (dc :: draw.RecordDC).ink_extent() :: Rect

Returns a rectangle that bounds all drawing into dc, as long as ink recording was enabled through the ~record_ink constructor argument for RecordDC.

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 for dc, RecordDC.ink_extent throws an exception.