Layout Module
A fluent DSL for composing layouts. All operations return the modified section to allow chaining (pipeline style).
Functions and values
| Function or value |
Description
|
Full Usage:
border x y width height content section
Parameters:
int
y : int
width : int
height : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Draws a hollow rectangle (border).
|
Full Usage:
center w h f parent
Parameters:
int
h : int
f : GridSection2D<'T> -> GridSection2D<'T>
parent : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Web Analog: margin: auto. Centers a block of a specific size within the current section.
|
Full Usage:
checker odd even section
Parameters:
'T
even : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Fills the section with a checkerboard pattern.
|
Full Usage:
checkerBorder x y width height odd even section
Parameters:
int
y : int
width : int
height : int
odd : 'T
even : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Applies a checkerboard pattern only to the border of a rectangle.
|
Full Usage:
circle cx cy radius filled content section
Parameters:
int
cy : int
radius : int
filled : bool
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Draws a circle using the integer-only Midpoint Circle Algorithm (Bresenham's). Significantly faster than distance-based checks.
|
Full Usage:
clear x y width height section
Parameters:
int
y : int
width : int
height : int
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Clears (sets to ValueNone) a rectangular area.
|
Full Usage:
corners x y width height content section
Parameters:
int
y : int
width : int
height : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Draws only the four corners of a rectangle.
|
Full Usage:
fill x y width height content section
Parameters:
int
y : int
width : int
height : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Fills a rectangular area with content.
|
Full Usage:
flowX step stamps parent
Parameters:
int
stamps : (GridSection2D<'T> -> GridSection2D<'T>) seq
parent : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Web Analog: flex-direction: row. Places a sequence of stamps horizontally with a fixed step between them.
|
Full Usage:
flowY step stamps parent
Parameters:
int
stamps : (GridSection2D<'T> -> GridSection2D<'T>) seq
parent : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Web Analog: flex-direction: column. Places a sequence of stamps vertically with a fixed step between them.
|
Full Usage:
generate x y width height generator section
Parameters:
int
y : int
width : int
height : int
generator : int -> int -> 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Fills a rectangular area by calling a generator function for each cell. Useful for procedural content (noise, auto-tiling) where the content depends on position.
|
Full Usage:
iter x y width height action section
Parameters:
int
y : int
width : int
height : int
action : int -> int -> 'T voption -> unit
section : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Iterates over a rectangular area, providing read access to the cells. Useful for analyzing neighbors or debugging.
|
Full Usage:
line x1 y1 x2 y2 content section
Parameters:
int
y1 : int
x2 : int
y2 : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Draws a line using Bresenham's line algorithm.
|
Full Usage:
map x y width height mapping section
Parameters:
int
y : int
width : int
height : int
mapping : 'T -> 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Transforms existing content in a rectangular area. Empty cells are skipped.
|
Full Usage:
padding n f parent
Parameters:
int
f : GridSection2D<'T> -> GridSection2D<'T>
parent : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Web Analog: padding. Creates a sub-section that is shrunk by 'n' on all sides.
|
Full Usage:
paddingEx left top right bottom f parent
Parameters:
int
top : int
right : int
bottom : int
f : GridSection2D<'T> -> GridSection2D<'T>
parent : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Creates a sub-section with explicit padding for each side.
|
Full Usage:
polygon points filled content section
Parameters:
(int * int)[]
filled : bool
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Draws a polygon from a set of vertices. Filled polygons use a scanline algorithm (scan-conversion).
|
Full Usage:
rect x y width height borderContent fillContent section
Parameters:
int
y : int
width : int
height : int
borderContent : 'T
fillContent : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Draws a filled rectangle with a border.
|
Full Usage:
repeatX x y count content section
Parameters:
int
y : int
count : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Repeats content horizontally 'count' times starting at (x, y).
|
Full Usage:
repeatY x y count content section
Parameters:
int
y : int
count : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Repeats content vertically 'count' times starting at (x, y).
|
Full Usage:
replace oldContent newContent section
Parameters:
'T
newContent : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Replaces all occurrences of 'oldContent' with 'newContent'. Uses structural equality (=).
|
Full Usage:
replaceScatter oldContent newContent probability seed section
Parameters:
'T
newContent : 'T
probability : float32
seed : int
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Probabilistically replaces occurrences of 'oldContent' with 'newContent'. Perfect for "weathering" or adding visual noise to large surfaces.
|
Full Usage:
run f grid
Parameters:
GridSection2D<'T> -> GridSection2D<'T>
-
The layout function to execute.
grid : CellGrid2D<'T>
-
The grid to modify.
Returns: CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
The entry point for the layout DSL. Lifts a Grid into a Section, executes the layout function, and returns the modified Grid.
|
Full Usage:
scatter count seed content section
Parameters:
int
seed : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Randomly places 'count' items within the section. Uses a deterministic seed for reproducible results.
|
Full Usage:
scatterBorder x y width height count seed content section
Parameters:
int
y : int
width : int
height : int
count : int
seed : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Scatters content randomly on the four edges of a rectangle. Ideal for adding "noise" (vines, cracks, dirt) to room boundaries.
|
Full Usage:
scatterLine x1 y1 x2 y2 count seed content section
Parameters:
int
y1 : int
x2 : int
y2 : int
count : int
seed : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Scatters content randomly along a 2D line. Useful for decorating ledges, paths, or wires.
|
Full Usage:
scatterStamp count seed stamp section'
Parameters:
int
seed : int
stamp : GridSection2D<'T> -> GridSection2D<'T>
section' : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Randomly applies a stamp 'count' times within the section. Use this to populate a level with complex multi-tile objects.
|
Full Usage:
section x y f parent
Parameters:
int
-
Relative X position.
y : int
-
Relative Y position.
f : GridSection2D<'T> -> GridSection2D<'T>
-
The layout function to run inside the new section.
parent : GridSection2D<'T>
Returns: GridSection2D<'T>
Modifiers: inline Type parameters: 'T |
Creates a sub-section (nested view) at the specified relative coordinates. Useful for defining reusable components (e.g., a "Box" or "Control") that don't know their absolute position.
|
Full Usage:
set x y content section
Parameters:
int
y : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Sets a single cell at (x, y).
|
Full Usage:
setIfEmpty x y content section
Parameters:
int
y : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>
|
Sets a cell only if it is currently empty (ValueNone). Useful for non-destructive decoration or filling gaps.
|
Mibo