Functional PostScript Examples

Functional PostScript Examples


Headlines

Headlines paints a row of messages in fading color and brightness. It demonstrate how to create fonts and glyphpaths, how to vary the style/attribute for drawing in colors, how to use colormap to create pictures, and how to create and change colors (rgb, hsb, hsb:h, hsb:b, etc).

The procedure takes one argument, num, which indicates how many times the headline gets printed. [PostScript Output]

(define (headlines num)
  (let* ((times (font "Times-BoldItalic" 36))
	 (helv  (font "Helvetica" 36))
	 (headline-path (join (string->glyphpath times  "Turnip")
			      (string->glyphpath helv  " Born Talking")))
	 (headline (paint-glyphpath headline-path (:color (rgb 1 0 0))))
	 (vertical-step 45))

    (translate 100 200
	       (let recur ((n num))
		 (if (<= n 1) headline
		     (let ((next-headline (recur (- n 1))))
		       (compose 			      
			headline
			(translate 0 vertical-step
				   (colormap (lambda (c) 
					       (hsb (hsb:h c)
						    (- (hsb:s c) 0.1)
						    (- (hsb:b c) .05)))
					     (recur (- n 1)))))))))))


FPS Home | Prev Example | Next Example

FPS Examples: Right-angle Fractal | Arrow Fractal | Headlines | Clipping Message | Turkey Bitmap | Sun | Bounding Box | Morphing Square to Circle | Text Along a Circle | Demo Driver