On this page:
blank
rectangle
square
ellipse
circle
polygon
line
text
bitmap
dc
animate
Pict.from_  handle
Color  Mode
Color  Mode.inherit
Line  Width
Line  Width.inherit
Refocus
Refocus.around
Rounded
Rounded.default
Arc  Direction
Arc  Direction.cw
Arc  Direction.ccw
8.12

3 Pict Constructors🔗ℹ

function

fun blank(

  size :: Real = 0,

  ~width: width :: Real = size,

  ~height: height :: Real = size,

  ~ascent: ascent :: Real = height,

  ~descent: descent :: Real = 0

) :: StaticPict

Creates a blank static pict with the specified bounding box.

> blank(10).width

10

function

fun rectangle(

  ~around: around :: maybe(Pict) = #false,

  ~width: width :: Real: if around | Pict.width(around) | 32,

  ~height: height :: Real: if around | Pict.height(around) | width,

  ~fill: fill :: maybe(ColorMode) = #false,

  ~line: line :: maybe(ColorMode) = !fill && #'inherit,

  ~line_width: line_width :: LineWidth = #'inherit,

  ~order: order :: OverlayOrder = #'back,

  ~refocus: refocus_on :: maybe(Refocus) = #'around,

  ~epoch: epoch_align :: EpochAlignment = #'center,

  ~duration: duration_align :: DurationAlignment = #'sustain

) :: Pict

Creates a pict to draw a rectangle. If an around pict is provided, then it both supplies default width and height values an is overlayed on top of the rectangle image,

The rectangle has an outline if line is not #false, and it is filled in if fill is not #false. If the rectangle has an outline, line_width is used for the outline. A line, fill, or line_width can be #'inherit to indicate that a context-supplied color and line width should be used. See also Pict.colorize and Pict.colorize Pict.line_width.

If rounded is a non-negative number, it is used as the radius of an arc to use for the rectangle’s corners. If rounded is a negative number, it is negated and multipled by the rectangle’s width and height to get a radius (in each direction) for the rounded corner.

When the refocus_on argument is a pict, then Pict.refocus is used on the resulting pict with refocus_on as the second argument. If refocus is #'around and around is not #false, then the pict is refocused on around, and then padded if necessary to make the width and height match width and height.

The epoch_align and duration_align arguments are used only when around is supplied, and they are passed on to overlay to combine a static rectangle pict with around. The order argument is similarly passed along to overlay. If around is #false, the resulting pict is always a static pict.

> rectangle()

image

> rectangle(~fill: "lightblue", ~line: #false)

image

> rectangle(~line: "blue", ~rounded: #'default)

image

> rectangle(~around: text("Hello"), ~fill: "lightgreen")

image

function

fun square(

  ~around: around :: maybe(Pict) = #false,

  ~size: size :: Real: if around

                       | math.max(Pict.width(around), Pict.width(around))

                       | 32,

  ~fill: fill :: maybe(ColorMode) = #false,

  ~line: line :: maybe(ColorMode) = !fill && #'inherit,

  ~line_width: line_width :: LineWidth = #'inherit,

  ~order: order :: OverlayOrder = #'back,

  ~refocus: refocus_on :: maybe(Refocus) = #'around,

  ~epoch: epoch_align :: EpochAlignment = #'center,

  ~duration: duration_align :: DurationAlignment = #'sustain

) :: Pict

A shorthand for rectangle where the width and height are specified as size.

> square(~around: text("Hello"), ~fill: "lightgreen")

image

function

fun ellipse(

  ~around: around :: maybe(Pict) = #false,

  ~width: width :: Real: if around | Pict.width(around) | 32,

  ~height: height :: Real: if around | Pict.height(around) | width,

  ~arc: arc :: maybe(ArcDirection) = #false,

  ~start: start :: Real = 0,

  ~end: end :: Real = 2 * math.pi,

  ~fill: fill :: maybe(ColorMode) = #false,

  ~line: line :: maybe(ColorMode) = !fill && #'inherit,

  ~line_width: line_width :: LineWidth = #'inherit,

  ~order: order :: OverlayOrder = #'back,

  ~refocus: refocus_on :: maybe(Refocus) = #'around,

  ~epoch: epoch_align :: EpochAlignment = #'center,

  ~duration: duration_align :: DurationAlignment = #'sustain

) :: Pict

Like rectangle, but for an ellipse or arc/wedge. The pict draws an arc or widge if arc is #'cw (clockwise) or #'ccw (counterclockwise).

> ellipse(~around: text("Hello"), ~fill: "lightgreen")

image

function

fun circle(

  ~around: around :: maybe(Pict) = #false,

  ~size: size :: Real: if around

                       | math.max(Pict.width(around), Pict.width(around))

                       | 32,

  ~arc: arc :: maybe(ArcDirection) = #false,

  ~start: start :: Real = 0,

  ~end: end :: Real = 2 * math.pi,

  ~fill: fill :: maybe(ColorMode) = #false,

  ~line: line :: maybe(ColorMode) = !fill && #'inherit,

  ~line_width: line_width :: LineWidth = #'inherit,

  ~order: order :: OverlayOrder = #'back,

  ~refocus: refocus_on :: maybe(Refocus) = #'around,

  ~epoch: epoch_align :: EpochAlignment = #'center,

  ~duration: duration_align :: DurationAlignment = #'sustain

) :: Pict

Like square, but a shorthand for ellipse.

> circle(~around: text("Hello"), ~fill: "lightgreen")

image

function

fun polygon(

  [pt :: draw.PointLike.to_point, ...],

  ~fill: fill :: maybe(ColorMode) = #false,

  ~line: line :: maybe(ColorMode) = !fill && #'inherit,

  ~line_width: line_width :: LineWidth = #'inherit

) :: Pict

Creates a pict that draws a polygon. The maximum x and y values among the pts determine the resulting pict’s bounding box.

> polygon([[0, 0], [50, 0], [50, 50]], ~fill: "lightgreen")

image

function

fun line(

  ~dx: dx :: Real = 0,

  ~dy: dy :: Real = 0,

  ~line: color :: maybe(ColorMode) = #'inherit,

  ~line_width: width :: LineWidth = #'inherit

) :: Pict

Creates a pict that draws a line from the top-left of the pict. The dx and dy arguments determine both the shape of the line and the width and height of the pict.

> line(~dx: 10, ~line_width: 3)

image

> line(~dy: 10, ~line: "blue", ~line_width: 3)

image

> line(~dx: 10, ~dy: 10)

image

function

fun text(content :: String,

         ~font: font :: draw.Font = draw.Font()) :: Pict

Creates a pict that draws text using font

> text("Hello")

image

> text("Hi!", ~font: draw.Font(~kind: #'roman, ~size: 20, ~style: #'italic))

image

function

fun bitmap(path :: Path || String) :: Pict

Creates a pict that draws a bitmap as loaded from path.

function

fun dc(draw :: Function.of_arity(3),

       ~width: width :: Real,

       ~height: height :: Real,

       ~ascent: ascent :: Real = height,

       ~descent: descent :: Real = 0) :: Pict

Creates a pict with an arbitrary drawing context. The draw function receives a s draw.DC, an x-offset, and a y-offset.

> dc(fun (dc :: draw.DC, dx, dy):

       dc.line([dx, dy+10], [dx+20, dy+10])

       dc.line([dx+10, dy], [dx+10, dy+20])

       dc.ellipse([[dx, dy], [21, 21]]),

     ~width: 20,

     ~height: 20)

image

function

fun animate(

  proc :: Function.of_arity(1),

  ~extent: extent :: NonnegReal = 0.5,

  ~bend: bend = bend.fast_middle,

  ~sustain_edge: sustain_edge :: TimeOrder = #'before

) :: Pict

Creates an animated pict. The proc should accept a Real.in() and produce a StaticPict.

function

fun Pict.from_handle(handle) :: Pict

Converts a static pict value compatible with the Racket pict library into a Pict value.

enumeration

enum ColorMode:

  ~is_a Color

  ~is_a String

  inherit

A color specification, where #'inherit allows the color to be configured externally, such as through Pict.colorize.

enumeration

enum LineWidth:

  ~is_a Real

  inherit

A line-width specification, where #'inherit allows the color to be configured externally, such as through Pict.line_width.

enumeration

enum Refocus:

  ~is_a Pict

  around

Refocusing options for functions like rectangle.

enumeration

enum Rounded:

  ~is_a Real

  default

Corner-rounding options for rectangle.

enumeration

enum ArcDirection:

  cw

  ccw

Arc directions, clockwise or counterclockwise.