aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data/color/pigment.lux
blob: b1798e43879560d1c85a057580c01837a2819679 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["r" rev]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(def .public test
  Test
  (<| (_.covering /._)
      (do [! random.monad]
        [alpha random.rev])
      (_.for [/.Alpha /.Pigment])
      (all _.and
           (_.coverage [/.transparent]
             (and (not (r.< /.transparent alpha))
                  (|> alpha
                      (r.+ /.transparent)
                      (r.= alpha))))
           (_.coverage [/.opaque]
             (not (r.> /.opaque alpha)))
           (_.coverage [/.translucent]
             (and (r.< /.opaque /.translucent)
                  (r.> /.transparent /.translucent)
                  (r.= /.transparent
                       (r.+ /.translucent /.translucent))))
           )))