On this page:
7.1 Construction and Access
fl1map
make-fl1map
fl1map-putpixel!
fl1map-getpixel
7.2 Bilinear Sampling
fl1map-sample
fl1map-unit-sample
7.3 Querying
fl1map-min
fl1map-max
7.4 Operations
fl1map-addpixel!
fl1map-divpixel!
fl1map-div!
fl1map-normalize!
fl1map-transpose
7.5 Rendering to Canvas
fl1map->canvas
7.6 Single-Channel 3D Flomaps
fl1map3
make-fl1map3
fl1map3-putpixel!
fl1map3-getpixel
fl1map3-clear!
7.7 Querying the 3D Flonum Map
fl1map3-min
fl1map3-max
7.8 Mutating Operations on 3D Flomaps
fl1map3-addpixel!
fl1map3-divpixel!
fl1map3-div!
fl1map3-normalize!
7.9 Fine-grained Sampling of 3D Flomaps
fl1map3-sample
fl1map3-unit-sample
7.10 2D Cuts of 3D Flomaps
fl1map3-cut
8.10

7 RRLL: Single-Channel Flomaps

Dominik Pantůček <dominik.pantucek@trustica.cz>

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

 (require rrll/fl1map/core) package: rrll-fl1map

This module contains the 2D flonum? map structure and basic constructors and accessors.

struct

(struct fl1map (width height data))

  width : fixnum?
  height : fixnum?
  data : flvector?
Stores the single-channel flonum? map data.

procedure

(make-fl1map width height)  fl1map?

  width : fixnum?
  height : fixnum?
Creates fl1map? of specified size.

procedure

(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.

procedure

(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

 (require rrll/fl1map/sampling) package: rrll-fl1map

This module contains the bilinear sampling procedures for single-channel flonum? maps.

procedure

(fl1map-sample fm x y)  flonum?

  fm : fl1map?
  x : flonum?
  y : flonum?
Samples given fl1map?. The coordinates are in its dimensions.

procedure

(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

 (require rrll/fl1map/query) package: rrll-fl1map

This module contains procedures used for querying the flomaps.

procedure

(fl1map-min fm)  flonum?

  fm : fl1map?
Finds the minimum value in given fl1map?.

procedure

(fl1map-max fm)  flonum?

  fm : fl1map?
Finds the maximum value in given fl1map?.

7.4 Operations

 (require rrll/fl1map/ops) package: rrll-fl1map

This module contains mutating operations on 2D fl1map?s.

procedure

(fl1map-addpixel! fm x y v)  void?

  fm : fl1map?
  x : fixnum?
  y : fixnum?
  v : flonum?
Adds given value to the pixel value.

procedure

(fl1map-divpixel! fm x y n)  void?

  fm : fl1map?
  x : fixnum?
  y : fixnum?
  n : flonum?
Divides given pixel value by the number provided.

procedure

(fl1map-div! fm n)  void?

  fm : fl1map?
  n : flonum?
Divides all pixels by given number.

procedure

(fl1map-normalize! fm)  void?

  fm : fl1map?
Normalizes all the values of given fl1map?.

procedure

(fl1map-transpose fm)  fl1map?

  fm : fl1map?
Creates a new fl1map? which is a transposition of the given one.

7.5 Rendering to Canvas

 (require rrll/fl1map/render) package: rrll-fl1map

This module is used for visualizing the flomaps.

procedure

(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.

 (require rrll/fl1map/core3) package: rrll-fl1map

struct

(struct fl1map3 (width height depth data))

  width : fixnum?
  height : fixnum?
  depth : fixnum?
  data : flvector?
Stores the 3D flomap data.

procedure

(make-fl1map3 width height depth)  fl1map3?

  width : fixnum?
  height : fixnum?
  depth : fixnum?
Creates an empty 3D flomap filled with 0.0.

procedure

(fl1map3-putpixel! fm x y z v)  void?

  fm : fl1map3
  x : fixnum?
  y : fixnum?
  z : fixnum?
  v : flonum?
Sets the value at given coordinates.

procedure

(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.

procedure

(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

 (require rrll/fl1map/query3) package: rrll-fl1map

This module contains procedures for querying the 3D flomap.

procedure

(fl1map3-min fm)  flonum?

  fm : fl1map3
Returns the minimum value stored in the 3D flomap.

procedure

(fl1map3-max fm)  flonum?

  fm : fl1map3
Returns the maximum value stored in the 3D flomap.

7.8 Mutating Operations on 3D Flomaps

 (require rrll/fl1map/ops3) package: rrll-fl1map

This module defines the mutating operations on 3D flomaps.

procedure

(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.

procedure

(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.

procedure

(fl1map3-div! fm n)  void?

  fm : fl1map3?
  n : flonum?
Divides all values in the 3D flomap by given number.

procedure

(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

 (require rrll/fl1map/sampling3) package: rrll-fl1map

This module contains procedures for sub-voxel querying 3D flomaps.

procedure

(fl1map3-sample fm x y z)  flonum?

  fm : fl1map3?
  x : flonum?
  y : flonum?
  z : flonum?
Uses bilinear interpolation for non-integer sampling coordinates.

procedure

(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

 (require rrll/fl1map/cuts3) package: rrll-fl1map

This module allows creating 2D cuts of 3D flomaps.

procedure

(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.