refactor terrain generation to not use an image boa constructor
parent
c39344f773
commit
310760aafb
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue