colors: adding some tests rgba to color to rgba roundtrips.

db4
John Benediktsson 2013-09-18 16:20:20 -07:00
parent a3e669aab3
commit 0de857e1fe
4 changed files with 72 additions and 12 deletions

View File

@ -0,0 +1,19 @@
! Copyright (C) 2013 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: arrays colors kernel locals math.functions math.ranges
sequences tools.test ;
IN: colors.cmyk
{ t } [
0.0 1.0 0.1 <range> [| r |
0.0 1.0 0.1 <range> [| g |
0.0 1.0 0.1 <range> [| b |
r g b 1.0 <rgba> dup rgba>cmyka >rgba
[ >rgba-components 4array ] bi@
[ 0.00000001 ~ ] 2all?
] all?
] all?
] all?
] unit-test

View File

@ -0,0 +1,19 @@
! Copyright (C) 2013 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: arrays colors kernel locals math.functions math.ranges
sequences tools.test ;
IN: colors.hsl
{ t } [
0.0 1.0 0.1 <range> [| r |
0.0 1.0 0.1 <range> [| g |
0.0 1.0 0.1 <range> [| b |
r g b 1.0 <rgba> dup rgba>hsla >rgba
[ >rgba-components 4array ] bi@
[ 0.00000001 ~ ] 2all?
] all?
] all?
] all?
] unit-test

View File

@ -1,16 +1,19 @@
USING: assocs colors kernel tools.test ; ! Copyright (C) 2013 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: arrays colors kernel locals math.functions math.ranges
sequences tools.test ;
IN: colors.ryb IN: colors.ryb
{ t } [ { t } [
{ 0.0 1.0 0.1 <range> [| r |
{ T{ rgba f 1.0 0.0 0.0 } T{ ryba f 1.0 0.0 0.0 } } 0.0 1.0 0.1 <range> [| g |
{ T{ rgba f 0.0 1.0 0.0 } T{ ryba f 0.0 1.0 1.0 } } 0.0 1.0 0.1 <range> [| b |
{ T{ rgba f 0.0 0.0 1.0 } T{ ryba f 0.0 0.0 1.0 } } r g b 1.0 <rgba> dup rgba>ryba >rgba
{ T{ rgba f 0.0 1.0 1.0 } T{ ryba f 0.0 0.5 1.0 } } [ >rgba-components 4array ] bi@
{ T{ rgba f 1.0 0.0 1.0 } T{ ryba f 1.0 0.0 1.0 } } [ 0.00000001 ~ ] 2all?
{ T{ rgba f 1.0 1.0 0.0 } T{ ryba f 0.0 1.0 0.0 } } ] all?
{ T{ rgba f 0.0 0.0 0.0 } T{ ryba f 0.0 0.0 0.0 } } ] all?
{ T{ rgba f 1.0 1.0 1.0 } T{ ryba f 1.0 1.0 1.0 } } ] all?
}
[ [ >rgba = ] [ swap rgba>ryba = ] 2bi and ] assoc-all?
] unit-test ] unit-test

View File

@ -0,0 +1,19 @@
! Copyright (C) 2013 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: arrays colors kernel locals math.functions math.ranges
sequences tools.test ;
IN: colors.yiq
{ t } [
0.0 1.0 0.1 <range> [| r |
0.0 1.0 0.1 <range> [| g |
0.0 1.0 0.1 <range> [| b |
r g b 1.0 <rgba> dup rgba>yiqa >rgba
[ >rgba-components 4array ] bi@
[ 0.00000001 ~ ] 2all?
] all?
] all?
] all?
] unit-test