]> gitweb.factorcode.org Git - factor.git/commitdiff
colors: adding linear-gradient.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 21 Oct 2012 19:32:45 +0000 (12:32 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 21 Oct 2012 19:32:45 +0000 (12:32 -0700)
basis/colors/colors.factor

index 0cd743fa5fd8a1e57a7f6cf8f76c6d361af69f6e..cdcd0ec93e3a8b4ebafa23b233bcbd3fac3d74b5 100644 (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 }
\ No newline at end of file
+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> ;