]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/mandel/colors/colors.factor
factor: trim using lists
[factor.git] / extra / benchmark / mandel / colors / colors.factor
1 USING: math math.order kernel byte-arrays sequences
2 colors.hsv accessors colors benchmark.mandel.params ;
3 IN: benchmark.mandel.colors
4
5 : scale ( x -- y ) 255 * >fixnum ; inline
6
7 : scale-rgb ( rgba -- n )
8     [ red>> scale ] [ green>> scale ] [ blue>> scale ] tri 3byte-array ;
9
10 CONSTANT: sat 0.85
11 CONSTANT: val 0.85
12
13 : <color-map> ( nb-cols -- map )
14     [ <iota> ] keep '[
15         360 * _ 1 + / sat val
16         1 <hsva> >rgba scale-rgb
17     ] map ;
18
19 : color-map ( -- map )
20     max-iterations max-color min <color-map> ; foldable