On this page:
DC
DC.handle
DC.from_  handle
DC.width
DC.height
DC.size
DC.clear
DC.pen
DC.brush
DC.font
DC.clipping_  region
DC.transformation
DC.layered_  transformation
DC.scale
DC.translate
DC.rotate
DC.transform
DC.save
DC.restore
DC.save_  and_  restore
DC.point
DC.line
DC.lines
DC.polygon
DC.rectangle
DC.rounded_  rectangle
DC.ellipse
DC.arc
DC.path
DC.text
DC.bitmap
DC.copy
DC.font_  metrics_  key
DC.Bitmap  Overlay
DC.Bitmap  Overlay.solid
DC.Bitmap  Overlay.opaque
DC.Bitmap  Overlay.xor
DC.Text  Combine
DC.Text  Combine.kern
DC.Text  Combine.grapheme
DC.Text  Combine.char
DC.Fill
DC.Fill
DC.Fill.winding
8.15.0.2

1.1 Generic Drawing Context🔗ℹ

interface

interface draw.DC

Represents a drawing context that renders to some destination, such as a bitmap or the screen.

One way to get a drawing context is Bitmap.make_dc.

property

property (dc :: draw.DC).handle :: Any

 

function

fun draw.DC.from_handle(hand :: Any) :: DC

The DC.handle property returns a Racket object that corresponds to the drawing context for use directly with racket/draw. The DC.from_handle function creates a DC from such a Racket object.

property

property (dc :: draw.DC).width :: NonnegReal

 

property

property (dc :: draw.DC).height :: NonnegReal

 

property

property (dc :: draw.DC).size :: Size

The size of the drawing area: width, height, or both.

method

method (dc :: draw.DC).clear() :: Void

Resets the output to an empty state.

Properties to get or set the drawing context’s configuration.

Beware that getting and setting DC.transformation does not save and restore precisely the same internal transformation state of dc. For cases where that is needed, DC.layered_transformation produces and consumes an opaque value representing the internal state The DC.save and DC.restore methods use DC.layered_transformation, for example.

method

method (dc :: draw.DC).scale(s :: Real) :: Void

 

method

method (dc :: draw.DC).scale(sx :: Real, sy :: Real) :: Void

 

method

method (dc :: draw.DC).translate(dpt :: PointLike) :: Void

 

method

method (dc :: draw.DC).translate(dx :: Real, dy :: Real) :: Void

 

method

method (dc :: draw.DC).rotate(radians :: Real) :: Void

 

method

method (dc :: draw.DC).transform(t :: Transformation) :: Void

Applies a (further) transformation to the drawing context’s conversion from drawing coordinates to deivice coordinates. In other words, these methods change the result that is returned by the DC.transformation property, and they affect drawing accordingly.

method

method (dc :: draw.DC).save() :: Void

 

method

method (dc :: draw.DC).restore() :: Void

 

expression

dot (dc :: draw.DC).save_and_restore:

  body

  ...

Saves and restores the draw context’s configuration.

The DC.save method pushes the current drawing state (pen, brush, clipping region, and transformation) onto an internal stack, and DC.restore pops the stack and restores the popped drawing state. The DC.save_and_restore form wraps a body sequence to save the drawing state on entry to the sequence and restore it on exit, returning the value(s) produced by the body sequence; entry and exit cover continuation jumps, like try.

method

method (dc :: draw.DC).point(pt :: PointLike)

  :: Void

 

method

method (dc :: draw.DC).line(pt1 :: PointLike,

                            pt2 :: PointLike)

  :: Void

 

method

method (dc :: draw.DC).lines(

  [pt :: PointLike, ...],

  ~dpt: dpt :: PointLike = Point.zero,

  ~dx: dx :: Real = 0,

  ~dy: dy :: Real = 0

) :: Void

 

method

method (dc :: draw.DC).polygon(

  [pt :: PointLike, ...],

  ~dpt: dpt :: PointLike = Point.zero,

  ~dx: dx :: Real = 0,

  ~dy: dy :: Real = 0,

  ~fill: fill :: DC.Fill = #'even_odd

) :: Void

 

method

method (dc :: draw.DC).rectangle(r :: RectLike)

  :: Void

 

method

method (dc :: draw.DC).rounded_rectangle(r :: RectLike,

                                         radius :: Real = -0.25)

  :: Void

 

method

method (dc :: draw.DC).ellipse(r :: RectLike)

  :: Void

 

method

method (dc :: draw.DC).arc(r :: RectLike,

                           start :: Real, end :: Real)

  :: Void

 

method

method (dc :: draw.DC).path(p :: draw.Path,

                            ~dpt: dpt :: PointLike = Point.zero,

                            ~dx: dx :: Real = 0,

                            ~dy: dy :: Real = 0,

                            ~fill: fill :: DC.Fill = #'odd_even)

  :: Void

Draws lines into a drawing context using the current pen. In the case of drawing a polygon, rectangle, rounded rectangle, ellipse, or arc, a shape is fulled using the current brush, too.

Offsets through dpt and also dx or dy are combined.

method

method (dc:: draw.DC).text(

  str :: String,

  ~dpt: dpt :: PointLike = Point.zero,

  ~dx: dx :: Real = 0,

  ~dy: dy :: Real = 0,

  ~combine: combine :: DC.TextCombine = #'kern,

  ~angle: angle :: Real = 0.0

) :: Void

Draws text into a drawing context using the current font.

method

method (dc :: draw.DC).bitmap(

  bm :: Bitmap,

  ~dpt: dpt :: PointLike = Point.zero,

  ~dx: dx :: Real = 0,

  ~dy: dy :: Real = 0,

  ~source: source :: RectLike:

             Rect(Point.zero, Bitmap.size(bm)),

  ~style: style :: DC.BitmapOverlay = #'solid,

  ~color: color :: Color = Color("black"),

  ~mask: mask :: maybe(Bitmap) = #false,

) :: Void

Draws a region of a bitmap into the drawing context. The default source region is the entire bitmap.

method

method (dc :: draw.DC).copy(source :: RectLike,

                            dest :: PointLike)

  :: Void

Copies a portion of the draw context’s content to another portion of the drawing context. The source and destination regions can overlap.

Returns a value that changes when the selected font is changed to one with different metrics.

enumeration

enum draw.DC.BitmapOverlay:

  solid

  opaque

  xor

Bitmap transfer modes.

enumeration

enum draw.DC.TextCombine:

  kern

  grapheme

  char

Typesetting modes for text.

enumeration

enum draw.DC.Fill:

  even_odd

  winding

Polygon fill modes.