src/robots/bit-loom.lisp @ 203fa16acf7a

Fuck off pnmtopng
author Steve Losh <steve@stevelosh.com>
date Sat, 03 Feb 2018 16:25:31 -0500
parents 26d560b85b8a
children dcf037ea2878
(in-package :magitek.robots.bit-loom)

(defun pnm-to-png (pnm png)
  (sb-ext:run-program "pnmtopng" (list pnm)
                      :search t
                      :output png
                      :error nil
                      :if-output-exists :supersede)
  (sb-ext:run-program "mogrify" (list "-resize" "800x800" png)
                      :error :output
                      :search t))

(defun loom-1 (seed)
  (let ((depth (random-range-inclusive 16 19)))
    (flax.looms.001-triangles:loom seed depth "out.pnm" 3000 3000)
    `(depth ,depth)))

(defun generate-image (seed)
  (prog1 (loom-1 seed)
    (pnm-to-png "out.pnm" "out.png")))

(defun random-tweet ()
  (let* ((seed (random (expt 2 32)))
         (parameters (append `(seed ,seed) (generate-image seed))))
    (values (string-upcase (format nil "Loom ~R, ~{~A ~A~^, ~}" 1 parameters))
            "out.png")))