4c4396e7e5fa

Flax writes PNGs directly now
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 05 Feb 2018 23:57:49 -0500
parents dcf037ea2878
children bb087180b17f
branches/tags (none)
files src/robots/bit-loom.lisp

Changes

--- a/src/robots/bit-loom.lisp	Sun Feb 04 00:51:49 2018 -0500
+++ b/src/robots/bit-loom.lisp	Mon Feb 05 23:57:49 2018 -0500
@@ -1,23 +1,19 @@
 (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)
+(defun resize (filename size)
+  (sb-ext:run-program "mogrify"
+                      (list "-resize" (format nil "~Dx~D" size size) filename)
                       :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)
+    (flax.looms.001-triangles:loom seed depth "out.png" 3000 3000)
     (format nil "depth ~D" depth)))
 
 (defun loom-2 (seed)
   (let ((ticks (* 1000 (random-range-inclusive 3 8))))
-    (flax.looms.002-wobbly-lines:loom seed ticks "out.pnm" 2000 400)
+    (flax.looms.002-wobbly-lines:loom seed ticks "out.png" 2000 400)
     (format nil "~R ticks" ticks)))
 
 (defparameter *looms* '(loom-1 loom-2))
@@ -27,7 +23,7 @@
          (loom (elt *looms* loom-index)))
     (pr 'running loom)
     (let ((extra (funcall loom seed)))
-      (pnm-to-png "out.pnm" "out.png")
+      (resize "out.png" 800)
       (values (1+ loom-index) extra))))
 
 (defun random-tweet ()