aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/color.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/data/color.lux79
1 files changed, 4 insertions, 75 deletions
diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux
index 2bfa5e5af..b65249c33 100644
--- a/stdlib/source/library/lux/data/color.lux
+++ b/stdlib/source/library/lux/data/color.lux
@@ -47,90 +47,19 @@
... else
it))
-(with_template [<op> <name>]
- [(def .public (<name> ratio it)
- (-> Frac Color Color)
- (let [it (hsl.of_rgb (rgb it))]
- (|> (hsl.hsl (hsl.hue it)
- (|> it
- hsl.saturation
- (f.* (|> +1.0 (<op> (..ratio ratio))))
- (f.min +1.0))
- (hsl.luminance it))
- hsl.rgb
- of_rgb)))]
-
- [f.+ saturated]
- [f.- un_saturated]
- )
-
-(def .public (gray_scale color)
- (-> Color Color)
- (let [color (hsl.of_rgb (rgb color))]
- (|> (hsl.hsl +0.0
- +0.0
- (hsl.luminance color))
- hsl.rgb
- of_rgb)))
-
-(with_template [<name> <1> <2>]
- [(`` (def .public (<name> color)
- (-> Color [Color Color Color])
- (let [hsl (hsl.of_rgb (rgb color))
- hue (hsl.hue hsl)
- saturation (hsl.saturation hsl)
- luminance (hsl.luminance hsl)]
- [color
- (|> (hsl.hsl (|> hue (f.+ <1>) ..ratio)
- saturation
- luminance)
- hsl.rgb
- of_rgb)
- (|> (hsl.hsl (|> hue (f.+ <2>) ..ratio)
- saturation
- luminance)
- hsl.rgb
- of_rgb)])))]
-
- [triad (|> +1.0 (f./ +3.0)) (|> +2.0 (f./ +3.0))]
- [clash (|> +1.0 (f./ +4.0)) (|> +3.0 (f./ +4.0))]
- [split_complement (|> +1.0 (f./ +5.0)) (|> +3.0 (f./ +5.0))]
- )
-
-(with_template [<name> <1> <2> <3>]
- [(`` (def .public (<name> color)
- (-> Color [Color Color Color Color])
- (let [it (hsl.of_rgb (..rgb color))
- hue (hsl.hue it)
- saturation (hsl.saturation it)
- luminance (hsl.luminance it)
- of_hue (is (-> hsl.Value
- Color)
- (function (_ hue)
- (|> (hsl.hsl hue saturation luminance)
- hsl.rgb
- ..of_rgb)))]
- [color
- (|> hue (f.+ <1>) ..ratio of_hue)
- (|> hue (f.+ <2>) ..ratio of_hue)
- (|> hue (f.+ <3>) ..ratio of_hue)])))]
-
- [square (|> +1.0 (f./ +4.0)) (|> +2.0 (f./ +4.0)) (|> +3.0 (f./ +4.0))]
- [tetradic (|> +2.0 (f./ +12.0)) (|> +6.0 (f./ +12.0)) (|> +8.0 (f./ +12.0))]
- )
-
(type .public Spread
Frac)
+... https://en.wikipedia.org/wiki/Color_scheme
(type .public Palette
(-> Spread Nat Color (List Color)))
(def .public (analogous spread variations it)
Palette
(let [it (hsl.of_rgb (..rgb it))
- hue (hsl.hue it)
- saturation (hsl.saturation it)
- luminance (hsl.luminance it)
+ hue (the hsl.#hue it)
+ saturation (the hsl.#saturation it)
+ luminance (the hsl.#luminance it)
spread (..ratio spread)]
(list#each (function (_ idx)
(|> (hsl.hsl (|> idx ++ .int int.frac (f.* spread) (f.+ hue) ..ratio)