]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/mandel/colors/colors.factor
87a2df6fe545b05a4335ec05e82482efaf63790c
[factor.git] / extra / benchmark / mandel / colors / colors.factor
1 USING: math math.order kernel arrays byte-arrays sequences
2 colors.hsv accessors colors fry 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