Element · the document

region

An area of a divided tile. Name the lines that bound it, then drop one or more fill points, like a paint bucket: the region is everything a fill point reaches without crossing a line. Elements act inside a region with at=.

A tile divided by two lines into three regions: a stone floor at the back, a grassy bank in the middle, a pool in front.
Two lines make three regions, each its own surface: floor at=yard, grass at=bank on the dirt, and water over the pool the dirt is pinned down in. From docs/elements/demo/region.dtile.

Writing it

line shore wobble="5dmm" { through "wsw" "e" }
region pool { boundedBy shore; fill "(0.5sq, 0.75sq)" }
region bank { boundedBy shore; fill "(0.5sq, 0.25sq)" }
region reach { within "5dmm" of=shore }     // a strip beside the line
region dry { except pool }                  // everything but the pool
stack {
    base
    dirt { pin top="$waterBedHeight" at=pool }   // a region is a place a pin holds
    water                                     // fills its area up to its top
    grass at=bank                             // and where a coat grows, off the wet ground
}

Try it

The tile this source builds, from above
dharmatiles version="1.0.0"

// Lengths carry a unit: `dmm` is a design millimetre at the 35 mm square (it prints smaller on
// OpenLOCK), `sq` is a square.  The wobble is 6dmm, and the band round the line is 7dmm.
tile size="1x1" seed=4 {
    line stream wobble="6dmm" { through "(0sq, 0.5sq)" "(1sq, 0.5sq)" }
    region band { within "7dmm" of=stream }
    stack {
        base
        dirt
        grass at=band
    }
}
A region needs no fill point when it is a band: within "7dmm" of=stream is everything within 7 design millimetres of the line, and the grass follows it.
The tile this source builds, from above
dharmatiles version="1.0.0"

// A line with a wobble: the shore of a pond.  The line goes through two points and may wander
// up to 5dmm off the straight path between them; the seed decides how.
tile size="1x1" seed=97 {
    line shore wobble="5dmm" { through "(0sq, 2sq/3)" "(1sq, 0.5sq)" }
    region pool { boundedBy shore; fill "(0.5sq, 0.85sq)" }
    region bank { boundedBy shore; fill "(0.5sq, 0.2sq)" }
    stack {
        base
        dirt
        grass at=bank
    }
}
Two regions, one line: boundedBy shore says which side of it each fill point is on.

Reference

WrittenTakesDefaultWhat it does
region NAMEa name—Its name, for at=. Required.
boundedByline names—The lines that bound it.
filla point—A point inside it, "(across, down)" with units or a point's name; a half may be a range, drawn once from the tile seed like a line's points (demo/line-drawn.dtile). Several fill points on different sides of a line join those areas into one region.
within LENGTH of=PLACEa length, a place—Everything within that distance of a point, a line or a region: a disc round a point, a strip beside a line, a ring round a region (the region itself included). A length in dmm or sq scales with the system. A range in it, within "[10dmm .. 20dmm]" of=northEdge, draws the depth along the place: masses 6 to 15 design millimetres long, each as deep as the range draws it (the same for the region and place whatever the seed), the middle of the range at both ends so runs butt.
exceptregion names—Takes those regions out. A region that only excepts starts from the whole tile.

Notes

The whole tile is the default area, so an undivided tile needs no region. The words add together: the fills, then each within, then except takes away. A region is flat, a footprint and nothing else; it is also a frame (every thing makes a region): $region, $tile and parent() name regions in a formula, and x($region, sq), d($region, %) and a($region, %) measure in one. how high a body is over it is the body's top and pin. Bodies, grass and scatter take a region with at=; a point or a line is refused (dt::type). A region whose fill points all lie on its lines is an error.

Seen from the language

The guide pages that use region: Regions.