colors.yiq: adding YIQ color support.

db4
John Benediktsson 2012-10-22 15:20:03 -07:00
parent 20a398ec16
commit 24778bf705
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1 @@
John Benediktsson

View File

@ -0,0 +1 @@
YIQ colors

View File

@ -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" } ;

View File

@ -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> ;