# 円周率を画像に..

そこで、とりあえず円周率を画像にするという事をしてみたくなりました（突発的に）
そこで、簡易なスクリプトを書いてみて先頭から361桁までを画像にしてみました。

```(setf *pi-str*
"3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367797521401")

(setf *pi-binary-str* (to-binary *pi-str*))

(defun remove-space (str)
(coerce (remove-if (lambda (x) (char= #\Space x))
(coerce str 'list)) 'string))

(defun square-nump (num)
(= num (expt (floor (sqrt num)) 2)))

(defun find-max-square-num (max-num)
(loop for n from max-num downto 4
when (square-nump n)
return n))

(defun to-binary (num)
(format nil "~{~A~}"
(loop for keta in (map 'list (lambda (x) (- (char-code x) (char-code #\0))) (format nil "~D" num))
collect (format nil "~2,4,'0,R" keta))))

(defun split-str (str length)
(labels
((%split-str (str length acc)
(if (<= (length str) length)
(nreverse (cons str acc))
(%split-str (subseq str length)
length
(cons (subseq str 0 length) acc)))))
(%split-str str length nil)))

(defun draw-pi-image (file)
(let* ((png (make-instance 'zpng:png
:color-type :grayscale-alpha
:width 38
:height 38))
(image (zpng:data-array png))
(max 255))
(dotimes (y 38 (zpng:write-png png file))
(dotimes (x 38)
(setf (aref image y x 1) (* 255 (- (char-code (aref *pi-binary-str* (+ x (* y 38)))) (char-code #\0))))))))
```

....冷静に考えれば10000桁とかでやれば良いんですけどね...