diff --git a/extra/colors/yiq/authors.txt b/extra/colors/yiq/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/extra/colors/yiq/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/extra/colors/yiq/summary.txt b/extra/colors/yiq/summary.txt new file mode 100644 index 0000000000..d91634e93f --- /dev/null +++ b/extra/colors/yiq/summary.txt @@ -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 index 0000000000..fa0ccf02c1 --- /dev/null +++ b/extra/colors/yiq/yiq-docs.factor @@ -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 + + rgba>yiqa +} +{ $see-also "colors" } ; diff --git a/extra/colors/yiq/yiq.factor b/extra/colors/yiq/yiq.factor new file mode 100644 index 0000000000..d34f9b3a02 --- /dev/null +++ b/extra/colors/yiq/yiq.factor @@ -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 + +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>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 ;