8.10
7 RRLL: Single-Channel Flomaps
Racket Rogue-Like Library: 2D and 3D Single-Channel Flomaps
These modules provide data structure with single-channel canvas-like
behavior used for procedural generation and similar.
7.1 Construction and Access
This module contains the 2D flonum? map structure and basic
constructors and accessors.
(struct fl1map (width height data))
|
width : fixnum? |
height : fixnum? |
data : flvector? |
Stores the single-channel flonum? map data.
(make-fl1map width height) → fl1map?
|
width : fixnum? |
height : fixnum? |
Creates fl1map? of specified size.
(fl1map-putpixel! fm x y v) → void?
|
fm : fl1map? |
x : fixnum? |
y : fixnum? |
v : flonum? |
Sets single fl1map? pixel to the value specified. Performs
any clipping necessary.
(fl1map-getpixel fm x y default) → (or/c #f flonum?)
|
fm : fl1map? |
x : fixnum? |
y : fixnum? |
default : (or/c #f flonum?) |
Gets a single fl1map? pixel defaulting to default value
if the requested pixel is outside of its bounds.
7.2 Bilinear Sampling
This module contains the bilinear sampling procedures for
single-channel flonum? maps.
(fl1map-sample fm x y) → flonum?
|
fm : fl1map? |
x : flonum? |
y : flonum? |
Samples given fl1map?. The coordinates are in its dimensions.
(fl1map-unit-sample fm x y) → flonum?
|
fm : fl1map? |
x : flonum? |
y : flonum? |
Samples given fl1map?. Both x,y\in\langle 0;1.0\rangle.
7.3 Querying
This module contains procedures used for querying the flomaps.
(fl1map-min fm) → flonum?
|
fm : fl1map? |
Finds the minimum value in given fl1map?.
(fl1map-max fm) → flonum?
|
fm : fl1map? |
Finds the maximum value in given fl1map?.
7.4 Operations
This module contains mutating operations on 2D fl1map?s.
(fl1map-addpixel! fm x y v) → void?
|
fm : fl1map? |
x : fixnum? |
y : fixnum? |
v : flonum? |
Adds given value to the pixel value.
(fl1map-divpixel! fm x y n) → void?
|
fm : fl1map? |
x : fixnum? |
y : fixnum? |
n : flonum? |
Divides given pixel value by the number provided.
(fl1map-div! fm n) → void?
|
fm : fl1map? |
n : flonum? |
Divides all pixels by given number.
(fl1map-normalize! fm) → void?
|
fm : fl1map? |
Normalizes all the values of given fl1map?.
(fl1map-transpose fm) → fl1map?
|
fm : fl1map? |
Creates a new fl1map? which is a transposition of the given one.
7.5 Rendering to Canvas
This module is used for visualizing the flomaps.
(fl1map->canvas fm conv) → canvas?
|
fm : fl1map? |
conv : procedure? |
Creates a canvas from given fl1map? using flonum? to color
conversion procedure provided.
7.6 Single-Channel 3D Flomaps
The following modules are just 3D versions of their 2D counterparts.
(struct fl1map3 (width height depth data))
|
width : fixnum? |
height : fixnum? |
depth : fixnum? |
data : flvector? |
Stores the 3D flomap data.
(make-fl1map3 width height depth) → fl1map3?
|
width : fixnum? |
height : fixnum? |
depth : fixnum? |
Creates an empty 3D flomap filled with 0.0.
(fl1map3-putpixel! fm x y z v) → void?
|
fm : fl1map3 |
x : fixnum? |
y : fixnum? |
z : fixnum? |
v : flonum? |
Sets the value at given coordinates.
(fl1map3-getpixel fm x y z [default]) → (or/c flonum? #f)
|
fm : fl1map3? |
x : fixnum? |
y : fixnum? |
z : fixnum? |
default : (or/c flonum? #f) = #f |
Gets the values stored at given coordinates or default value if out of bounds.
(fl1map3-clear! fm [v]) → void?
|
fm : fl1map3? |
v : flonum? = 0.0 |
Fills the fl1map3? with given value v.
7.7 Querying the 3D Flonum Map
This module contains procedures for querying the 3D flomap.
(fl1map3-min fm) → flonum?
|
fm : fl1map3 |
Returns the minimum value stored in the 3D flomap.
(fl1map3-max fm) → flonum?
|
fm : fl1map3 |
Returns the maximum value stored in the 3D flomap.
7.8 Mutating Operations on 3D Flomaps
This module defines the mutating operations on 3D flomaps.
(fl1map3-addpixel! fm x y z v) → void?
|
fm : fl1map3? |
x : fixnum? |
y : fixnum? |
z : fixnum? |
v : flonum? |
Adds given value to the value at given position.
(fl1map3-divpixel! fm x y z n) → void?
|
fm : fl1map3? |
x : fixnum? |
y : fixnum? |
z : fixnum? |
n : flonum? |
Divids the value at given position by the number specified.
(fl1map3-div! fm n) → void?
|
fm : fl1map3? |
n : flonum? |
Divides all values in the 3D flomap by given number.
(fl1map3-normalize! fm) → void?
|
fm : fl1map3? |
Normalizes all values in given 3D flomap to the \langle 0;1\rangle range.
7.9 Fine-grained Sampling of 3D Flomaps
This module contains procedures for sub-voxel querying 3D flomaps.
(fl1map3-sample fm x y z) → flonum?
|
fm : fl1map3? |
x : flonum? |
y : flonum? |
z : flonum? |
Uses bilinear interpolation for non-integer sampling coordinates.
(fl1map3-unit-sample fm x y z) → flonum?
|
fm : fl1map3? |
x : flomap? |
y : flomap? |
z : flomap? |
Uses bilinear interpolation for sampling the 3D flomap with coordinates
in the \langle 0;1\rangle range.
7.10 2D Cuts of 3D Flomaps
This module allows creating 2D cuts of 3D flomaps.
(fl1map3-cut | | fm3 | | | | | | | x0 | | | | | | | y0 | | | | | | | z0 | | | | | | | dx:x | | | | | | | dx:y | | | | | | | dx:z | | | | | | | dy:x | | | | | | | dy:y | | | | | | | dy:z) | | → | | fl1map? |
|
fm3 : fl1map3? |
x0 : flonum? |
y0 : flonum? |
z0 : flonum? |
dx:x : flonum? |
dx:y : flonum? |
dx:z : flonum? |
dy:x : flonum? |
dy:y : flonum? |
dy:z : flonum? |
Creates 2D fl1map? from given fl1map3? starting
at the specified x0, y0, z0 position. The
cutting plane x and y directions are specified in the remaining
arguments.