Header menu logo Mibo

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

border x y width height content section

Full Usage: border x y width height content section

Parameters:
    x : int
    y : int
    width : int
    height : int
    content : 'T
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Draws a hollow rectangle (border).

x : int
y : int
width : int
height : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

center w h f parent

Full Usage: center w h f parent

Parameters:
Returns: GridSection2D<'T>
Modifiers: inline
Type parameters: 'T

Web Analog: margin: auto. Centers a block of a specific size within the current section.

w : int
h : int
f : GridSection2D<'T> -> GridSection2D<'T>
parent : GridSection2D<'T>
Returns: GridSection2D<'T>

checker odd even section

Full Usage: checker odd even section

Parameters:
Returns: GridSection2D<'T>

Fills the section with a checkerboard pattern.

odd : 'T
even : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

checkerBorder x y width height odd even section

Full Usage: checkerBorder x y width height odd even section

Parameters:
    x : 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.

x : int
y : int
width : int
height : int
odd : 'T
even : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

circle cx cy radius filled content section

Full Usage: circle cx cy radius filled content section

Parameters:
    cx : 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.

cx : int
cy : int
radius : int
filled : bool
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

clear x y width height section

Full Usage: clear x y width height section

Parameters:
    x : int
    y : int
    width : int
    height : int
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Clears (sets to ValueNone) a rectangular area.

x : int
y : int
width : int
height : int
section : GridSection2D<'T>
Returns: GridSection2D<'T>

corners x y width height content section

Full Usage: corners x y width height content section

Parameters:
    x : int
    y : int
    width : int
    height : int
    content : 'T
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Draws only the four corners of a rectangle.

x : int
y : int
width : int
height : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

fill x y width height content section

Full Usage: fill x y width height content section

Parameters:
    x : int
    y : int
    width : int
    height : int
    content : 'T
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Fills a rectangular area with content.

x : int
y : int
width : int
height : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

flowX step stamps parent

Full Usage: flowX step stamps parent

Parameters:
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.

step : int
stamps : (GridSection2D<'T> -> GridSection2D<'T>) seq
parent : GridSection2D<'T>
Returns: GridSection2D<'T>

flowY step stamps parent

Full Usage: flowY step stamps parent

Parameters:
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.

step : int
stamps : (GridSection2D<'T> -> GridSection2D<'T>) seq
parent : GridSection2D<'T>
Returns: GridSection2D<'T>

generate x y width height generator section

Full Usage: generate x y width height generator section

Parameters:
    x : 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.

x : int
y : int
width : int
height : int
generator : int -> int -> 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

iter x y width height action section

Full Usage: iter x y width height action section

Parameters:
    x : 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.

x : int
y : int
width : int
height : int
action : int -> int -> 'T voption -> unit
section : GridSection2D<'T>
Returns: GridSection2D<'T>

line x1 y1 x2 y2 content section

Full Usage: line x1 y1 x2 y2 content section

Parameters:
    x1 : int
    y1 : int
    x2 : int
    y2 : int
    content : 'T
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Draws a line using Bresenham's line algorithm.

x1 : int
y1 : int
x2 : int
y2 : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

map x y width height mapping section

Full Usage: map x y width height mapping section

Parameters:
    x : 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.

x : int
y : int
width : int
height : int
mapping : 'T -> 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

padding n f parent

Full Usage: padding n f parent

Parameters:
Returns: GridSection2D<'T>
Modifiers: inline
Type parameters: 'T

Web Analog: padding. Creates a sub-section that is shrunk by 'n' on all sides.

n : int
f : GridSection2D<'T> -> GridSection2D<'T>
parent : GridSection2D<'T>
Returns: GridSection2D<'T>

paddingEx left top right bottom f parent

Full Usage: paddingEx left top right bottom f parent

Parameters:
Returns: GridSection2D<'T>
Modifiers: inline
Type parameters: 'T

Creates a sub-section with explicit padding for each side.

left : int
top : int
right : int
bottom : int
f : GridSection2D<'T> -> GridSection2D<'T>
parent : GridSection2D<'T>
Returns: GridSection2D<'T>

polygon points filled content section

Full Usage: polygon points filled content section

Parameters:
    points : (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).

points : (int * int)[]
filled : bool
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

rect x y width height borderContent fillContent section

Full Usage: rect x y width height borderContent fillContent section

Parameters:
    x : int
    y : int
    width : int
    height : int
    borderContent : 'T
    fillContent : 'T
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Draws a filled rectangle with a border.

x : int
y : int
width : int
height : int
borderContent : 'T
fillContent : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

repeatX x y count content section

Full Usage: repeatX x y count content section

Parameters:
    x : int
    y : int
    count : int
    content : 'T
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Repeats content horizontally 'count' times starting at (x, y).

x : int
y : int
count : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

repeatY x y count content section

Full Usage: repeatY x y count content section

Parameters:
    x : int
    y : int
    count : int
    content : 'T
    section : GridSection2D<'T>

Returns: GridSection2D<'T>

Repeats content vertically 'count' times starting at (x, y).

x : int
y : int
count : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

replace oldContent newContent section

Full Usage: replace oldContent newContent section

Parameters:
Returns: GridSection2D<'T>

Replaces all occurrences of 'oldContent' with 'newContent'. Uses structural equality (=).

oldContent : 'T
newContent : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

replaceScatter oldContent newContent probability seed section

Full Usage: replaceScatter oldContent newContent probability seed section

Parameters:
    oldContent : '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.

oldContent : 'T
newContent : 'T
probability : float32
seed : int
section : GridSection2D<'T>
Returns: GridSection2D<'T>

run f grid

Full Usage: run f grid

Parameters:
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.

f : GridSection2D<'T> -> GridSection2D<'T>

The layout function to execute.

grid : CellGrid2D<'T>

The grid to modify.

Returns: CellGrid2D<'T>

scatter count seed content section

Full Usage: scatter count seed content section

Parameters:
    count : 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.

count : int
seed : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

scatterBorder x y width height count seed content section

Full Usage: scatterBorder x y width height count seed content section

Parameters:
    x : 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.

x : int
y : int
width : int
height : int
count : int
seed : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

scatterLine x1 y1 x2 y2 count seed content section

Full Usage: scatterLine x1 y1 x2 y2 count seed content section

Parameters:
    x1 : 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.

x1 : int
y1 : int
x2 : int
y2 : int
count : int
seed : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

scatterStamp count seed stamp section'

Full Usage: scatterStamp count seed stamp section'

Parameters:
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.

count : int
seed : int
stamp : GridSection2D<'T> -> GridSection2D<'T>
section' : GridSection2D<'T>
Returns: GridSection2D<'T>

section x y f parent

Full Usage: section x y f parent

Parameters:
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.

x : 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>

set x y content section

Full Usage: set x y content section

Parameters:
Returns: GridSection2D<'T>

Sets a single cell at (x, y).

x : int
y : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

setIfEmpty x y content section

Full Usage: setIfEmpty x y content section

Parameters:
Returns: GridSection2D<'T>

Sets a cell only if it is currently empty (ValueNone). Useful for non-destructive decoration or filling gaps.

x : int
y : int
content : 'T
section : GridSection2D<'T>
Returns: GridSection2D<'T>

Type something to start searching.