On this page:
3.1 Pict Colors
color
3.2 Pict Manipulation
fill
scale-to
3.2.1 Conditional Manipulations
strike
shade
3.2.2 Conditional Combinations
pict-combine
with-pict-combine
pict-match
3.3 Shapes with Borders
ellipse/  border
circle/  border
rectangle/  border
rounded-rectangle/  border
3.4 Lines with Labels
pin-label-line
pin-arrow-label-line
pin-arrows-label-line
3.5 Blur
blur-bitmap!
3.6 Shadow Frames
arch
3.7 Drawing
draw-pict-centered
3.8 Additional combinators
backdrop
cross-out
3.9 PLT Logos
make-plt-title-background
7.1

3 Pict Utilities

NOTE: This library is deprecated; use pict, instead. The contents of this module, with the exceptions below, have been merged with the pict collection, or its subcollections.

 (require unstable/gui/pict) package: unstable-lib

The functions and macros exported by this module are also exported by unstable/gui/slideshow.

3.1 Pict Colors

procedure

(color c p)  pict?

  c : color/c
  p : pict?
Applies color c to picture p. Equivalent to (colorize p c).

Example:
> (color "red" (disk 20))

image

3.2 Pict Manipulation

procedure

(fill pict width height)  pict?

  pict : pict?
  width : (or/c real? #f)
  height : (or/c real? #f)
Extends pict’s bounding box to a minimum width and/or height, placing the original picture in the middle of the space.

Example:
> (frame (fill (disk 20) 40 40))

image

procedure

(scale-to pict width height [#:mode mode])  pict?

  pict : pict?
  width : real?
  height : real?
  mode : (or/c 'preserve 'inset 'distort) = 'preserve
Scales pict so that its width and height are at most width and height, respectively. If mode is 'preserve, the width and height are scaled by the same factor so pict’s aspect ratio is preserved; the result’s bounding box may be smaller than width by height. If mode is 'inset, the aspect ratio is preserved as with 'preserve, but the resulting pict is centered in a bounding box of exactly width by height. If mode is 'distort, the width and height are scaled separately.

Examples:
> (frame (scale-to (circle 100) 40 20))

image

> (frame (scale-to (circle 100) 40 20 #:mode 'inset))

image

> (frame (scale-to (circle 100) 40 20 #:mode 'distort))

image

3.2.1 Conditional Manipulations

These pict transformers all take boolean arguments that determine whether to transform the pict or leave it unchanged. These transformations can be useful for staged slides, as the resulting pict always has the same size and shape, and its contents always appear at the same position, but changing the boolean argument between slides can control when the transformation occurs.

procedure

(strike pict [strike?])  pict?

  pict : pict?
  strike? : truth/c = #t
Displays a strikethrough image by putting a line through the middle of pict if strike? is true; produces pict unchanged otherwise.

Example:
> (strike (colorize (disk 20) "yellow"))

image

procedure

(shade pict [shade? #:ratio ratio])  pict?

  pict : pict?
  shade? : truth/c = #t
  ratio : (real-in 0 1) = 1/2
Shades pict to show with ratio of its normal opacity; if ratio is 1 or shade? is #f, shows pict unchanged.

Example:
> (shade (colorize (disk 20) "red"))

image

3.2.2 Conditional Combinations

These bindings provide additional control over the combinations in pict/conditional.

This syntax parameter determines the default pict combining form used by the combinaitons in pict/conditional. It defaults to lbl-superimpose.

syntax

(with-pict-combine combine-id body ...)

Sets pict-combine to refer to combine-id within each of the body terms, which are spliced into the containing context.

Example:
> (let ([f (lambda (x)
             (with-pict-combine cc-superimpose
               (pict-case x
                 [(circle) (circle 20)]
                 [(disk) (disk 40)]
                 [(text) (text "ok" null 20)])))])
    (hc-append 10
               (frame (f 'circle))
               (frame (f 'disk))
               (frame (f 'text))))

image

syntax

(pict-match test-expr maybe-combine [pattern pict-expr] ...)

 
maybe-combine = 
  | #:combine combine-expr
Chooses a pict-expr based on test-expr and each pattern, similarly to match. Combines the chosen, visible image with the other, invisible images using combine-expr, defaulting to lbl-superimpose.

3.3 Shapes with Borders

The subsequent bindings were added by Vincent St-Amour.

procedure

(ellipse/border w    
  h    
  [#:color color    
  #:border-color border-color    
  #:border-width border-width])  pict?
  w : real?
  h : real?
  color : color/c = "white"
  border-color : color/c = "black"
  border-width : real? = 2

procedure

(circle/border diameter    
  [#:color color    
  #:border-color border-color    
  #:border-width border-width])  pict?
  diameter : real?
  color : color/c = "white"
  border-color : color/c = "black"
  border-width : real? = 2

procedure

(rectangle/border w    
  h    
  [#:color color    
  #:border-color border-color    
  #:border-width border-width])  pict?
  w : real?
  h : real?
  color : color/c = "white"
  border-color : color/c = "black"
  border-width : real? = 2

procedure

(rounded-rectangle/border w 
  h 
  [#:color color 
  #:border-color border-color 
  #:border-width border-width 
  #:corner-radius corner-radius 
  #:angle angle]) 
  pict?
  w : real?
  h : real?
  color : color/c = "white"
  border-color : color/c = "black"
  border-width : real? = 2
  corner-radius : real? = -0.25
  angle : real? = 0
These functions create shapes with border of the given color and width.

Examples:
> (ellipse/border 80 40 #:border-color "blue")

image

> (rounded-rectangle/border 60 60 #:color "red" #:angle 1 #:border-width 3)

image

> (circle/border 40 #:color "green" #:border-color "purple")

image

> (rectangle/border 200 20 #:border-width 5)

image

3.4 Lines with Labels

The subsequent bindings were added by Scott Owens.

procedure

(pin-label-line label    
  pict    
  src-pict    
  src-coord-fn    
  dest-pict    
  dest-coord-fn    
  [#:start-angle start-angle    
  #:end-angle end-angle    
  #:start-pull start-pull    
  #:end-pull end-pull    
  #:line-width line-width    
  #:color color    
  #:alpha alpha    
  #:style style    
  #:under? under?    
  #:x-adjust x-adjust    
  #:y-adjust y-adjust])  pict?
  label : pict?
  pict : pict?
  src-pict : pict-path?
  src-coord-fn : (-> pict-path? (values real? real?))
  dest-pict : pict-path?
  dest-coord-fn : (-> pict-path? (values real? real?))
  start-angle : (or/c real? #f) = #f
  end-angle : (or/c real? #f) = #f
  start-pull : real? = 1/4
  end-pull : real? = 1/4
  line-width : (or/c real? #f) = #f
  color : (or/c #f string? (is-a?/c color%)) = #f
  alpha : (real-in 0 1) = 1
  style : pen-style/c = 'solid
  under? : any/c = #f
  x-adjust : real? = 0
  y-adjust : real? = 0

procedure

(pin-arrow-label-line label 
  arrow-size 
  pict 
  src-pict 
  src-coord-fn 
  dest-pict 
  dest-coord-fn 
  [#:start-angle start-angle 
  #:end-angle end-angle 
  #:start-pull start-pull 
  #:end-pull end-pull 
  #:line-width line-width 
  #:color color 
  #:alpha alpha 
  #:style style 
  #:solid? solid? 
  #:under? under? 
  #:hide-arrowhead? hide-arrowhead? 
  #:x-adjust x-adjust 
  #:y-adjust y-adjust]) 
  pict?
  label : pict?
  arrow-size : real?
  pict : pict?
  src-pict : pict-path?
  src-coord-fn : (-> pict-path? (values real? real?))
  dest-pict : pict-path?
  dest-coord-fn : (-> pict-path? (values real? real?))
  start-angle : (or/c real? #f) = #f
  end-angle : (or/c real? #f) = #f
  start-pull : real? = 1/4
  end-pull : real? = 1/4
  line-width : (or/c real? #f) = #f
  color : (or/c #f string? (is-a?/c color%)) = #f
  alpha : (real-in 0 1) = 1
  style : pen-style/c = 'solid
  solid? : boolean? = #t
  under? : any/c = #f
  hide-arrowhead? : any/c = #f
  x-adjust : real? = 0
  y-adjust : real? = 0

procedure

(pin-arrows-label-line label 
  arrow-size 
  pict 
  src-pict 
  src-coord-fn 
  dest-pict 
  dest-coord-fn 
  [#:start-angle start-angle 
  #:end-angle end-angle 
  #:start-pull start-pull 
  #:end-pull end-pull 
  #:line-width line-width 
  #:color color 
  #:alpha alpha 
  #:style style 
  #:solid? solid? 
  #:under? under? 
  #:hide-arrowhead? hide-arrowhead? 
  #:x-adjust x-adjust 
  #:y-adjust y-adjust]) 
  pict?
  label : pict?
  arrow-size : real?
  pict : pict?
  src-pict : pict-path?
  src-coord-fn : (-> pict-path? (values real? real?))
  dest-pict : pict-path?
  dest-coord-fn : (-> pict-path? (values real? real?))
  start-angle : (or/c real? #f) = #f
  end-angle : (or/c real? #f) = #f
  start-pull : real? = 1/4
  end-pull : real? = 1/4
  line-width : (or/c real? #f) = #f
  color : (or/c #f string? (is-a?/c color%)) = #f
  alpha : (real-in 0 1) = 1
  style : pen-style/c = 'solid
  solid? : boolean? = #t
  under? : any/c = #f
  hide-arrowhead? : any/c = #f
  x-adjust : real? = 0
  y-adjust : real? = 0
These functions behave like pin-line, pin-arrow-line and pin-arrows-line with the addition of a label attached to the line.

Example:
> (let* ([a (red (disk 20))]
         [b (blue (filled-rectangle 20 20))]
         [p (vl-append a (hb-append (blank 100) b))])
    (pin-arrow-label-line
     (rotate (text "label" null 10) (/ pi -4))
     10 p
     a rb-find
     b lt-find))

image

3.5 Blur

The subsequent bindings were added by Ryan Culpepper.

procedure

(blur-bitmap! bitmap h-radius [v-radius])  void?

  bitmap : (is-a?/c bitmap%)
  h-radius : (and/c real? (not/c negative?))
  v-radius : (and/c real? (not/c negative?)) = h-radius
Blurs bitmap using blur radii h-radius and v-radius.

3.6 Shadow Frames

procedure

(arch outer-width    
  inner-width    
  solid-height    
  leg-height)  pict?
  outer-width : real?
  inner-width : real?
  solid-height : real?
  leg-height : real?
Creates an arch.

Example:
> (colorize (arch 100 80 20 20) "red")

image

3.7 Drawing

The subsequent bindings were added by Jay McCarthy.

procedure

(draw-pict-centered p dc w h)  void?

  p : pict?
  dc : (is-a?/c dc<%>)
  w : real?
  h : real?
Draws the pict p on dc centered in a wxh rectangle.

3.8 Additional combinators

The subsequent bindings were added by Asumu Takikawa.

procedure

(backdrop pict [#:color color])  pict?

  pict : pict?
  color : color/c = "white"
Adds a background highlighted with color to pict.

Examples:
> (backdrop (circle 20) #:color "whitesmoke")

image

> (backdrop (text "broccoli rabé") #:color "PaleGreen")

image

procedure

(cross-out pict    
  [#:width width    
  #:style style    
  #:color color])  pict?
  pict : pict?
  width : real? = 1
  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)
 = 'solid
  color : color/c = "black"
Crosses out pict with two diagonal lines drawn with the given line width and with the line style. The lines are colored with color.

Examples:
> (cross-out (circle 20))

image

> (cross-out (rectangle 30 20) #:width 2 #:style 'long-dash)

image

> (cross-out (text "rapini") #:width 3 #:color "red")

image

3.9 PLT Logos

 (require unstable/gui/pict/plt-logo)
  package: unstable-lib

The subsequent bindings were added by Jay McCarthy.

procedure

(make-plt-title-background w h)  pict?

  w : real?
  h : real?
Draws the PLT logo inside a wxh rectangle.