Created
October 10, 2013 12:12
-
-
Save tshatrov/6917347 to your computer and use it in GitHub Desktop.
number printing for Skippy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun gif-write-integer (n image index x y) | |
(let ((digits #(#*111101101101111 | |
#*001011101001001 | |
#*111001111100111 | |
#*111001111001111 | |
#*101101111001001 | |
#*111100111001111 | |
#*111100111101111 | |
#*111001010010100 | |
#*111101111101111 | |
#*111101111001111))) | |
(flet ((write-digit (n x y) | |
(loop for b across (elt digits n) | |
for i from 0 | |
if (= b 1) do (setf (pixel-ref image (+ x (mod i 3)) (+ y (floor i 3))) index)))) | |
(cond | |
((< n 0) (error "Number must be positive")) | |
((= n 0) (write-digit 0 x y)) | |
(t (loop with nstr = (princ-to-string n) | |
and curx = x | |
for digit in (map 'list #'digit-char-p nstr) | |
do (write-digit digit curx y) (incf curx 4))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment