]> gitweb.factorcode.org Git - factor.git/commitdiff
colors.yiq: expanded the number of digits in the coefficients for the rgba>yiqa conve...
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 18 Sep 2013 23:17:07 +0000 (16:17 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 18 Sep 2013 23:17:07 +0000 (16:17 -0700)
extra/colors/yiq/yiq.factor

index 300539d65940b931512456dc48804a8c04ede1fe..8afa9d513195c521477c9881e67bf667683cd94c 100644 (file)
@@ -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 <rgba> ; 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 <yiqa> ;
+:: 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 <yiqa> ;