6.3 Pens

In Asymptote, pens provide a context for the four basic drawing commands (see Drawing commands). They are used to specify the following drawing attributes: color, line type, line width, line cap, line join, fill rule, text alignment, font, font size, pattern, overwrite mode, and calligraphic transforms on the pen nib. The default pen used by the drawing routines is called currentpen. This provides the same functionality as the MetaPost command pickup. The implicit initializer for pens is defaultpen.

Pens may be added together with the nonassociative binary operator +. This will add the colors of the two pens. All other non-default attributes of the rightmost pen will override those of the leftmost pen. Thus, one can obtain a yellow dashed pen by saying dashed+red+green or red+green+dashed or red+dashed+green. The binary operator * can be used to scale the color of a pen by a real number, until it saturates with one or more color components equal to 1.

The routine defaultpen() returns the current default pen attributes. Calling the routine resetdefaultpen() resets all pen default attributes to their initial values.