1 ! Copyright (C) 2022 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: accessors colors colors.gray colors.hsl combinators
5 kernel math math.order ;
11 { whiteness read-only }
12 { blackness read-only }
22 [ hue>> ] [ whiteness>> ] [ blackness>> ] [ alpha>> ]
23 } cleave :> ( h w b a )
30 h 1.0 0.5 a <hsla> >rgba-components
31 [ [ 1 w+b - * w + ] tri@ ] dip <rgba>
35 GENERIC: >hwba ( color -- hsla )
37 M: object >hwba >rgba >hwba ;
39 M: hwba >hwba ; inline
43 >hsla [ hue>> ] [ >rgba-components ] bi :> ( h r g b a )
45 r g b max max 1 swap - :> b