On this page:
get-cap
get-color
get-join
get-stipple
get-style
get-width
set-cap
set-color
set-join
set-stipple
set-style
set-width

pen% : class?

  superclass: object%

A pen is a drawing tool with a color, width, and style. A pen draws lines and outlines, such as the outline of a rectangle. In a monochrome destination, all non-white pens are drawn as black.

In addition to its color, width, and style, a pen can have a stipple bitmap. Painting with a stipple pen is similar to calling draw-bitmap with the stipple bitmap in region painted by the pen.

A pen’s style is one of the following:

To avoid creating multiple pens with the same characteristics, use the global pen-list% object the-pen-list, or provide a color, width, and style to set-pen in dc<%>.

A pen of size 0 uses the minimum line size for the destination drawing context. In (unscaled) canvases and bitmaps, a zero-width pen behaves the nearly same as a pen of size 1.

(new pen% [[color color]    
  [width width]    
  [style style]    
  [cap cap]    
  [join join]    
  [stipple stipple]])  (is-a?/c pen%)
  color : (or/c string? (is-a?/c color%)) = "black"
  width : (real-in 0 255) = 0
  style : 
(one-of/c 'transparent 'solid 'xor 'hilite
          'dot 'long-dash 'short-dash 'dot-dash
          'xor-dot 'xor-long-dash 'xor-short-dash
          'xor-dot-dash)
   = 'solid
  cap : (one-of/c 'round 'projecting 'butt) = 'round
  join : (one-of/c 'round 'bevel 'miter) = 'round
  stipple : (or/c #f (is-a?/c bitmap%)) = #f
Creates a pen with the given color, width, style, cap style, join style, and stipple. For the case that the color is specified using a name, see color-database<%> for information about color names; if the name is not known, the pen’s color is black.

(send a-pen get-cap)  (one-of/c 'round 'projecting 'butt)
Returns the pen cap style. The default is 'round.

(send a-pen get-color)  (is-a?/c color%)
Returns the pen’s color object.

(send a-pen get-join)  (one-of/c 'round 'bevel 'miter)
Returns the pen join style. The default is 'round.

(send a-pen get-stipple)  (or/c (is-a?/c bitmap%) #f)
Gets the current stipple bitmap, or returns #f if no stipple bitmap is installed.

(send a-pen get-style)
  
(one-of/c 'transparent 'solid 'xor 'hilite
          'dot 'long-dash 'short-dash 'dot-dash
          'xor-dot 'xor-long-dash 'xor-short-dash
          'xor-dot-dash)
Returns the pen style. See pen% for information about possible styles.

(send a-pen get-width)  (real-in 0 255)
Returns the pen width.

(send a-pen set-cap cap-style)  void?
  cap-style : (one-of/c 'round 'projecting 'butt)
Sets the pen cap style. See get-cap for information about cap styles.

A pen cannot be modified if it was obtained from a pen-list% or while it is selected into a drawing context.

(send a-pen set-color color)  void?
  color : (is-a?/c color%)
(send a-pen set-color color-name)  void?
  color-name : string?
(send a-pen set-color red green blue)  void?
  red : (integer-in 0 255)
  green : (integer-in 0 255)
  blue : (integer-in 0 255)
Sets the pen color.

A pen cannot be modified if it was obtained from a pen-list% or while it is selected into a drawing context.

(send a-pen set-join join-style)  void?
  join-style : (one-of/c 'round 'bevel 'miter)
Sets the pen join style. See get-join for information about join styles.

A pen cannot be modified if it was obtained from a pen-list% or while it is selected into a drawing context.

(send a-pen set-stipple bitmap)  void?
  bitmap : (or/c (is-a?/c bitmap%) #f)
Sets the pen stipple bitmap, where #f turns off the stipple bitmap.

If bitmap is modified while is associated with a pen, the effect on the pen is unspecified. A pen cannot be modified if it was obtained from a pen-list% or while it is selected into a drawing context.

(send a-pen set-style style)  void?
  style : 
(one-of/c 'transparent 'solid 'xor 'hilite
          'dot 'long-dash 'short-dash 'dot-dash
          'xor-dot 'xor-long-dash 'xor-short-dash
          'xor-dot-dash)
Sets the pen style. See pen% for information about the possible styles.

A pen cannot be modified if it was obtained from a pen-list% or while it is selected into a drawing context.

(send a-pen set-width width)  void?
  width : (real-in 0 255)
Sets the pen width.

A pen cannot be modified if it was obtained from a pen-list% or while it is selected into a drawing context.