;; Something to output a color palette according to https://9p.io/magic/man2html/6/color ;; ;; I couldn't visualize the colors it was supposed to generate, and I ;; was curious, so I made a thing to generate said colors and display ;; them. ;; ;; I THINK the colors are correct. ;; ;; By icefox@dreamquest.io ;; License: MIT (fn generate-palette [] "Generates the palette, returning a list of [r g b] values" (var palette []) (for [r 0 3] (for [v 0 3] (for [g 0 3] (for [b 0 3] (var denom r) (if (> g denom) (set denom g)) (if (> b denom) (set denom b)) ; Check for divide by 0, pick grey (if (= denom 0) (let [c (* 17 v)] (table.insert palette [c c c])) (let [num (* 17 (+ (* 4 denom) v))] (table.insert palette [(// (* r num) denom) (// (* g num) denom) (// (* b num) denom)]))))))) palette) ;; Ok now we want to output the result of this. We have three options. ;; First, we could just print out the raw values, though that's not ;; very helpful: ;(local fennel (require :fennel)) ;(print (fennel.view (generate-palette))) ;; Otherwise I WAS going to make a cool program that generated a png or ;; displayed something with love2d, but (print "
") (print "" color-str)) ; (print color-str) ; (print " |
" color-str)) (print color-str) (print " | "))) (print "