HOME | DD

burtonsamograd — X-10

Published: 2015-02-08 05:27:57 +0000 UTC; Views: 486; Favourites: 0; Downloads: 0
Redirect to original
Description ;; appriximations of pi
(eval-when (:compile-toplevel :load-toplevel)
  (require 'vecto))
(in-package :vecto)


(defun lumiance(r b g)
  (sqrt (+ (* 0.299 (* r r)) (* 0.587 (* g g)) (* 0.114 (* b b)))))

(defun fc (&optional (lum .5) (e .05))
  "find color of a given lumiance with error e"
  (do ((r (random 1.0) (random 1.0))
       (g (random 1.0) (random 1.0))
       (b (random 1.0) (random 1.0)))
      (nil)
    (let ((l (lumiance r g b)))
      (if (and (< lum (+ l e))
               (> lum (- l e)))
          (return-from fc (values r g b))))))

(defun render (file)
  (let* ((w (/ 10800 1)) (h (/ 7200
 1))
         (s (coerce (/ w 8) 'float)))
    (with-canvas (:width w :height h)
      (set-rgba-fill 1 1 1 1)
      (rectangle 0 0 w h)
      (fill-path)

      (dotimes (i 4)
        (do ((x 0 (incf x s)))
            ((> x w))
          (do ((y 0 (incf y s)))
              ((> y h))
            (multiple-value-bind (r g b) (fc .1)
              (set-rgba-fill r g b (/ (random .9) (1+ i)))
            (if (= 0 (random 2))
                (arc x y (1+ (random s)) 0 (* 2 pi))
                (rectangle x y (random s) (random s)))
            (fill-path)
            (set-rgba-stroke 0 0 0 (/ (random 1.0) (1+ i)))
            (set-line-width (1+ (random (/ s 16))))
            (if (= 0 (random 2))
                (arc x y (1+ (random s)) 0 (* 2 pi))
                (rectangle x y (random s) (random s)))
            (stroke)
            ))
        (setf s (/ s 2))
        ))

      ;; 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-10.png")
;; burton samograd 2015
Related content
Comments: 0