soegaard2
2019-8-25 19:45:51
#lang racket
(require "../metapict.rkt" "../text-path.rkt")


;;; Configuration

(def logo-text "RACKET")
(def font       (make-similar-font (new-font)
                                   #:size   180
                                   #:face   "Arial"
                                   #:weight 'bold))


; 1. Logo text drawn in chosen font
(with-font font
  (draw (text logo-text)))

; 2. Use the sizes to set pict size and user coordinates

(defv (width height) (let ([p (with-font font (text logo-text))])
                       (values (pict-width p) (pict-height p))))

(set-curve-pict-size width height)
(curve-pict-window (window 0 (+ width 2) 0 (+ height 2)))


; 3. Outline
;   The outline consists of a list of curves
(def outline (map (shifted 1 height)
                  (text-outline font logo-text)))

(draw outline)

; 4. choose a gradient
(def blue       (color-med 0. "blue" "white"))
(def black      "black")
(def light-blue (color-med 0.6 "blue" "white"))
(def  dark-blue (color-med 0.2 "blue" "white"))

(def red-blue-gradient
  (linear-gradient (pt 0 0) (pt width height) (list "red" "blue")))
(def fancy-gradient
  (linear-gradient (pt 0 0) (pt 0 height) ; vertical
                   (list blue blue black light-blue  dark-blue blue)
                   #:stops
                   (list 0.0  0.25  0.5   0.5        0.75      1.0)
                   #:height-factor 1.3))

; 5. Fill the outline with a gradient
(brushgradient red-blue-gradient
               (draw (apply fill outline)
                     (penwidth 3 (draw outline))))


(brushgradient fancy-gradient
               (draw (apply fill outline)
                     (penwidth 3 (draw outline))))