api.terrain
TerrainApi
Reading the terrain: the tileset's paintable types, the ISOM lattice, flood regions,
blend candidates and the symmetry mode. Painting goes through document.edit.
- types
- isomTypes
- hasIsom
- checkIsom
- tileInfo
- terrainAt
- color
- terrainColor
- heightOf
- diamondAt
- isDiamond
- diamondsIn
- floodRegion
- blendCandidates
- flatGroupOf
- symmetry
- setSymmetry
- symmetryAvailable
- mirror
- mirrorPoint
- active
- setActive
Members
types
types(): TerrainType[];
Paintable flat terrains of the open map's tileset (empty without the graphics).
hasIsom
hasIsom(): boolean;
Whether the open map carries an ISOM section the isometric brush can work on.
checkIsom
checkIsom(): Promise<IsomReport | null>;
How well the ISOM describes the tiles — rects measured, mismatched among them,
and stale when the share is past what the palette warns at — or null when the map
has no ISOM (hasIsom) or no map is open. Waits for the tileset graphics to load
and rejects when they are missing.
terrainAt
terrainAt(tx: number, ty: number): number | null;
The terrain a tile belongs to, as the id types() lists (a flat pair's CV5 index):
the tile's own group when it is flat ground, else — under a cliff, a shore or a
doodad — what the ISOM lattice says the diamond there is. Null off the map, without
the tileset graphics, or when neither tells.
color
color(tileId: number): number | null;
The atlas average of a tile, packed 0xRRGGBB, or null without graphics.
terrainColor
terrainColor(terrainId: number): number | null;
The mean colour of a terrain's common flat variations, packed 0xRRGGBB.
heightOf
heightOf(terrainId: number): 0 | 1 | 2 | null;
A flat terrain's height level (0 low, 1 high, 2 higher), or null when it is not one.
diamondsIn
diamondsIn(rect: Rect): Diamond[];
Every in-bounds diamond whose centre tile lies in rect, row by row.
floodRegion
floodRegion(x: number, y: number, match?: "terrain" | "tile"): number[];
The 4-connected area around a tile of the same terrain type ("terrain", the Rect fill's reading) or the same exact tile ("tile"), as flat indices.
blendCandidates
blendCandidates(anchorTileId: number, side: Side, options?: Partial<BlendOptions>): BlendCandidate[];
The Blend brush's list: drawable tiles whose opposite edge meets the anchor tile's
side, nearest first, with the pixel distance (0..255, designed pairs 0.2–8).
Empty without the graphics.
flatGroupOf
flatGroupOf(terrainId: number): number;
The Rect brush's terrain, in the tileset's own terms: the even CV5 group of a flat pair, or -1.
symmetry
symmetry(): SymmetryMode;
Tools ▸ Symmetry…: the mode the brushes paint and the palettes place under.
setSymmetry
setSymmetry(mode: SymmetryMode): void;
symmetryAvailable
symmetryAvailable(mode: SymmetryMode): boolean;
Whether a mode can run on the open map (the rotations and diagonals need a square one).
mirror
mirror(cells: Rect | Iterable<number>): number[];
Flat indices of cells and their images under the symmetry mode, each once.
mirrorPoint
mirrorPoint(px: number, py: number): { x: number; y: number; }[];
A map pixel and its images under the symmetry mode, the original first.
active
active(): ActiveBrush;
setActive
setActive(brush: Partial<ActiveBrush>): void;
Types
Declarations only this group names.
TerrainTypeinterface
interface TerrainType
group: number | Even CV5 group of the flat pair; odd columns use |
|---|---|
height: 0 | 1 | 2 | |
buildable: boolean |
TileInfointerface
interface TileInfo
id: number | |
|---|---|
group: number | |
slot: number | |
megatile: number | VX4 megatile, or -1 when the id points at nothing drawable. |
kind: GroupKind | |
label: string | |
height: 0 | 1 | 2 | |
buildable: boolean | |
walkable: number | Walkable minitiles out of 16, from VF4. |
IsomReportinterface
interface IsomReport
checkIsom with the verdict the palette and Check Map draw from it.
stale: boolean | More than |
|---|
SymmetryModetype
type SymmetryMode = "none" | "h" | "v" | "hv" | "rot180" | "rot90" | "diag" | "adiag";
BlendCandidateinterface
interface BlendCandidate
id: number | MTXM tile id to place. |
|---|---|
megatile: number | |
distance: number |
|
BlendOptionsinterface
interface BlendOptions
maxDistance: number | Largest distance still listed. |
|---|---|
limit: number | Most candidates listed per side. |
include?: (id: number) => boolean | Optional filter over tile ids (the palette's group-kind dropdown). |
ActiveBrushinterface
interface ActiveBrush
mode: TerrainMode | |
|---|---|
terrain: number | The Rect / isometric brush's terrain id. |
tile: number | The Tile brush's MTXM id. |
brushSize: number | |
variation: number | The Rect brush's variation slot, or -1 for a random one per pair. |