The tile language · guide

Units and kinds

Every length is written with its unit; dmm is 1/35 of a square and scales with the system.

The result

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
    }
}
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 7dmm.

Say it plainly

A length is a number and a unit: 8dmm, 2sq, 0.45mm. An angle is a number and deg or rad. Everything else, a count or a share, is a plain number.

Because most sizes are in dmm, a tile written once builds for either system: at OpenLOCK’s smaller square the same stone is smaller, and nothing needs rewriting. Printed units, mm and layer, never scale, for a printer does not.

The rules

Every length is written with its unit

The rule for an author is one sentence: write every length with its unit; dmm is the design millimetre, 1/35 of a square, and scales with the system.

Nothing is guessed. A length is a number and a unit; an angle is a number and deg or rad; everything else (a count, a density, a share, a fraction) is a plain number.

UnitMeasuresIsScales with the system?
sqlengthone square: 35 mm on DungeonBlocks, 25.4 mm on OpenLOCKyes: it is the grid
dmmlengtha design millimetre: exactly 1/35 of a square, so 1 mm on DungeonBlocks and about 0.73 mm on OpenLOCKyes, with the grid
mm, inlengtha printed millimetre, a printed inch: what calipers and the slicer measureno
layerlengthone printed layer: 0.2 mm on the default printerno: it is the printer's
deg, radangledegrees; radians (pi is a number word, so a turn is 360deg or 2 pi rad)no
%plain fraction50% is 0.5 everywhere (cover="100%", buried="20%..50%")no

Sizes in the library are written in dmm, so at OpenLOCK's 25.4 mm square a 7dmm wall prints 5.08 mm thick and a 4.5dmm leaf 3.27 mm long, and a stone that must fit a 28 mm miniature is written in mm. Write sq or a share to follow the grid exactly. Densities (perSquare=45) follow the square; counts, words and switches never change.

Sizes in dmm and sq scale; the printer’s floors never do

Every size written in dmm or sq scales with the system, like a photocopy. The hidden printability floors never shrink: they come from the printer profile, library/printers/default.dtile, written in printed units:

dharmatiles version="1.0.0"

printer default {
    line     "0.45mm"       // one extruded line: the thinnest wall that prints
    layer    "0.2mm"        // one layer
    overhang "55deg"        // what every element aims for, degrees from vertical
    steepest "65deg"        // small patches up to here
    gap      "0.2mm"        // the narrowest gap that stays open
}

Other profiles sit beside it in library/printers/ (fine, and a machine by brand and model, bambu/x1c), and your own in a printers/ folder beside your tiles; --printer chooses one. A profile holds the printer's floors, and for a machine its bed and filaments (see Printers): the base system is chosen with --system, and edge and corner rounding belong to materials. Elements apply the floors after scaling, so a scaled blade, leaf or branch is never thinner than what prints.

A unit goes right after its number and multiplies it

  • A unit goes right after its number and multiplies it: 2layer is 0.4 mm on the default printer, 0.5sq is half a square, 2 pi rad is a full turn. House style writes no space (4.5dmm, as 50% already is); a spaced 4.5 dmm still reads.
  • A digit followed by letters is always a number and a unit, since plain names can't start with a digit. An unknown suffix, 2foot, is dt::unit: “foot is not a unit”, listing the units.
  • A bare 0 is the same in every unit and fits any of them.
  • As a coordinate's second argument a unit divides instead: d($region, mm) is the distance in from the edge counted in printed millimetres, a plain number (squares and points).
  • % on its own is a plain fraction. It is a length only inside a point, "(50%, 2sq)", where the frame gives it a size, and a coordinate's unit divides by the frame's own size: x($region, %) is 0 at the region's west edge and 1 at its east. An angle is always deg or rad: polar($tile, 40%, 90deg).
  • Printer files take printed units only: line "0.45mm", layer "0.2mm", overhang "55deg". sq, dmm and layer have no meaning there and are refused.

Errors this page explains

Next

Next: kinds, how lengths, angles and plain numbers are checked apart.