diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-05-07 10:05:20 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-05-07 10:05:20 -0700 |
commit | c651bbeffcd3b840a63ca3ae831e8ba2ec64189b (patch) | |
tree | dc16f492b68cb525346b0b6f6d947bcc1ed570f8 | |
parent | 74be534e2be007f0729092c49a90ca8e410150a8 (diff) | |
download | mu-c651bbeffcd3b840a63ca3ae831e8ba2ec64189b.tar.gz |
clean up hline and vline
-rw-r--r-- | shell/data.limg | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/shell/data.limg b/shell/data.limg index b3750892..c2a7805c 100644 --- a/shell/data.limg +++ b/shell/data.limg @@ -4,18 +4,18 @@ `(def ,name (litmac litfn () ,params ,@body))))]) (when . [(mac when (cond body) `(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 lo hi color) - (while (< lo hi) - (pixel screen lo y color) - (set lo (+ lo 1)))))]) + (let (x xmax) `(0 ,(width screen)) + (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 lo hi color) - (while (< lo hi) - (pixel screen x lo color) - (set lo (+ lo 1)))))]) + (let (y ymax) `(0 ,(height screen)) + (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) |