The tile language · guide

Lines

A line runs through points as one smooth curve; it divides a tile into regions, or is a strip things follow.

The result

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
    }
}
A shore through two points, wandering up to 5dmm off the straight path between them. Drag wobble, or roll the seed: the points stay where they are written.

Say it plainly

A line is the points it goes through, in order. Give it a wobble and it wanders a little off them; give it a width and it is a strip that dirt, grass or a scatter fills.

Where a line leaves the tile it has to meet the next tile, so it may cross a square’s edge only at a seam: a corner, a third, a half or two thirds. The program says which seam is nearest, and can move the point for you.

The rules

A line runs through points

A drawn line runs through points. With a width it is a strip, and a dirt, grass or cliff at= it fills the strip (within half the width, wobble included), and a scatter reaches half the width either side unless it writes reach. A surface along a line with no width, or along a tile edge, is dt::type. wobble lets it wander up to that far off its points.

line trail width="9dmm" wobble="3dmm" { through south "(0.65sq, 0.5sq)" north }

An element along a drawn line takes side=left, right or centre (the default), as you walk the line. side= along a tile edge is an error, because on an edge a wall always stands inside.

A line is one smooth curve through its points

A line is one smooth curve through the points you write: a cubic Bézier from each point to the next, its handles 0.4 of the chord long, and inside the line a point’s direction is the chord of its two neighbours. Walls, strips, regions, scatters and cliffs all follow that one curve. Where an end meets the edge of the tile, only its direction is decided: an end exactly on a side leaves along the side’s normal, and an end exactly on a tile corner leaves along the corner’s bisector, 45° to both sides. Each end is decided on its own. A square corner partway along a bigger tile’s side is on a side, so it leaves square to it. Two tiles that meet at the same seam therefore meet in the same direction; how much each is still bending there is not matched.

line shore { through "(0sq, 0.5sq)" "(0.5sq, 1sq)" }          // square to the west side, square to the south side
line knee  { through "(0sq, 0.5sq)"
                     "(0.4sq, 0.4sq)" corner=#true
                     "(1sq, 0.5sq)" }                               // a sharp knee on purpose
line bend  { through "(0sq, 0.5sq)"
                     "(0.5sq, 0.7sq)" heading="30deg" pull=0.6
                     "(1sq, 0.5sq)" }                               // leave this point at 30deg, hold the direction 0.6 as far
line free  ends=free { through "(0.2sq, 0.5sq)" "(0.8sq, 0.3sq)" "(1sq, 0.5sq)" }   // the ends take their direction from the next point
line run   curve=straight { through "(0sq, 0.5sq)" "(1sq, 2sq/3)" }  // straight runs, exactly as the points say
  • corner=#true on a through of one point makes a sharp knee there.
  • heading= on a through of one point is the way the line goes through it: an angle with its unit, 0deg east, 90deg south, like polar(). It is allowed on any point, and an end given one leaves that way instead of square.
  • pull= on a through of one point is how far the curve holds its direction there, a share of the usual (1; from 0 to 3).
  • ends=free on a line lets both ends take their direction from the neighbouring points. ends=square is the default.
  • curve=straight on a line draws straight runs between the points; curve=smooth is the default.

Errors this page explains

Next

Next: seams, where a line may cross a square’s edge.