Writing it
dirt { scatter perSquare=40 { pebble } } // inside a surface: lands on it
scatter at=pool count=2 { rock size="6dmm .. 10dmm" } // two rocks in the pool
scatter at="foot(cliff)" perSquare=55 reach="4dmm" { stone } // scree at the cliff's foot
scatter perSquare=3 { stone weight=3; boulder } // a mix, three stones to a boulder
scatter perSquare=3 { rock size="4dmm .. 8dmm" weight=3; flower; tree top="$bottom + [22dmm .. 30dmm]" weight=1 } // a glade
A scatter needs exactly one of count and perSquare. reach needs at=foot(…). A scatter holds rocks, flowers and trees, alone or mixed, and a let whose body is one such thing written bare (scatter count=3 { boulder size="7dmm .. 10dmm" }: the child's properties are the definition's params, a tree's top= is its height, weight= is its share, and a place word on the child is dt::place; see demo/scatter-definition.dtile). With several children, each child's weight= is its share of the mix (default: equal), whatever the kind. A mix is placed with one gap between every two things (default: the first child's own: 1.5dmm for a rock, 1dmm for a tree, 0.5dmm for a flower), the things that stand alike together and the largest first: trees (laid out together; an error names how many fit when not all do), then rocks clear of the crowns, then flowers on dry ground clear of both. A mix is not gathered at a foot; at= a region or a line works as for any scatter. A scatter is built where it is listed: a dirt listed after it lies on its rocks and banks against its trunks, and grass listed after it grows round it. Every scattered thing keeps inside the tile and clear of other solids: it is nudged inward, never clipped.
How the places fall
pattern says how a scatter's places fall; count or perSquare says how many; the same placement and the same things follow whichever it is.
- spaced
- The default. Things keep
gapand the room each takes between them, the largest first. - clumped
- The things gather in
clumps(to a square, a range): each clump draws how far it reaches (spread, a range) and its places fade from the middle outward. Things are kept apart within a clump, as in a spaced scatter; ask for moreperSquarethan the clumps hold and the rest are left out, never crowded. - cover
- A dense cover for thousands of things a square. Nothing is checked among the things, so they touch and overlap, but they fall evenly: each place is the next point of an evenly spreading sequence (shifted by the seed), so every patch of the square holds its share and nothing heaps up or leaves wide bare ground; ask for
pattern=clumpedto heap them. Each keeps clear of what already stands only bygap, which under a cover is0unless written, measured from the real outline of what stands (the footprintnearreads, not a disc round its bounds): the things lie against a rock, a wall or a trunk on every side, touching it and never in it, and a place that falls where nothing could stand (in a rock, off the area) is not lost but thrown again at the next point of the sequence, so the count holds (a spaced or clumped scatter keeps the disc of each rock) (a spaced scatter'sgapis the thing's own,1.5dmmfor a rock). Writegap=to leave a bare band, orthinin anearblock to make a bare ring. The cost grows with the number of things, not with the square of it.
cover is the share of places that keep a thing ("85%"); clearings (to a square, a range) are round patches left bare, clearingWidth wide each. Both mean what they mean on grass, and work with every pattern. perSquare is the density where there are things: a cover of 85% with clearings leaves less than perSquare on the whole square.
dharmatiles version="1.0.0"
tile size="1x1" seed=5 {
stack {
base
dirt
rock at="(0.5sq, 0.5sq)" size="9dmm"
scatter perSquare=300 pattern=cover cover="85%" clearings=3 clearingWidth="6dmm .. 9dmm" {
pebble size="1.2dmm .. 2.2dmm"
near of=rock reach="4dmm .. 9dmm" height="1.3 .. 1.6" thin="30%"
}
}
}
Things that answer to what is near
A near block changes the things of a scatter that stand within reach of something already in the tile. of names what: rock, wall, tree, cliff, standing (those four) or water (the water's edge); a name that is none of them is refused at the line. The scatter measures each thing's distance to the nearest of it, from the solids of that kind the stack built before the scatter (the footprint where each meets the ground, so earlier scatters' items count, while the dirt's own clods and pebbles, which are the ground, and this scatter's own things do not); the thing is changed when that distance is under its reach, which each thing draws from the range, so a range is a soft edge: reach="6dmm .. 12dmm" changes every thing within 6dmm, none beyond 12dmm and a fading share between.
What changes is height (a range, how many times taller the thing stands: only things that can grow taller take it, which are rocks and flowers) and thin (the share of things within reach left out). One scatter has one near: two behaviours, say taller by a rock and bare by water, are two scatters over the same area. A scatter at=foot(…) gathers its own way and takes no pattern, cover, clearings or near.
dharmatiles version="1.0.0"
tile size="1x1" seed=3 {
stack {
base
dirt
rock at="(0.7sq, 0.3sq)" size="8dmm"
scatter perSquare=24 pattern=clumped clumps="2 .. 3" spread="5dmm .. 8dmm" {
flower size="4dmm .. 6dmm" petals=5 centre="1.2dmm" stem="1dmm" dome="1dmm" petal="0.5dmm"
near of=rock reach="6dmm .. 12dmm" height="1.3 .. 1.6"
}
}
}
Variants: built once, copied
Left alone, every thing a scatter places is its own draw: its own size and its own shape, each built once. A cover of two thousand pebbles is two thousand builds. variants=K says the things are drawn as one of K variants instead: each placement picks a variant, each variant is built once, and every placement of it is that body copied, turned about its own axis and set down where it stands. The pebbles still fall as the pattern says and still turn every which way; there are only K shapes among them, so the build makes K bodies and copies the rest.
- What it saves
- The work of building. A copy costs a turn and a move, so a cover with
variants=12builds twelve pebbles however many it places. The final union still holds every copy and the gate still checks the whole mesh, so the size of the result and the time of the union do not change. The build record says how many bodies a build made, copied and read (things). - What a variant is
- One draw of the thing, from a stream of its own keyed by the thing and the variant's number, so every copy of a variant is the same draw, and asking for more variants moves none of the first. A rock's variant is its placement (a stone, or a cluster of stones), each stone grained from the variant's seed; a flower's is its size and petals.
- What a copy cannot do
- A rock a
nearblock stands taller, or that has atop=, is another shape and is built as its own. Only rocks are copied. Flowers are built where they stand (a flower built at the origin and moved is the same flower to a hair's breadth, and that hair moved the repair counts of a meadow's union), and trees are grown where they stand (their sink into the ground, their footing and theirtop=read the tile):variantson either still draws only that many shapes, but builds each placement where it stands. - Unset
- Every placement is its own draw, as before; a tile that does not write
variantsbuilds the same bytes.
dharmatiles version="1.0.0"
tile size="1x1" seed=5 {
stack {
base
dirt
scatter perSquare=300 pattern=cover variants=12 {
pebble size="1.2dmm .. 2.2dmm"
}
}
}
Reference
at= region, line, foot(…)Controls
| Control | Takes | Default | What it does |
|---|---|---|---|
count | count, 0 to 10000, or a range, or a weighted range | not counted: perSquare says how many | how many, in total |
perSquare | per square, a number, a range or a weighted range | — | how many per square of the area, or of length along a line |
pattern | word | spaced | how the places fall: kept apart, in clumps, or a dense cover
|
clumps | per square, 0 to 200, or a range, or a weighted range | 3 | with pattern=clumped: how many clumps to a square |
spread | length (dmm), over 0, or a range, or a weighted range | 3dmm .. 8dmm | with pattern=clumped: how far from its middle a clump reaches, drawn for each clump |
reach | length (dmm) | where the rocks stand: a foot's or a line's own | with at=foot(…): how far out from the foot; with at= a line: how far either side of it |
cover | percent, 0% to 100% | 100% | share of the places that keep a thing |
clearings | per square, 0 to 20, or a range, or a weighted range | 0 | round patches left bare, to a square |
clearingWidth | length (dmm), over 0, or a range, or a weighted range | 6dmm .. 14dmm | how wide a clearing is, drawn for each |
variants | count, 1 to 256 | every placement is its own draw | draw each thing as one of this many variants, each built once and copied turned and placed |
near | group | — | things that answer to what is already in the tile: taller, or fewer, within reach of it |
near of | word | — | what the things answer to Required.
|
near reach | length (dmm), over 0, or a range, or a weighted range | 6dmm .. 12dmm | how far out from it a thing is changed, drawn for each: a range is a soft edge |
near height | number, over 0, or a range, or a weighted range | 1 | how many times taller a thing within reach stands |
near thin | percent, 0% to 100% | 0% | the share of things within reach that are left out |
gap | length (dmm) | — | least space between neighbours |
In the library
1x1-cliff-corner.dtilelib:tiles/cliffs/1x1-cliff-corner.dtile · Open in the editor1x1-cliff-mound.dtilelib:tiles/cliffs/1x1-cliff-mound.dtile · Open in the editor1x1-cliff-spire.dtilelib:tiles/cliffs/1x1-cliff-spire.dtile · Open in the editor1x1-cliff.dtilelib:tiles/cliffs/1x1-cliff.dtile · Open in the editor2x1-cliff-blocks.dtilelib:tiles/cliffs/2x1-cliff-blocks.dtile · Open in the editor2x1-cliff-escarpment.dtilelib:tiles/cliffs/2x1-cliff-escarpment.dtile · Open in the editor2x1-cliff-needles.dtilelib:tiles/cliffs/2x1-cliff-needles.dtile · Open in the editor2x1-cliff-rubble.dtilelib:tiles/cliffs/2x1-cliff-rubble.dtile · Open in the editor2x1-cliff.dtilelib:tiles/cliffs/2x1-cliff.dtile · Open in the editor2x2-cliff-canyon.dtilelib:tiles/cliffs/2x2-cliff-canyon.dtile · Open in the editor2x2-cliff-corner.dtilelib:tiles/cliffs/2x2-cliff-corner.dtile · Open in the editor2x2-cliff-massif.dtilelib:tiles/cliffs/2x2-cliff-massif.dtile · Open in the editor2x2-cliff-plateau.dtilelib:tiles/cliffs/2x2-cliff-plateau.dtile · Open in the editor1x1-grass-flowers.dtilelib:tiles/ground/1x1-grass-flowers.dtile · Open in the editor1x1-grass-tree.dtilelib:tiles/ground/1x1-grass-tree.dtile · Open in the editor2x1-tree-row.dtilelib:tiles/ground/2x1-tree-row.dtile · Open in the editor2x2-glade.dtilelib:tiles/ground/2x2-glade.dtile · Open in the editor1x1-water+grass-angle.dtilelib:tiles/water/1x1-water+grass-angle.dtile · Open in the editor1x1-water+grass-corner.dtilelib:tiles/water/1x1-water+grass-corner.dtile · Open in the editor1x1-water+grass-tree.dtilelib:tiles/water/1x1-water+grass-tree.dtile · Open in the editor1x1-water+grass.dtilelib:tiles/water/1x1-water+grass.dtile · Open in the editor1x1-water+soil-angle.dtilelib:tiles/water/1x1-water+soil-angle.dtile · Open in the editor1x1-water+soil-corner.dtilelib:tiles/water/1x1-water+soil-corner.dtile · Open in the editor1x1-water+soil.dtilelib:tiles/water/1x1-water+soil.dtile · Open in the editor1x1-water-u+grass.dtilelib:tiles/water/1x1-water-u+grass.dtile · Open in the editor1x1-water-u+soil.dtilelib:tiles/water/1x1-water-u+soil.dtile · Open in the editor
Generated from dharmatiles elements scatter by cargo xtask docs.
Notes
- at=foot(cliff)
- Gathers at the foot of that kind of thing:
cliff,wall,rockortree. Scattered at a cliff's foot, rocks take the cliff's rock: that is scree. - at=line
- Spreads along a drawn line, an edge or an edge path, within
reacheither side of it (default5dmm), to the ends of the line rounded.perSquarecounts the line's length in squares. It builds for rocks, flowers and trees alike:scatter at=road count=3 reach="3dmm" { tree top="$bottom + [26dmm .. 32dmm]" }. A single thing at a line is refused (a line has no one place on it); a scatter is how several stand along one. - trees
- A scatter of trees places every crown clear of the others (centres at least both crown radii and
gapapart, default1dmm), each trunk a crown radius in from the tile edge and clear of what already stands, then grows them one after another, each from its own seed. A tree is a heavy build: ask for few. If the crowns cannot all fit it is an error naming how many do, never fewer trees without a word. - count, perSquare
- Take a weighted range (of plain numbers):
perSquare="low(2..8, 3)". Each whole number of a range is as likely as any other. See weighted ranges. - inside a surface
- A scatter written inside
dirtorgrassis placed on that surface, in its area.
A scatter is a region of its own, its at= area (or the tile), and the things it places are its children: a tree in a scatter has the scatter, then the tile, as parents. A single thing never takes a count: tree count=3 is an error whose help says to use a scatter. See placement in the language guide.
Seen from the language
The guide pages that use scatter: The stack, Placement and scatter, Values and ranges, Weighted ranges, Names, Seeds, Things and layers, Worked tiles.
