From ac5c9a5d91d7c499550151cf1557fe3d35476f4f Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 21 Oct 2012 12:32:45 -0700 Subject: [PATCH] colors: adding linear-gradient. --- basis/colors/colors.factor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/basis/colors/colors.factor b/basis/colors/colors.factor index 0cd743fa5f..cdcd0ec93e 100644 --- a/basis/colors/colors.factor +++ b/basis/colors/colors.factor @@ -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 ;