laurent.orseau
2019-8-27 07:17:58

works well now, thanks!


laurent.orseau
2019-8-27 07:18:11

Revised version for those who wants to try it:


laurent.orseau
2019-8-27 07:18:20
#lang racket
(require metapict
         metapict/text-path)


;;; 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
(freeze (brushgradient red-blue-gradient
               (draw (apply fill outline)
                     (penwidth 3 (draw outline)))))


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

laurent.orseau
2019-8-27 07:18:40

(added freeze at the end, and used module-style requires)


soegaard2
2019-8-27 11:17:12

Btw - I tried to mimick the example in this blog: https://hokstad.com/draw-a-logo-with-gradients-with-ruby-and-cairo


soegaard2
2019-8-27 11:17:30

soegaard2
2019-8-27 12:28:31

Koch curve using plain Metapict: http://rosettacode.org/wiki/Koch_curve#Racket


soegaard2
2019-8-27 12:29:44

Peano curve where MetaPict is used to implement a turtle and then draw the curve: https://rosettacode.org/wiki/Peano_curve#Racket


soegaard2
2019-8-27 12:30:20

Anyone up for the task of drawing a Hilbert curve? https://rosettacode.org/wiki/Hilbert_curve


laurent.orseau
2019-8-27 16:41:13

we need a wave distortion!


soegaard2
2019-8-27 17:26:40

Like a good old c64 scroller?