]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/benchmark/mandel/colors/colors.factor
factor: trim using lists
[factor.git] / extra / benchmark / mandel / colors / colors.factor
index 7bbb25a47d532a5be1c16628610b2524cd54592a..8a1d17dd67b722c4a1d25a781f78512be5ee40e7 100644 (file)
@@ -1,19 +1,20 @@
-USING: math math.order kernel arrays byte-arrays sequences
-colors.hsv benchmark.mandel.params ;
+USING: math math.order kernel byte-arrays sequences
+colors.hsv accessors colors benchmark.mandel.params ;
 IN: benchmark.mandel.colors
 
-: scale 255 * >fixnum ; inline
+: scale ( x -- y ) 255 * >fixnum ; inline
 
-: scale-rgb ( r g b -- n ) [ scale ] tri@ 3byte-array ;
+: scale-rgb ( rgba -- n )
+    [ red>> scale ] [ green>> scale ] [ blue>> scale ] tri 3byte-array ;
 
-: sat 0.85 ; inline
-: val 0.85 ; inline
+CONSTANT: sat 0.85
+CONSTANT: val 0.85
 
 : <color-map> ( nb-cols -- map )
-    dup [
-        360 * swap 1+ / sat val
-        3array hsv>rgb first3 scale-rgb
-    ] with map ;
+    [ <iota> ] keep '[
+        360 * _ 1 + / sat val
+        1 <hsva> >rgba scale-rgb
+    ] map ;
 
 : color-map ( -- map )
     max-iterations max-color min <color-map> ; foldable