This commit is contained in:
Kartik K. Agaram 2021-05-07 12:11:59 -07:00
parent e42ae8219e
commit dd192dd52c

View File

@ -6,22 +6,18 @@
`(if ,cond ,body ()))])
(let . [(mac let (var val . body)
`((fn (,var) ,@body) ,val))])
(hline . [(def hline (fn (screen y color)
(hline1 screen y 0 (width screen) color)))])
(hline1 . [(def hline1 (fn (screen y x xmax color)
(while (< x xmax)
(pixel screen x y color)
(set x (+ x 1)))))])
(vline . [(def vline (fn (screen x color)
(vline1 screen x 0 (height screen) color)))])
(vline1 . [(def vline1 (fn (screen x y ymax color)
(while (< y ymax)
(pixel screen x y color)
(set y (+ y 1)))))])
(fill_rect . [(def fill_rect (fn (screen x1 y1 x2 y2 color)
(while (< y1 y2)
(hline1 screen y1 x1 x2 color)
(set y1 (+ y1 1)))))])
(hline . [(def hline (fn (screen y color)
(hline1 screen y 0 (width screen) color)))])
(vline . [(def vline (fn (screen x color)
(vline1 screen x 0 (height screen) color)))])
(brline . [(def brline (fn (screen x0 y0 x1 y1 color)
(let (x y) `(,x0 ,y0)
(let dx (abs (- x1 x0))
@ -52,6 +48,16 @@
(write str c)
(set c (key keyboard))))
str)))])
(fill_rect . [(def fill_rect (fn (screen x1 y1 x2 y2 color)
(while (< y1 y2)
(hline1 screen y1 x1 x2 color)
(set y1 (+ y1 1)))))])
(chessboard_row . [(def chessboard_row (fn (screen px y x xmax)
(while (< x xmax)
(fill_rect screen
x y
(+ x px) (+ y px) 15)
(set x (+ x (* px 2))))))])
(chessboard . [(def chessboard (fn (screen px)
(clear screen)
(let xmax (width screen)
@ -62,12 +68,6 @@
(set y (+ y px))
(chessboard_row screen px y px xmax)
(set y (+ y px)))))])
(chessboard_row . [(def chessboard_row (fn (screen px y x xmax)
(while (< x xmax)
(fill_rect screen
x y
(+ x px) (+ y px) 15)
(set x (+ x (* px 2))))))])
(brcircle . [(def brcircle (fn (screen cx cy r clr)
(let x (- 0 r)
(let y 0