1 ! Copyright (C) 2013 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: accessors colors kernel locals math math.order ;
18 : normalized ( a b c quot: ( a b c -- a' b' c' ) -- a' b' c' )
19 [ 3dup min min ] dip over
22 [ [ + ] curry tri@ ] tri* ; inline
24 :: ryb>rgb ( r! y! b! -- r g b )
40 my swap / [ * ] curry tri@
43 :: rgb>ryb ( r! g! b! -- r y b )
59 mg swap / [ * ] curry tri@
66 [ red>> ] [ yellow>> ] [ blue>> ] tri
67 [ ryb>rgb ] normalized
68 ] [ alpha>> ] bi <rgba> ;
70 GENERIC: >ryba ( color -- ryba )
72 M: object >ryba >rgba >ryba ;
74 M: ryba >ryba ; inline
77 >rgba-components [ [ rgb>ryb ] normalized ] [ <ryba> ] bi* ;