]> gitweb.factorcode.org Git - factor.git/commitdiff
colors.yiq: adding YIQ color support.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Oct 2012 22:20:03 +0000 (15:20 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Oct 2012 22:20:03 +0000 (15:20 -0700)
extra/colors/yiq/authors.txt [new file with mode: 0644]
extra/colors/yiq/summary.txt [new file with mode: 0644]
extra/colors/yiq/yiq-docs.factor [new file with mode: 0644]
extra/colors/yiq/yiq.factor [new file with mode: 0644]

diff --git a/extra/colors/yiq/authors.txt b/extra/colors/yiq/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/colors/yiq/summary.txt b/extra/colors/yiq/summary.txt
new file mode 100644 (file)
index 0000000..d91634e
--- /dev/null
@@ -0,0 +1 @@
+YIQ colors
diff --git a/extra/colors/yiq/yiq-docs.factor b/extra/colors/yiq/yiq-docs.factor
new file mode 100644 (file)
index 0000000..fa0ccf0
--- /dev/null
@@ -0,0 +1,14 @@
+USING: help.markup help.syntax ;
+IN: colors.yiq
+
+HELP: yiqa
+{ $class-description "The class of YIQ (Y, In-Place, Quadrature) colors with an alpha channel. All slots store values in the interval " { $snippet "[0,1]" } "." } ;
+
+ARTICLE: "colors.yiq" "YIQ colors"
+"THe " { $vocab-link "colors.yiq" } " vocabulary implements colors specified by their Y, in-place, and quadrature components, together with an alpha channel."
+{ $subsections
+    yiqa
+    <yiqa>
+    rgba>yiqa
+}
+{ $see-also "colors" } ;
diff --git a/extra/colors/yiq/yiq.factor b/extra/colors/yiq/yiq.factor
new file mode 100644 (file)
index 0000000..d34f9b3
--- /dev/null
@@ -0,0 +1,32 @@
+! Copyright (C) 2012 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+
+USING: accessors colors combinators kernel math math.order ;
+
+IN: colors.yiq
+
+TUPLE: yiqa < color
+{ y read-only }
+{ in-phase read-only }
+{ quadrature read-only }
+{ alpha read-only } ;
+
+C: <yiqa> yiqa
+
+M: yiqa >rgba
+    {
+        [ y>> ] [ in-phase>> ] [ quadrature>> ] [ alpha>> ]
+    } cleave [
+        [ [ 0.948262 * ] [ 0.624013 * ] bi* + + ]
+        [ [ 0.276066 * ] [ 0.639810 * ] bi* + - ]
+        [ [ 1.105450 * ] [ 1.729860 * ] bi* - - ]
+        3tri [ 0.0 1.0 clamp ] tri@
+    ] dip <rgba> ;
+
+: 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> ;