diff options
author | Eduardo Julian | 2022-12-02 19:33:00 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-12-02 19:33:00 -0400 |
commit | 94e5802f594a73245fce0fbd885103b8bf210d57 (patch) | |
tree | 65e5799c0be40f5f015b39bfa6c87c9c27fd9424 /stdlib/source/test/lux/data/color.lux | |
parent | b491dfff00219d5206075ea65468e00ab657075d (diff) |
Added some simple time-series handling machinery.
Diffstat (limited to 'stdlib/source/test/lux/data/color.lux')
-rw-r--r-- | stdlib/source/test/lux/data/color.lux | 120 |
1 files changed, 56 insertions, 64 deletions
diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index 8198800e6..5d94addef 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -27,6 +27,8 @@ ["[1][0]" rgb] ["[1][0]" cmyk] ["[1][0]" hsl] + ["[1][0]" hsb] + ["[1][0]" pigment] ["[1][0]" named] ["[1][0]" terminal]]) @@ -81,11 +83,7 @@ (all _.and (_.coverage [/.rgb /.of_rgb] (|> expected /.rgb /.of_rgb - (at /.equivalence = expected))) - (_.coverage [/.HSB /.hsb /.of_hsb] - (|> expected /.hsb /.of_hsb - (distance/3 expected) - (f.<= ..rgb_error_margin))) + (of /.equivalence = expected))) )) (def transformation @@ -127,54 +125,54 @@ (f.<= ..rgb_error_margin))))) ))) -(def palette - Test - (_.for [/.Spread /.Palette] - (do [! random.monad] - [eH (at ! each (|>> f.abs (f.% +0.9) (f.+ +0.05)) - random.safe_frac) - .let [eS +0.5] - variations (at ! each (|>> (n.% 3) (n.+ 2)) random.nat) - .let [max_spread (f./ (|> variations ++ .int int.frac) - +1.0) - min_spread (f./ +2.0 max_spread) - spread_space (f.- min_spread max_spread)] - spread (at ! each (|>> f.abs (f.% spread_space) (f.+ min_spread)) - random.safe_frac)] - (`` (all _.and - (,, (with_template [<brightness> <palette>] - [(_.coverage [<palette>] - (let [eB <brightness> - expected (/.of_hsb [eH eS eB]) - palette (<palette> spread variations expected)] - (and (n.= variations (list.size palette)) - (not (list.any? (at /.equivalence = expected) palette)))))] - [+1.0 /.analogous] - [+0.5 /.monochromatic] - )) - (,, (with_template [<palette>] - [(_.coverage [<palette>] - (let [expected (/.of_hsb [eH eS +0.5]) - [c0 c1 c2] (<palette> expected)] - (and (at /.equivalence = expected c0) - (not (at /.equivalence = expected c1)) - (not (at /.equivalence = expected c2)))))] - - [/.triad] - [/.clash] - [/.split_complement])) - (,, (with_template [<palette>] - [(_.coverage [<palette>] - (let [expected (/.of_hsb [eH eS +0.5]) - [c0 c1 c2 c3] (<palette> expected)] - (and (at /.equivalence = expected c0) - (not (at /.equivalence = expected c1)) - (not (at /.equivalence = expected c2)) - (not (at /.equivalence = expected c3)))))] - - [/.square] - [/.tetradic])) - ))))) +... (def palette +... Test +... (_.for [/.Spread /.Palette] +... (do [! random.monad] +... [eH (of ! each (|>> f.abs (f.% +0.9) (f.+ +0.05)) +... random.safe_frac) +... .let [eS +0.5] +... variations (of ! each (|>> (n.% 3) (n.+ 2)) random.nat) +... .let [max_spread (f./ (|> variations ++ .int int.frac) +... +1.0) +... min_spread (f./ +2.0 max_spread) +... spread_space (f.- min_spread max_spread)] +... spread (of ! each (|>> f.abs (f.% spread_space) (f.+ min_spread)) +... random.safe_frac)] +... (`` (all _.and +... (,, (with_template [<brightness> <palette>] +... [(_.coverage [<palette>] +... (let [eB <brightness> +... expected (/.of_hsb [eH eS eB]) +... palette (<palette> spread variations expected)] +... (and (n.= variations (list.size palette)) +... (not (list.any? (of /.equivalence = expected) palette)))))] +... [+1.0 /.analogous] +... [+0.5 /.monochromatic] +... )) +... (,, (with_template [<palette>] +... [(_.coverage [<palette>] +... (let [expected (/.of_hsb [eH eS +0.5]) +... [c0 c1 c2] (<palette> expected)] +... (and (of /.equivalence = expected c0) +... (not (of /.equivalence = expected c1)) +... (not (of /.equivalence = expected c2)))))] + +... [/.triad] +... [/.clash] +... [/.split_complement])) +... (,, (with_template [<palette>] +... [(_.coverage [<palette>] +... (let [expected (/.of_hsb [eH eS +0.5]) +... [c0 c1 c2 c3] (<palette> expected)] +... (and (of /.equivalence = expected c0) +... (not (of /.equivalence = expected c1)) +... (not (of /.equivalence = expected c2)) +... (not (of /.equivalence = expected c3)))))] + +... [/.square] +... [/.tetradic])) +... ))))) (def .public test Test @@ -199,22 +197,16 @@ (and (not (/#= expected ~expected)) (/#= expected (/.complement ~expected))))) (_.coverage [/.black /.white] - (and (at /.equivalence = /.white (/.complement /.black)) - (at /.equivalence = /.black (/.complement /.white)))) + (and (of /.equivalence = /.white (/.complement /.black)) + (of /.equivalence = /.black (/.complement /.white)))) ..transformation - ..palette - (_.for [/.Alpha /.Pigment] - (all _.and - (_.coverage [/.transparent /.opaque] - (and (r.= /.opaque (-- /.transparent)) - (r.= /.transparent (++ /.opaque)))) - (_.coverage [/.translucent] - (r.= /.transparent (r.+ /.translucent /.translucent))) - )) + ... ..palette /rgb.test /cmyk.test /hsl.test + /hsb.test + /pigment.test /named.test /terminal.test )))) |