ui.pens.gradient: update for iota

db4
Slava Pestov 2010-01-15 06:19:13 +13:00
parent 4bab2ba807
commit 816b47561a
2 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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 ;