Skip to content

Instantly share code, notes, and snippets.

@youz
Created April 24, 2012 04:16
Show Gist options
  • Select an option

  • Save youz/2476357 to your computer and use it in GitHub Desktop.

Select an option

Save youz/2476357 to your computer and use it in GitHub Desktop.
;;; http://www.p01.org/releases/#128b_raytraced_checkboard
(defun draw-checkboard (n &optional (s *standard-output*))
(do* ((k 64) (i k))
((= (decf i (/ k)) 0))
(let ((j (/ k i)))
(princ (char "p.\n"
(if (and (integerp i) (evenp i))
2
(logand 1
(logxor (floor j)
(floor (+ (* (mod i 2) j) (- j) (/ n k)))))))
s))))
(defun checkboard ()
(interactive)
(let ((n 0) (buf (get-buffer-create "*check*")))
(labels ((frame ()
(if (eq *this-command* 'quit)
#1=(progn
(stop-timer #'frame)
(delete-buffer buf)
(refresh-screen))
(handler-case
(progn
(set-buffer buf)
(erase-buffer buf)
(with-output-to-buffer (buf)
(draw-checkboard (incf n 7)))
(refresh-screen))
(quit (c) #1#)))))
(start-timer 1/30 #'frame))))
; press C-g to stop
@youz
Copy link
Copy Markdown
Author

youz commented Apr 28, 2012

どうもー 修正しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment