refactor terrain generation to not use an image boa constructor

Doug Coleman 2009-06-10 15:59:14 -04:00
parent c39344f773
commit 310760aafb
1 changed files with 18 additions and 11 deletions

View File

@ -1,6 +1,7 @@
USING: accessors arrays byte-arrays combinators fry grouping USING: accessors arrays byte-arrays combinators
images kernel math math.affine-transforms math.order combinators.smart fry grouping images kernel math
math.vectors noise random sequences ; math.affine-transforms math.order math.vectors noise random
sequences ;
IN: terrain.generation IN: terrain.generation
CONSTANT: terrain-segment-size { 512 512 } CONSTANT: terrain-segment-size { 512 512 }
@ -31,15 +32,21 @@ TUPLE: terrain big-noise-table small-noise-table tiny-noise-seed ;
TUPLE: segment image ; TUPLE: segment image ;
: <terrain-image> ( bytes -- image )
<image>
swap >>bitmap
RGBA >>component-order
terrain-segment-size >>dim ;
: terrain-segment ( terrain at -- image ) : terrain-segment ( terrain at -- image )
[
{ {
[ big-noise-segment ] [ big-noise-segment ]
[ small-noise-segment ] [ small-noise-segment ]
[ tiny-noise-segment ] [ tiny-noise-segment ]
[ padding ] [ padding ]
} 2cleave } 2cleave
4array flip concat >byte-array ] output>array flip B{ } concat-as <terrain-image> ;
[ terrain-segment-size RGBA f ] dip image boa ;
: 4max ( a b c d -- max ) : 4max ( a b c d -- max )
max max max ; inline max max max ; inline