Bitmap/Midpoint circle algorithm: Difference between revisions
Content added Content deleted
(CL code) |
m (use <lang>) |
||
Line 206: | Line 206: | ||
Based upon the OCaml version. |
Based upon the OCaml version. |
||
< |
<lang lisp>(defun draw-circle (draw-function x0 y0 radius) |
||
(labels ((foo (x y) |
(labels ((foo (x y) |
||
(funcall draw-function x y)) |
(funcall draw-function x y)) |
||
Line 234: | Line 234: | ||
(+ m 4 (* 8 x)))))))) |
(+ m 4 (* 8 x)))))))) |
||
(put 0 radius (- 5 (* 4 radius))) |
(put 0 radius (- 5 (* 4 radius))) |
||
(values)))</ |
(values)))</lang> |
||
< |
<lang lisp>CL-USER> (let ((buffer (make-array '(30 30) |
||
:element-type 'bit))) |
:element-type 'bit))) |
||
(draw-circle (lambda (x y) |
(draw-circle (lambda (x y) |
||
(setf (bit buffer x y) 1)) 15 15 10) |
(setf (bit buffer x y) 1)) 15 15 10) |
||
buffer) |
buffer)</lang> |
||
;; edited for your convenience |
<pre>;; edited for your convenience |
||
(( ) |
(( ) |
||
( 1 1 1 1 1 1 1 ) |
( 1 1 1 1 1 1 1 ) |