Functional PostScript Examples
Clip-msg prints a string of message and fills it with rays. It demonstrates how to use clip to create pictures. First the ray picture is drawn, then we create the msg glyphpath, and clip the ray picture with the path.
The procedure take one argument, msg, which is a simple string that will be printed. [PostScript Output]
(define (clip-msg msg) (let* ((times (font "Times-BoldItalic" 84)) (m-path (simple-string->glyphpath times msg)) (max-pt (bounding-box:max (bounding-box m-path))) (height (pt:y max-pt)) (width (pt:x max-pt)) (l-len (sqrt (+ (* (/ width 2) (/ width 2)) (* height height)))) (l (line (pt 0 0) (pt (+ 150 width) 0))) (angle-step .025) (rays (translate (/ width 2) 0 (apply compose (let recur ((angle 0)) (if (> angle pi) '() (cons (rotate angle l) (recur (+ angle angle-step))))))))) (translate 100 400 (clip m-path (stroke rays (:color (hsb 0.4 0.1 0.4)))))))
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