diff --git a/extra/benchmark/mandel/colors/colors.factor b/extra/benchmark/mandel/colors/colors.factor index 0300538ce1..87a2df6fe5 100644 --- a/extra/benchmark/mandel/colors/colors.factor +++ b/extra/benchmark/mandel/colors/colors.factor @@ -1,5 +1,5 @@ USING: math math.order kernel arrays byte-arrays sequences -colors.hsv benchmark.mandel.params accessors colors ; +colors.hsv accessors colors fry benchmark.mandel.params ; IN: benchmark.mandel.colors : scale ( x -- y ) 255 * >fixnum ; inline @@ -11,10 +11,10 @@ CONSTANT: sat 0.85 CONSTANT: val 0.85 : ( nb-cols -- map ) - dup [ - 360 * swap 1 + / sat val + [ iota ] keep '[ + 360 * _ 1 + / sat val 1 >rgba scale-rgb - ] with map ; + ] map ; : color-map ( -- map ) max-iterations max-color min ; foldable diff --git a/extra/benchmark/mandel/mandel.factor b/extra/benchmark/mandel/mandel.factor index 1da3d91c61..97d7008487 100755 --- a/extra/benchmark/mandel/mandel.factor +++ b/extra/benchmark/mandel/mandel.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: io kernel math math.functions sequences prettyprint io.files io.files.temp io.encodings io.encodings.ascii @@ -6,13 +6,12 @@ io.encodings.binary fry benchmark.mandel.params benchmark.mandel.colors ; IN: benchmark.mandel -: x-inc ( -- x ) width 200000 zoom-fact * / ; inline -: y-inc ( -- y ) height 150000 zoom-fact * / ; inline +: x-scale ( -- x ) width 200000 zoom-fact * / ; inline +: y-scale ( -- y ) height 150000 zoom-fact * / ; inline -: c ( i j -- c ) - [ x-inc * center real-part x-inc width 2 / * - + >float ] - [ y-inc * center imaginary-part y-inc height 2 / * - + >float ] bi* - rect> ; inline +: scale ( x y -- z ) [ x-scale * ] [ y-scale * ] bi* rect> ; inline + +: c ( i j -- c ) scale center width height scale 2 / - + ; inline : count-iterations ( z max-iterations step-quot test-quot -- #iters ) '[ drop @ dup @ ] find-last-integer nip ; inline @@ -25,7 +24,7 @@ IN: benchmark.mandel [ color-map [ length mod ] keep nth ] [ B{ 0 0 0 } ] if* ; inline : render ( -- ) - height [ width swap '[ _ c pixel color write ] each ] each ; inline + height iota [ width iota swap '[ _ c pixel color write ] each ] each ; inline : ppm-header ( -- ) ascii encode-output