diff --git a/extra/colors/yiq/yiq.factor b/extra/colors/yiq/yiq.factor index 300539d659..8afa9d5131 100644 --- a/extra/colors/yiq/yiq.factor +++ b/extra/colors/yiq/yiq.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2012 John Benediktsson ! See http://factorcode.org/license.txt for BSD license -USING: accessors colors combinators kernel math math.order ; +USING: accessors colors combinators kernel locals math +math.order ; IN: colors.yiq @@ -17,16 +18,17 @@ M: yiqa >rgba { [ y>> ] [ in-phase>> ] [ quadrature>> ] [ alpha>> ] } cleave [ - [ [ 0.948262 * ] [ 0.624013 * ] bi* + + ] - [ [ 0.276066 * ] [ 0.639810 * ] bi* + - ] - [ [ 1.105450 * ] [ 1.729860 * ] bi* - - ] + [ [ 0.9468822170900693 * ] [ 0.6235565819861433 * ] bi* + + ] + [ [ 0.27478764629897834 * ] [ 0.6356910791873801 * ] bi* + - ] + [ [ 1.1085450346420322 * ] [ 1.7090069284064666 * ] bi* - - ] 3tri [ 0.0 1.0 clamp ] tri@ ] dip ; inline -: rgba>yiqa ( rgba -- yiqa ) - >rgba-components [ - [ [ 0.30 * ] [ 0.59 * ] [ 0.11 * ] tri* + + ] - [ [ 0.60 * ] [ 0.28 * ] [ 0.32 * ] tri* + - ] - [ [ 0.21 * ] [ 0.52 * ] [ 0.31 * ] tri* - - ] - 3tri - ] dip ; +:: rgba>yiqa ( rgba -- yiqa ) + rgba >rgba-components :> ( r g b a ) + 0.30 r * 0.59 g * 0.11 b * + + :> y + r y - :> r-y + b y - :> b-y + 0.74 r-y * 0.27 b-y * - :> i + 0.48 r-y * 0.41 b-y * + :> q + y i q a ;