import { type League } from "./leagues.ts"; import { type BadmintonFigures, type BadmintonLeague, type FreeZone, type NetLeague, type NetSport, type NetballFigures, type NetballLeague, type PadelFigures, type PadelLeague, type PickleballFigures, type PickleballLeague, type RacquetballFigures, type RacquetballLeague, type RoundnetFigures, type RoundnetLeague, type SepakTakrawFigures, type SepakTakrawLeague, type SquashFigures, type SquashLeague, type TableTennisFigures, type TableTennisLeague, type TennisFigures, type TennisLeague, type TeqballFigures, type TeqballLeague, type VolleyballFigures, type VolleyballLeague } from "./leagues/courts.ts"; import type { SurfaceOptions } from "./types.ts"; /** A rectangle as `[x0, y0, x1, y1]`, in feet. */ export type Rect = readonly [x0: number, y0: number, x1: number, y1: number]; /** A post, an antenna or a stick: a mark of a size, centred on a place. */ export interface Fixture { x: number; y: number; /** The width of a square mark, or the diameter of a round one. */ size: number; shape: "square" | "round"; } /** The net's plane in the drawing: the line x = `x`, from `y0` to `y1`. */ export interface NetLine { x: number; y0: number; y1: number; } /** * A line drawn as a circle or an arc of one: `r` is the outer radius (the rulebooks measure to the outside of a line), `w` the line's width and `a0` to `a1` the arc, * in radians from the +x axis towards +y (down the page), the whole circle when they are missing. */ export interface Ring { cx: number; cy: number; r: number; w: number; a0?: number; a1?: number; } /** * Something that stands round or beside the court, as a rectangle: a wall (solid), the metal fence between a padel court's walls (`mesh`), the front wall of a squash court * laid out flat beside it (`face`) with its tin (`tin`). */ export interface Band { rect: Rect; kind: "wall" | "mesh" | "face" | "tin"; } /** A solid object on the court: a teqball table (a rectangle) or a roundnet set (a disc). */ export type Solid = { kind: "table"; rect: Rect; } | { kind: "set"; cx: number; cy: number; r: number; }; /** The looks each sport has, the sport's default first. */ export declare const LOOKS: Readonly>; /** How each sport's board counts: in sets, in games, or (netball) as one total, as any other score is drawn. */ export declare const BOARD: Readonly>; /** True for a sport whose court is one of these. */ export declare const isNetSport: (sport: string) => sport is NetSport; /** True for a league of one of these courts. */ export declare const isNetLeague: (league: League) => league is NetLeague; /** True for a sport whose score is a board of sets or games (all of these courts but netball's). */ export declare const hasSetsBoard: (sport: string) => sport is NetSport; interface Common { /** The look: a name from `LOOKS`. */ look: string; /** The free zone drawn round the court, in feet, or `null`. */ zone: FreeZone; /** How the free zone was asked for. */ free: "official" | "least" | "none"; /** Tennis: the singles sticks are drawn. */ sticks: boolean; } /** A court to draw: the sport, its league and figures (in feet), and how it is shown. */ export type CourtPlan = (Common & { sport: "tennis"; league: TennisLeague; figures: TennisFigures; }) | (Common & { sport: "volleyball"; league: VolleyballLeague; figures: VolleyballFigures; }) | (Common & { sport: "badminton"; league: BadmintonLeague; figures: BadmintonFigures; }) | (Common & { sport: "pickleball"; league: PickleballLeague; figures: PickleballFigures; }) | (Common & { sport: "tabletennis"; league: TableTennisLeague; figures: TableTennisFigures; }) | (Common & { sport: "padel"; league: PadelLeague; figures: PadelFigures; }) | (Common & { sport: "squash"; league: SquashLeague; figures: SquashFigures; }) | (Common & { sport: "racquetball"; league: RacquetballLeague; figures: RacquetballFigures; }) | (Common & { sport: "sepaktakraw"; league: SepakTakrawLeague; figures: SepakTakrawFigures; }) | (Common & { sport: "teqball"; league: TeqballLeague; figures: TeqballFigures; }) | (Common & { sport: "roundnet"; league: RoundnetLeague; figures: RoundnetFigures; }) | (Common & { sport: "netball"; league: NetballLeague; figures: NetballFigures; }); /** * The court the options ask for. A `league` picks the rulebook (the sport's own by default; `fivb-beach` for beach volleyball); `net.look` a named look, `net.free` * the free zone, `net.sticks` the tennis singles sticks. * @throws Error when the look or the free zone is not one the sport has. */ export declare function courtFor(o: Pick): CourtPlan; /** The length and the width of the court in feet: a tennis court is the doubles court. */ export declare function courtSize(plan: CourtPlan): { length: number; width: number; }; /** The court's lines, painted areas and fixtures, in feet. */ export interface CourtGeometry { length: number; width: number; /** The lines, as the rectangles they cover. */ lines: Rect[]; /** Painted areas: the non-volley zones, the volleyball front zones. */ areas: Rect[]; /** Short lines outside the court (the attack line's extension, the service zone's limits), a part of `lines` that is drawn only in the full detail. */ small: Rect[]; /** The net across the middle, or `null` for a court without one (squash, racquetball, roundnet's circle, netball). */ net: NetLine | null; posts: Fixture[]; antennae: Fixture[]; sticks: Fixture[]; /** Lines drawn as circles and arcs (sepak takraw, netball, roundnet). */ rings: Ring[]; /** Walls, fences and the like round or beside the court, outside its rectangle. */ bands: Band[]; /** A table or a set standing on the court. */ solids: Solid[]; /** Lines painted on a wall, laid flat beside the court (squash's front wall): they may be another colour than the floor's. */ wallLines: Rect[]; /** The width of a line that runs beneath the net from side to side (volleyball's and sepak takraw's centre line): it shows between the net's edges. */ underNet: number | null; } /** * Where everything stands, from the figures of the league in feet. A line's rectangle covers the line's width: the court's dimensions are to the outside edge of the * lines (tennis Rule 1, pickleball 3.A.2, badminton Law 1.1 and Diagram A, volleyball 1.3.2 "drawn inside the dimensions"), so an end line covers * x from 0 to its width and an interior line is placed by the edge the rule measures to. */ export declare function courtGeometry(plan: CourtPlan): CourtGeometry; /** How far the court's fixtures reach beyond its side lines: the net's posts and the antennae's marks. */ export declare function sideReach(geometry: CourtGeometry): number; /** How far the walls, fences and the like stand beyond each edge of the court's rectangle: nothing for a court without any. */ export declare function bandReach(geometry: CourtGeometry): { left: number; right: number; top: number; bottom: number; }; export {};