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