use l5 colorLerp and color fns

This commit is contained in:
Travis Shears 2026-05-27 18:10:27 +01:00
parent 580218dac4
commit b4f9aaa39f
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
2 changed files with 5 additions and 8 deletions

View file

@ -4,11 +4,8 @@
(size 640 480)
(textSize 100))
(local colors {
:yellow [255 228 112] ; #ffe470
:dark [64 56 48] ; #403830
})
(local yellow (color 255 228 112)) ; #ffe470
(local dark (color 64 56 48)) ; #403830
(local steps (* 24 60))
(var step 0)
@ -32,8 +29,8 @@
(let [
half (/ steps 2)
color-step (if (> step half) (- half (- step half)) step)
color-fn #(+ (. colors.dark $1) (* (/ (- (. colors.yellow $1) (. colors.dark $1)) half) color-step))]
(background (color-fn 1) (color-fn 2) (color-fn 3)))
current-color (lerpColor dark yellow (map color-step 0 half 0 1))]
(background current-color))
(text (time step) 175 150)
(text (time goal-time) 175 250)
(when (and pause (= goal-time step)) (set won true))

View file

@ -58,7 +58,7 @@
(def built-ins #{"fn" "local" "λ" "lambda" "require" "let" "+" "-" "/" "*" "<" ">" "<=" ">=" "not=" ".."
"var" "if" "when" "and" "or" "not" "do" "set" "each" "for" "while"
"true" "$1" "math.floor" "floor" "false" "nil" "size" "textSize" "background" "text" "random" "key"
":setup" ":draw" ":key-pressed" ":L5" "map"})
":setup" ":draw" ":key-pressed" ":L5" "map" "color" "lerpColor"})
(defn collect-bindings [tokens]
(reduce (fn [acc token]