From 816b47561accb0e7cc13c6187aea88020478326b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 15 Jan 2010 06:19:13 +1300 Subject: [PATCH] ui.pens.gradient: update for iota --- basis/ui/pens/gradient/gradient-tests.factor | 26 +++++++++++++++++--- basis/ui/pens/gradient/gradient.factor | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/basis/ui/pens/gradient/gradient-tests.factor b/basis/ui/pens/gradient/gradient-tests.factor index 63134b3c8e..22802d39ae 100644 --- a/basis/ui/pens/gradient/gradient-tests.factor +++ b/basis/ui/pens/gradient/gradient-tests.factor @@ -1,4 +1,24 @@ -! Copyright (C) 2009 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: tools.test ui.pens.gradient ; +USING: tools.test ui.pens.gradient ui.pens.gradient.private +colors.constants specialized-arrays alien.c-types ; +SPECIALIZED-ARRAY: float IN: ui.pens.gradient.tests + +[ + float-array{ + 0.0 + 0.0 + 0.0 + 100.0 + 50.0 + 0.0 + 50.0 + 100.0 + 100.0 + 0.0 + 100.0 + 100.0 + } +] [ + { 1 0 } { 100 100 } { COLOR: red COLOR: green COLOR: blue } + gradient-vertices +] unit-test diff --git a/basis/ui/pens/gradient/gradient.factor b/basis/ui/pens/gradient/gradient.factor index 7f7bd02204..fbf190a218 100644 --- a/basis/ui/pens/gradient/gradient.factor +++ b/basis/ui/pens/gradient/gradient.factor @@ -16,7 +16,7 @@ TUPLE: gradient < caching-pen colors last-vertices last-colors ; :: gradient-vertices ( direction dim colors -- seq ) direction dim v* dim over v- swap - colors length dup 1 - v/n [ v*n ] with map + colors length [ iota ] [ 1 - ] bi v/n [ v*n ] with map swap [ over v+ 2array ] curry map concat concat >float-array ;