palette operations now a bit faster

This commit is contained in:
Kartik K. Agaram 2021-07-26 01:33:48 -07:00
parent 438c00fd1f
commit 6b57715502

View File

@ -146,20 +146,22 @@
for r r0 (r < r0+w) ++r for r r0 (r < r0+w) ++r
(circle screen cx cy r clr)]) (circle screen cx cy r clr)])
(Greys . [define Greys (Greys . [define Greys
(map1 (fn(n) n+15) ret p (populate 16 ())
(seq 16))]) for i 0 (< i 16) ++i
(Pinks . [define Pinks '(84 85 59 60 61 iset p i i+16])
13 36 37 5 108)]) (Pinks . [define Pinks (array
84 85 59 60 61
13 36 37 5 108)])
(palette . [def (palette p i) (palette . [def (palette p i)
(nth (i % (len p)) p)]) (index p (i % (len p)))])
(pat . [def (pat screen) (pat . [def (pat screen)
with (w (width screen) with (w (width screen)
h (height screen)) h (height screen))
for y 0 (y < h) ++y for y 0 (y < h) ++y
for x 0 (x < w) ++x for x 0 (x < w) ++x
(pixel screen x y x*y)]) (pixel screen x y (palette Greys x*y))])
(main . [def (main screen keyboard) (main . [def (main screen keyboard)
(pat screen)]) (pat screen)])
)) ))
(sandbox . [circle screen 35 35 14 3]) (sandbox . [pat screen])
) )