import type { Area, Shape } from "../fields.types.ts"; import type { MBox } from "./parts.ts"; /** A mat's size. */ export interface MatSize { length: number; width: number; } /** What a piece of floor is: a whole mat, half of one (a square), or a mat cut to fit. */ export type PieceKind = "full" | "half" | "cut"; /** One piece of the floor, a mat or part of one. */ export interface Piece extends MBox { kind: PieceKind; /** The axis of its long side: `x` or `y`. */ along: "x" | "y"; /** Which colour it is painted: 1 the first, 2 the second, 3 the third (a danger zone or a border). */ tone: 1 | 2 | 3; } /** The kind of a piece of a floor laid with mats of a size. */ export declare function kindOf(w: number, h: number, mat: MatSize, along: "x" | "y"): PieceKind; /** * Lay a rectangle with mats whose long sides run along `along`, in columns the width of a mat. With `stagger` every second column is set off by half a mat, so that no four * corners meet (the traditional lay); without it the mats make a grid. The floor's ends and sides are cut to fit where its size is not a whole number of mats; a column that is * set off begins and ends with half a mat. */ export declare function lay(rect: MBox, mat: MatSize, along: "x" | "y", stagger: boolean): Piece[]; /** The part of a piece inside a box, and the parts of it outside, each a piece of its own (a mat cut where a colour changes). */ export declare function cutBy(piece: Piece, box: MBox, mat: MatSize): { inside: Piece | undefined; outside: Piece[]; }; /** * Give every piece the tone of the zone it lies in: the first of `zones` that holds it, else `rest`. A mat that a boundary runs through is cut there, each part * taking its own zone's tone. */ export declare function tint(pieces: readonly Piece[], zones: readonly { box: MBox; tone: 1 | 2 | 3; }[], rest: 1 | 2 | 3, mat: MatSize): Piece[]; /** The mats of a checker floor: the tone alternates from one mat to the next, as the squares of a chessboard do. */ export declare function checker(pieces: readonly Piece[], rect: MBox, mat: MatSize): Piece[]; /** * How many points are a corner of four pieces or more: where four mats meet. A floor laid in the traditional way has none. Pieces that only touch along a side are not counted (a T is a point * where one piece's side runs past the corners of two others, not a corner of three). */ export declare function fourCorners(pieces: readonly Piece[]): number; /** The floor's area in square metres. */ export declare const areaOf: (pieces: readonly Piece[]) => number; /** The number of mats a floor holds, counted as the mats' own area: a half mat is a half, a cut piece the share of a mat it covers. */ export declare const matCount: (pieces: readonly Piece[], mat: MatSize) => number; /** The painted areas of a floor of mats: one path for each tone, in the class the look gives it. */ export declare function tatamiAreas(id: string, pieces: readonly Piece[], classes: Readonly>, feature: Readonly>): Area[]; /** The seams: the outline of every piece, as one line. */ export declare function seams(id: string, pieces: readonly Piece[], width: number): Shape[]; /** The heri (畳縁), the cloth along the two long sides of a traditional mat, as filled strips inside the mat. Cut pieces and the thin ends of a floor have none. */ export declare function heri(id: string, pieces: readonly Piece[], width: number, mat: MatSize): Area[];