dcf037ea2878
Add second loom
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Sun, 04 Feb 2018 00:51:49 -0500 |
parents | 203fa16acf7a |
children | 4c4396e7e5fa |
branches/tags | (none) |
files | src/robots/bit-loom.lisp |
Changes
--- a/src/robots/bit-loom.lisp Sat Feb 03 16:25:31 2018 -0500 +++ b/src/robots/bit-loom.lisp Sun Feb 04 00:51:49 2018 -0500 @@ -13,14 +13,31 @@ (defun loom-1 (seed) (let ((depth (random-range-inclusive 16 19))) (flax.looms.001-triangles:loom seed depth "out.pnm" 3000 3000) - `(depth ,depth))) + (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) + (format nil "~R ticks" ticks))) + +(defparameter *looms* '(loom-1 loom-2)) (defun generate-image (seed) - (prog1 (loom-1 seed) - (pnm-to-png "out.pnm" "out.png"))) + (let* ((loom-index (random (length *looms*))) + (loom (elt *looms* loom-index))) + (pr 'running loom) + (let ((extra (funcall loom seed))) + (pnm-to-png "out.pnm" "out.png") + (values (1+ loom-index) extra)))) (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"))) + (let ((seed (random (expt 2 32)))) + (multiple-value-bind (loom-number extra-information) + (generate-image seed) + (values (string-upcase + (format nil "loom ~R, seed ~D~A" + loom-number seed + (if extra-information + (concatenate 'string ", " extra-information) + ""))) + "out.png"))))