Simplify mandelbrot
parent
f2721e0608
commit
4413ef40c2
|
@ -1,9 +1,8 @@
|
|||
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays io kernel namespaces math math.functions
|
||||
math.order math.parser sequences byte-arrays byte-vectors
|
||||
io.files io.encodings.binary fry make benchmark.mandel.params
|
||||
benchmark.mandel.colors ;
|
||||
USING: io kernel math math.functions sequences prettyprint
|
||||
io.files io.encodings io.encodings.ascii io.encodings.binary fry
|
||||
benchmark.mandel.params benchmark.mandel.colors ;
|
||||
IN: benchmark.mandel
|
||||
|
||||
: 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
|
||||
|
||||
: render ( -- )
|
||||
height [ width swap '[ _ c pixel color % ] each ] each ; inline
|
||||
height [ width swap '[ _ c pixel color write ] each ] each ; inline
|
||||
|
||||
: ppm-header ( -- )
|
||||
"P6\n" % width # " " % height # "\n255\n" % ; inline
|
||||
|
||||
: buf-size ( -- n ) width height * 3 * 100 + ; inline
|
||||
|
||||
: mandel ( -- data )
|
||||
buf-size <byte-vector>
|
||||
[ building [ ppm-header render ] with-variable ] [ B{ } like ] bi ;
|
||||
ascii encode-output
|
||||
"P6\n" write width pprint " " write height pprint "\n255\n" write
|
||||
binary encode-output ; inline
|
||||
|
||||
: 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
|
||||
|
|
Loading…
Reference in New Issue