bresenham circles
Known issue: circles of radius 9 crash. (Multiples of 9 overflow the trace.)
This commit is contained in:
parent
7148f1222e
commit
606c5681b7
|
@ -67,8 +67,29 @@
|
||||||
(fill_rect screen x y (+ x px) (+ y px) color)
|
(fill_rect screen x y (+ x px) (+ y px) color)
|
||||||
(set x (+ x px))
|
(set x (+ x px))
|
||||||
(set x (+ x px)))))
|
(set x (+ x px)))))
|
||||||
|
(brcircle . (fn () (screen cx cy r color)
|
||||||
|
((fn (x y err continue)
|
||||||
|
(while continue
|
||||||
|
(pixel screen (- cx x) (+ cy y) color)
|
||||||
|
(pixel screen (- cx y) (- cy x) color)
|
||||||
|
(pixel screen (+ cx x) (- cy y) color)
|
||||||
|
(pixel screen (+ cx y) (+ cy x) color)
|
||||||
|
(set r err)
|
||||||
|
(if (<= r y)
|
||||||
|
(set err (+ err (+ 1 (* 2 (set y (+ y 1))))))
|
||||||
|
())
|
||||||
|
(if (or (> r x) (> err y))
|
||||||
|
(set err (+ err (+ 1 (* 2 (set x (+ x 1))))))
|
||||||
|
())
|
||||||
|
(set continue (< x 0))
|
||||||
|
))
|
||||||
|
(- 0 r)
|
||||||
|
0
|
||||||
|
(- 2 (* 2 r))
|
||||||
|
1
|
||||||
|
)))
|
||||||
(main . (fn () (screen keyboard)
|
(main . (fn () (screen keyboard)
|
||||||
(chessboard screen 16)))
|
(chessboard screen 16)))
|
||||||
))
|
))
|
||||||
(sandbox . (+ 1 2))
|
(sandbox . (brcircle screen 5 5 3 12))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user