Merge branch 'master' of git://factorcode.org/git/factor

db4
John Benediktsson 2008-09-11 18:24:04 -07:00
commit 15408bb246
1 changed files with 8 additions and 13 deletions

View File

@ -1,9 +1,8 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays io kernel namespaces math math.functions USING: io kernel math math.functions sequences prettyprint
math.order math.parser sequences byte-arrays byte-vectors io.files io.encodings io.encodings.ascii io.encodings.binary fry
io.files io.encodings.binary fry make benchmark.mandel.params benchmark.mandel.params benchmark.mandel.colors ;
benchmark.mandel.colors ;
IN: benchmark.mandel IN: benchmark.mandel
: x-inc width 200000 zoom-fact * / ; inline : x-inc width 200000 zoom-fact * / ; inline
@ -25,18 +24,14 @@ IN: benchmark.mandel
[ color-map [ length mod ] keep nth ] [ B{ 0 0 0 } ] if* ; inline [ color-map [ length mod ] keep nth ] [ B{ 0 0 0 } ] if* ; inline
: render ( -- ) : render ( -- )
height [ width swap '[ _ c pixel color % ] each ] each ; inline height [ width swap '[ _ c pixel color write ] each ] each ; inline
: ppm-header ( -- ) : ppm-header ( -- )
"P6\n" % width # " " % height # "\n255\n" % ; inline ascii encode-output
"P6\n" write width pprint " " write height pprint "\n255\n" write
: buf-size ( -- n ) width height * 3 * 100 + ; inline binary encode-output ; inline
: mandel ( -- data )
buf-size <byte-vector>
[ building [ ppm-header render ] with-variable ] [ B{ } like ] bi ;
: mandel-main ( -- ) : mandel-main ( -- )
mandel "mandel.ppm" temp-file binary set-file-contents ; "mandel.ppm" temp-file binary [ ppm-header render ] with-file-writer ;
MAIN: mandel-main MAIN: mandel-main