On this page:
2.7.1 Dingbats
cloud
file-icon
standard-fish
jack-o-lantern
angel-wing
desktop-machine
thermometer
2.7.2 Balloon Annotations
wrap-balloon
pip-wrap-balloon
pin-balloon
balloon
balloon?
make-balloon
balloon-pict
balloon-point-x
balloon-point-y
balloon-color
balloon-enable-3d
2.7.3 Face
default-face-color
face
face*
2.7.4 Flash
filled-flash
outline-flash

2.7 More Pict Constructors

2.7.1 Dingbats

procedure

(cloud w h [color])  pict?

  w : real?
  h : real?
  color : (or/c string? (is-a?/c color%)) = "gray"
Creates a fluffy cloud.

Examples:

> (cloud 100 75)

image

> (cloud 100 75 "lavenderblush")

image

procedure

(file-icon w h color [shaded?])  pict?

  w : real?
  h : real?
  color : (or/c string? (is-a?/c color%) any/c)
  shaded? : any/c = #f
Creates a Mac-like file icon, optionally shaded. If color is not a string or color% object, it is treated as a boolean, in which case true means "gray" and false means "white".

Examples:

> (file-icon 50 60 "bisque")

image

> (file-icon 50 60 "honeydew" #t)

image

procedure

(standard-fish w    
  h    
  [#:direction direction    
  #:color color    
  #:eye-color eye-color    
  #:open-mouth open-mouth])  pict?
  w : real?
  h : real?
  direction : (or/c 'left 'right) = 'left
  color : (or/c string? (is-a?/c color%)) = "blue"
  eye-color : (or/c string? (is-a?/c color%) #f) = "black"
  open-mouth : (or/c boolean? real?) = #f
Creates a fish swimming either 'left or 'right. If eye-color is #f, no eye is drawn.

The open-mouth argument can be either #f (mouth closed), #t (mouth fully open), or a number: 0.0 is closed, 1.0 is fully open, and numbers in between are partially open.

Examples:

> (standard-fish 100 50)

image

> (standard-fish 100 50 #:direction 'right #:color "chocolate")

image

> (standard-fish 100 50 #:eye-color "saddlebrown" #:color "salmon")

image

> (standard-fish 100 50 #:open-mouth #t #:color "olive")

image

procedure

(jack-o-lantern size    
  [pumpkin-color    
  face-color])  pict?
  size : real?
  pumpkin-color : (or/c string? (is-a?/c color%)) = "orange"
  face-color : (or/c string? (is-a?/c color%)) = "black"
Creates a jack-o-lantern; use the same pumpkin and face color to get a plain pumpkin. The size determines the width.

Examples:

> (jack-o-lantern 100)

image

> (jack-o-lantern 100 "cadet blue" "khaki")

image

procedure

(angel-wing w h left?)  pict?

  w : real?
  h : real?
  left? : any/c
Creates an angel wing, left or right, or any size. The color and pen width for drawing the wing outline is the current one.

Examples:

> (angel-wing 100 40 #f)

image

> (angel-wing 100 40 #t)

image

procedure

(desktop-machine scale [style])  pict?

  scale : real?
  style : (listof symbol?) = null
Produces a picture of ancient desktop computer. The scale argument scales the size relative to the base size of 120 by 115.

The style can include any of the following:

Examples:

> (desktop-machine 1)

image

> (desktop-machine 1 '(devil plt))

image

> (desktop-machine 1 '(plt binary))

image

procedure

(thermometer [#:height-% height-% 
  #:color-% color-% 
  #:ticks ticks 
  #:start-color start-color 
  #:end-color end-color 
  #:top-circle-diameter top-circle-diameter 
  #:bottom-circle-diameter bottom-circle-diameter 
  #:stem-height stem-height 
  #:mercury-inset mercury-inset]) 
  pict?
  height-% : (between/c 0 1) = 1
  color-% : (between/c 0 1) = height-%
  ticks : non-exact-negative-integer? = 4
  start-color : (or/c string? (is-a?/c color%)) = "lightblue"
  end-color : (or/c string? (is-a?/c color%)) = "lightcoral"
  top-circle-diameter : positive-real? = 40
  bottom-circle-diameter : positive-real? = 80
  stem-height : positive-real? = 180
  mercury-inset : positive-real? = 8
Produces a thermometer that consists of a semi-circle on top of a rectangle on top of a circle. The sizes of the three components are controlled via the top-circle-diameter, stem-height, and bottom-circle-diameter arguments.

The mercury is drawn the same way, but by creating the three components inset from the versions that draw the boundary of the thermometer. This inset is conrolled by the mercury-inset argument.

The height of the mercury in the thermometer is controlled by the height-% argument. Its color is interpolated between the start-color and end-color, as determined by the color-% argument.

Finally, some number of ticks are drawn, basd on the ticks argument.

Example:

> (thermometer #:stem-height 90
               #:bottom-circle-diameter 40
               #:top-circle-diameter 20
               #:mercury-inset 4)

image

2.7.2 Balloon Annotations

The slideshow/balloon library provides functions for creating and placing cartoon-speech balloons.

procedure

(wrap-balloon pict    
  spike    
  dx    
  dy    
  [color    
  corner-radius])  balloon?
  pict : pict?
  spike : (or/c 'n 's 'e 'w 'ne 'se 'sw 'nw)
  dx : real?
  dy : real?
  color : (or/c string? (is-a?/c color%)) = balloon-color
  corner-radius : (and/c real? (not/c negative?)) = 32
Superimposes pict on top of a balloon that wraps it.

The spike argument indicates the corner from which a spike protrudes from the balloon (i.e., the spike that points to whatever the balloon is about). For example, 'n means “north,”, which is a spike in the top middle of the balloon.

The dx and dy arguments specify how far the spike should protrude. For a 'w spike, dx should be negative, etc.

The color argument is the background color for the balloon.

The corner-radius argument determines the radius of the cicle used to roun the balloon’s corners. As usual, if it is less than 1, then it acts as a ratio of the balloon’s width or height.

The result is a balloon, not a pict. The balloon-pict function extracts a pict whose bounding box does not include the spike, but includes the rest of the image, and the balloon-point-x and balloon-point-y functions extract the location of the spike point. More typically, the pin-balloon function is used to add a balloon to a pict.

procedure

(pip-wrap-balloon pict    
  spike    
  dx    
  dy    
  [color    
  corner-radius])  pict?
  pict : pict?
  spike : (or/c 'n 's 'e 'w 'ne 'se 'sw 'nw)
  dx : real?
  dy : real?
  color : (or/c string? (is-a?/c color%)) = balloon-color
  corner-radius : (and/c real? (not/c negative?)) = 32
Like wrap-balloon, but produces a zero-sized pict suitable for use with pin-over.

procedure

(pin-balloon balloon base x y)  pict?

  balloon : balloon?
  base : pict?
  x : real?
  y : real?
(pin-balloon balloon base at-pict find)  pict?
  balloon : balloon?
  base : pict?
  at-pict : pict-path?
  find : (pict? pict-path? . -> . (values real? real?))
Superimposes the pict in balloon onto base to produce a new pict. The balloon is positioned so that its spike points to the location specified by either x and y (numbers) or at the position determined by combining base and at-pict with find. The find function uses its arguments like lt-find.

The resulting pict has the same bounding box, descent, and ascent as base, even if the balloon extends beyond the bounding box.

Examples:

> (define a-pict (standard-fish 70 40))
> (pin-balloon (balloon 40 30 5 'se 5 5)
               (cc-superimpose (blank 300 150) a-pict)
               a-pict
               lc-find)

image

> (pin-balloon (wrap-balloon (text "Hello!") 'sw -5 3)
               (cc-superimpose (blank 300 150) a-pict)
               a-pict
               rt-find)

image

procedure

(balloon w h corner-radius spike dx dy [color])  balloon?

  w : real?
  h : real?
  corner-radius : (and/c real? (not/c negative?))
  spike : (or/c 'n 's 'e 'w 'ne 'se 'sw 'nw)
  dx : real?
  dy : real?
  color : (or/c string? (is-a?/c color%)) = balloon-color
Creates a balloon, much like wrap-balloon except that the balloon’s width is w and its height is h.

procedure

(balloon? v)  boolean?

  v : any/c
(make-balloon pict x y)  balloon?
  pict : pict?
  x : real?
  y : real?
(balloon-pict balloon)  pict?
  balloon : balloon?
(balloon-point-x balloon)  real?
  balloon : balloon?
(balloon-point-y balloon)  real?
  balloon : balloon?
A balloon encapsulates a pict and the position of the balloon’s spike relative to the balloon’s top-left corner.

value

balloon-color : (or/c string? (is-a?/c color%))

The default background color for a balloon.

parameter

(balloon-enable-3d)  boolean?

(balloon-enable-3d on?)  void?
  on? : any/c
A parameter that determines whether balloons are drawn with 3-D shading.

2.7.3 Face

The slideshow/face library provides functions for a kind of Mr. Potatohead-style face library.

Orange.

procedure

(face mood [color])  pict?

  mood : symbol?
  color : (or/c string (is-a?/c color%)) = default-face-color
Returns a pict for a pre-configured face with the given base color. The built-in configurations, selected by mood-symbol, are as follows:

'unhappy (face* 'none 'plain #t default-face-color 6)

  

image

'sortof-unhappy (face* 'worried 'grimace #t default-face-color 6)

  

image

'sortof-happy (face* 'worried 'medium #f default-face-color 6)

  

image

'happy (face* 'none 'plain #f default-face-color 6)

  

image

'happier (face* 'none 'large #f default-face-color 3)

  

image

'embarrassed (face* 'worried 'medium #f default-face-color 3)

  

image

'badly-embarrassed (face* 'worried 'medium #t default-face-color 3)

  

image

'unhappier (face* 'normal 'large #t default-face-color 3)

  

image

'happiest (face* 'normal 'huge #f default-face-color 0 -3)

  

image

'unhappiest (face* 'normal 'huge #t default-face-color 0 -3)

  

image

'mad (face* 'angry 'grimace #t default-face-color 0)

  

image

'mean (face* 'angry 'narrow #f default-face-color 0)

  

image

'surprised (face* 'worried 'oh #t default-face-color -4 -3 2)

  

image

procedure

(face* eyebrow-kind    
  mouth-kind    
  frown?    
  color    
  eye-inset    
  eyebrow-dy    
  pupil-dx    
  pupil-dy    
  [#:eyebrow-shading? eyebrow-on?    
  #:mouth-shading? mouth-on?    
  #:eye-shading? eye-on?    
  #:tongue-shading? tongue-on?    
  #:face-background-shading? face-bg-on?    
  #:teeth? teeth-on?])  pict?
  eyebrow-kind : (or/c 'none 'normal 'worried 'angry)
  mouth-kind : 
(or/c 'plain 'smaller 'narrow 'medium 'large
      'huge 'grimace 'oh 'tongue)
  frown? : any/c
  color : (or/c string (is-a?/c color%))
  eye-inset : real?
  eyebrow-dy : real?
  pupil-dx : real?
  pupil-dy : real?
  eyebrow-on? : any/c = #t
  mouth-on? : any/c = #t
  eye-on? : any/c = #t
  tongue-on? : any/c = #t
  face-bg-on? : any/c = #t
  teeth-on? : any/c = #t
Returns a pict for a face:

The #:eyebrow-shading? through #:face-background-shading? arguments control whether a shading is used for on a particular feature in the face (shading tends to look worse than just anti-aliasing when the face is small). The #:teeth? argument controls the visibility of the teeth for some mouth shapes.

2.7.4 Flash

 (require slideshow/flash)

procedure

(filled-flash width    
  height    
  [n-points    
  spike-fraction    
  rotation])  pict?
  width : real?
  height : real?
  n-points : exact-positive-integer? = 10
  spike-fraction : (real-in 0 1) = 0.25
  rotation : real? = 0
Returns a pict for a “flash”: a spiky oval, like the yellow background that goes behind a “new!” logo on web pages or a box of cereal.

The height and width arguments determine the size of the oval in which the flash is drawn, prior to rotation. The actual height and width may be smaller if points is not a multiple of 4, and the actual height and width will be different if the flash is rotated.

The n-points argument determines the number of points on the flash.

The spike-fraction argument determines how big the flash spikes are compared to the bounding oval.

The rotation argument specifies an angle in radians for counter-clockwise rotation.

The flash is drawn in the default color.

Examples:

> (filled-flash 100 50)

image

> (filled-flash 100 50 8 0.25 (/ pi 2))

image

procedure

(outline-flash width    
  height    
  [n-points    
  spike-fraction    
  rotation])  pict?
  width : real?
  height : real?
  n-points : exact-positive-integer? = 10
  spike-fraction : (real-in 0 1) = 0.25
  rotation : real? = 0
Like filled-flash, but drawing only the outline.

Examples:

> (outline-flash 100 50)

image

> (outline-flash 100 50 8 0.25 (/ pi 2))

image