HOME | DD

burtonsamograd — X-F

Published: 2015-02-13 04:45:47 +0000 UTC; Views: 454; Favourites: 0; Downloads: 0
Redirect to original
Description (eval-when (:compile-toplevel :load-toplevel)
  (require 'vecto))
(in-package :vecto)

(defun j (x n)
  (+ (- x n) (random (* 2 n))))

(defun render (file)
  (let* ((w (/ 10800 1)) (h (/ 7800 1)) (s (coerce (/ w 64) 'float)) (n 2))
    (with-canvas (:width w :height h)
      (set-rgba-fill 0 0 0 1)
      (rectangle 0 0 w h)
      (fill-path)
      (set-line-cap :round)
      
      (dotimes (i 10)
        (flet ((r (x)
                 (+ (- x) (* 3 (random x))))
               (j (x n)
                 (+ (- x) (* 3 (random n)))))
          (let* ((ps (let (ps) (dotimes (i 47 ps)
                                 (push (cons (r w) (r h)) ps))))
                 (p (car ps))
                 (s (+ (/ s 8) (expt 2 i))))

            (set-line-width (* s (expt 1.03 i)))
            (set-rgba-stroke 0 0 0 .1)
            (move-to (car p) (cdr p))
            (mapc (lambda (p)
                    (let ((x (car p))
                          (y (cdr p)))
                      (line-to x y))) (cdr ps))
            (stroke)

            (set-line-width (* s (expt 1.014 i)))
            (set-rgba-stroke 0 0 0 1)
            (move-to (car p) (cdr p))
            (mapc (lambda (p)
                    (let ((x (car p))
                          (y (cdr p)))
                      (line-to x y))) (cdr ps))
            (stroke)

          (set-line-width s)
          (set-rgba-stroke 1 1 1 1)
          (move-to (car p) (cdr p))
          (mapc (lambda (p)
                  (let ((x (car p))
                        (y (cdr p)))
                    (line-to x y))) (cdr ps))
          (stroke)

          (set-line-width (/ s 16))
          (set-rgba-stroke 0 0 0 (random 1.0))
          (move-to (+ (car p) (/ s 16)) (+ (cdr p) (/ s 16)))
          (mapc (lambda (p)
                  (let ((x (+ (car p) (/ s 16)))
                        (y (+ (cdr p) (/ s 16))))
                    (line-to x y))) (cdr ps))
          (stroke)

          )))

      ;; signature
      (set-rgba-fill 0 0 0 1)
      (set-font (get-font "~/OCRABold.ttf") (/ w 128))
      (draw-string (- w (/ w 32)) (/ h 32) "X")
      (fill-path)

      (save-png file))))
(render "x-F.png")
Related content
Comments: 0