This Java applet models the operation of a pen retractor. This mechanism has the somewhat remarkable property that depressing the button once extends the pen, whereas depressing it again retracts the pen.
The horizontal width represents 360° of the pen's cylindrical angle (as if it were rolled flat), and the vertical height represents a short length of the pen just below the button end. The structure is symmetrical about the pen's centerline, such that it repeats every 180° and wraps from the right edge back to the left edge.
The yellow layer represents the drive cam that is attached to the pen's button. The cyan layer represents the stationary cam that is attached to the pen's body. The drive cam and the stationary cam are concentric, and the area in which they overlap is shown in green. The drive cam interlocks the pen body such that it can slide up and down, but cannot rotate.
The red area represents the lifter, which can overlap neither the drive cam nor the stationary cam because it extends from the pen's centerline to the inside of its body. The lifter is spring loaded, such that it always engages one or both of the cams. On its other side, the lifter engages the ink cartridge (not shown), such that the height of the lifter (represented by the black dot) corresponds directly to the degree of extension.
Because the mechanism has memory, its operation must include irreversible motion; that is, motion in which mechanical energy is lost. Some of this energy is dissipated in the form of the characteristic "click" sound that occurs when the lifter experiences sudden jumps.