From 86120571285246797ecec30d810c10d3230c5425 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 6 May 2009 13:47:35 -0500 Subject: [PATCH] make noise-map/noise-image take an affine-transform --- extra/perlin-noise/perlin-noise.factor | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extra/perlin-noise/perlin-noise.factor b/extra/perlin-noise/perlin-noise.factor index e662202ca1..0a12eef12c 100644 --- a/extra/perlin-noise/perlin-noise.factor +++ b/extra/perlin-noise/perlin-noise.factor @@ -1,4 +1,4 @@ -USING: byte-arrays combinators images kernel locals math +USING: byte-arrays combinators images kernel locals math math.affine-transforms math.functions math.polynomials math.vectors random sequences sequences.product ; IN: perlin-noise @@ -70,14 +70,14 @@ IN: perlin-noise [ faded second lerp ] 2bi@ faded third lerp ; -: noise-map ( table scale dim -- map ) - [ iota ] map [ v* 0.0 suffix noise ] with with product-map ; +: noise-map ( table transform dim -- map ) + [ iota ] map [ a.v 0.0 suffix noise ] with with product-map ; -: normalize ( sequence -- sequence' ) +: normalize-0-1 ( sequence -- sequence' ) [ supremum ] [ infimum [ - ] keep ] [ ] tri [ swap - ] with map [ swap / ] with map ; -: noise-image ( table scale dim -- image ) - [ noise-map normalize [ 255.0 * >fixnum ] B{ } map-as ] +: noise-image ( table transform dim -- image ) + [ noise-map normalize-0-1 [ 255.0 * >fixnum ] B{ } map-as ] [ swap [ L f ] dip image boa ] bi ;