colors: adding linear-gradient.

db4
John Benediktsson 2012-10-21 12:32:45 -07:00
parent 4fe22de451
commit ac5c9a5d91
1 changed files with 7 additions and 2 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2003, 2009 Slava Pestov.
! Copyright (C) 2008 Eduardo Cavazos.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors combinators math ;
USING: accessors combinators kernel math locals ;
IN: colors
TUPLE: color ;
@ -27,4 +27,9 @@ M: color blue>> ( color -- blue ) >rgba blue>> ;
: opaque? ( color -- ? ) alpha>> 1 number= ;
CONSTANT: transparent T{ rgba f 0.0 0.0 0.0 0.0 }
CONSTANT: transparent T{ rgba f 0.0 0.0 0.0 0.0 }
:: linear-gradient ( color1 color2 percent -- color )
color1 >rgba-components drop [ 1.0 percent - * ] tri@
color2 >rgba-components drop [ percent * ] tri@
[ + ] tri-curry@ tri* 1.0 <rgba> ;