import type { CrowdShape, LedBoardOptions, LightingOptions, Side, Sport, SurfaceOptions } from "./types.ts"; export type Pt = [number, number]; export type Box = { x: number; y: number; w: number; h: number; }; /** The outline of a part of the stands, in feet in the surface's wide frame: a rectangle with rounded corners, an ellipse, or a polygon. */ export type Outline = { kind: "rrect"; x0: number; y0: number; x1: number; y1: number; r: number; } | { kind: "ellipse"; cx: number; cy: number; rx: number; ry: number; } | { kind: "poly"; points: Pt[]; }; /** A tier of the stands: a band of seats between two outlines. */ export interface StandRing { /** `lower`, `middle`, `upper`, `courtside`, `grandstand` or `bleachers`, with the tier's number where a ring has parts. */ id: string; tier: "courtside" | "gallery" | "lower" | "middle" | "upper" | "grandstand" | "bleachers" | "wall"; /** The band is `region` less `hole` (nothing for a polygon that is the band itself). */ region: Outline; /** Further pieces of the band that are apart from `region` (a ballpark's bleachers either side of the batter's eye). */ more?: Outline[]; hole: Outline | null; /** How far the band's inner and outer edges are from the edge of the playing surface, in feet, at the sides (the ends' distances are the same plus the venue's end gap less its side gap). */ from: number; to: number; /** The height of the first and of the last row above the playing surface, in feet; `rake` is the slope between them in degrees. For a view that raises the stands. */ height: [number, number]; rake: number; /** The share of its seats that are taken, relative to the stands' (the upper tier is emptier). */ fill: number; /** A hall's gallery: the rows of seats the band holds. */ rows?: number; /** The seats the band holds, at a seat's 2 by 2.3 feet. */ seats: number; /** The aisles and vomitories across the band, each from a point on its inner edge to its outer: across the sides, fanning round the corners. */ aisles: [Pt, Pt][]; /** The band is closed in this configuration (a real stadium's seats a configuration does not open): drawn as empty seats, with no people, in the same place every time. */ closed?: boolean; } /** A block of the stands that is not the home fans': the visitors', or a card display. A polygon in the wide frame. */ export interface StandSector { ring: string; kind: "away" | "tifo-home" | "tifo-away" | "closed"; points: Pt[]; } /** A place left open or built on: a tunnel through the lower stands, a bench, the camera platform of the media side. A box in the wide frame. */ export interface StandGap { kind: "tunnel" | "bench" | "media" | "camera"; box: [x0: number, y0: number, x1: number, y1: number]; } /** The stands round a surface as data. */ export interface CrowdStands { sport: Sport; shape: CrowdShape; /** The stadium a soccer pitch stands in: `purpose` (its own), `nfl` or `cfl` (a gridiron's), or nothing for another sport. */ stadium?: "purpose" | "nfl" | "cfl"; /** The playing surface, in the wide frame. */ box: Box; /** * The floor round the playing surface, where the surface draws more than its box (a court's run-off, a track's sprint straight, runways and pits): its bounding box and its outline as points, in the wide frame. * The first row of seats clears all of it by `FLOOR_CLEAR`, and the opening is centred on its box. Missing for a real venue's stands and a ballpark's, which are laid out from their own data. */ floor?: { box: Box; points: Pt[]; }; rings: StandRing[]; /** Boxes where the stands are left out (the open end of a horseshoe, the ends of two sides). */ covers: [x0: number, y0: number, x1: number, y1: number][]; sectors: StandSector[]; gaps: StandGap[]; /** The walks between the tiers: a band between one tier's outer edge and the next one's inner. */ concourses: { region: Outline; hole: Outline | null; }[]; /** A gridiron stadium's field under a soccer pitch: its outline and its two end zones, in the wide frame, so that the gap is seen. */ footprint?: { field: Box; endZones: [Box, Box]; }; /** The ground the stands need beyond the surface on each side, in feet. */ reach: { left: number; right: number; top: number; bottom: number; }; /** The seats of all the stands, from the model: what a density is a share of when no capacity is given. */ seats: number; /** The stands are a hall's gallery (a dojo's balcony): a thin band close to the walls, plain seats, a few neutral people and no sides. */ gallery?: boolean; /** The stands are a real venue's (see `src/venues.ts`): the outline of its building, the way north lies on the page and the roof. */ real?: RealShell; /** * A real stadium of more than one configuration is laid out in its own frame, the venue's, with the middle of its field at the origin whichever field it is: `shift` is where that middle is in the drawing's own * frame (the surface's), so that what belongs to the field is drawn there and the building, the bowl and the crowd are the same numbers for every configuration. */ shift?: [number, number]; } /** The room above a real venue's building that the arrow saying where north is takes, in feet, and how far above the building's box the middle of the arrow stands. */ export declare const NORTH_ROOM = 60; export declare const NORTH_AT = 32; /** What a real venue adds to the stands round a surface: the building they stand in, in feet in the wide frame, and the roof over them. */ export interface RealShell { /** The outline of the building, a polygon (OpenStreetMap's, turned so that the rink lies along x). */ footprint: Pt[]; /** The hall the stands are in: the bowl's outer wall, a rounded rectangle inside the building, and what the 3D view raises walls and a roof on (the building's annexes, which the outline has, are left as ground). */ hall: Extract; /** The way north points on the page, in degrees clockwise from the top; absent where the rink's real orientation is not known. */ north?: number; /** * `fixed` is a lid; `saddle` a roof that rises at the two ends and falls at the two sides; `barrel` a barrel vault, a round arch along the surface that stands highest over its middle line and falls to the walls at the two sides; `cable` a cable-supported roof with an opening over the surface, which a retractable fabric closes (BC Place's); * `canopy` roofs over some of the stands and leaves the field open (Lumen Field's, `canopies`); `panels` a retractable roof of sections over a ballpark's field and stands, far above its walls (T-Mobile Park's, `panels`); * `dome` an air-supported roof, a membrane that rises from the rim of the walls to a crown over the middle of the field (Tokyo Dome's, `dome`); `open` no roof: the walls only (Koshien Stadium's). */ roof: "fixed" | "saddle" | "barrel" | "cable" | "canopy" | "panels" | "dome" | "open"; /** The height of the walls, in feet, where it is not the roof's rim (a ballpark's walls stand far below its roof). */ wall?: number; /** A `canopy` roof's pieces: the outline of each in the drawing's frame, the height of its low edge (over the field's side) and how far it rises to its high edge (over the back of the stands), in feet. */ canopies?: { ring: Pt[]; low: number; rise: number; shape?: string; }[]; /** A `panels` roof: the outline it covers when closed, its bottom and its top above the field in feet (rim and crown), and where its sections rest when it is open. */ panels?: { cover: Pt[]; bottom: number; top: number; parked: Pt[]; }; /** A `dome` roof: the outline of its rim in the drawing's frame, and the heights of the rim (`low`) and of the crown above the surface, in feet. It is held up by the air inside, so it is a smooth lens, with no struts. With `ribs` (the Olympic Stadium's) the shell is `count` concrete consoles with glazed panels between them and a roof of panels rising to a ring, and `low` is the ring's height. */ dome?: { rim: Pt[]; low: number; crown: number; ribs?: { count: number; }; }; /** Draw the walls as brick (a ballpark's facade, T-Mobile Park's: from the brief; a plain drawing choice, a wall in a brick tone, no courses). */ brick?: boolean; /** Draw the walls as ivy-covered (a plain drawing choice: the wall in green). */ ivy?: boolean; /** A `cable` roof: how far its crown (the edge of the opening) stands over its rim, in feet, and the opening, a polygon in the drawing's frame over the surface. */ crown?: { rise: number; opening: Pt[]; }; /** The height of the building's podium, a lower band of its walls under the concourse levels, in feet; the walls are drawn in two bands where a venue has one (ours where the sources do not say). */ podium?: number; /** A `fixed` roof closed in the middle by a cap with a long skylight along the surface's long side (Rogers Arena's): ours, from the brief. */ skylight?: boolean; /** A `cable` roof's masts round its rim: how many, and how high they rise over the rim, in feet. */ masts?: { count: number; height: number; }; /** * A tower that leans over the building (the Olympic Stadium's Montreal Tower): the middle of its base and of its top in the drawing's frame, the height of its top above the surface in feet, and the width of its shaft at the * base and at the top in feet (a plain tapering square shaft: its width is ours). */ tower?: { base: Pt; top: Pt; height: number; angle: number; width: [number, number]; }; /** The height of the roof's lowest edge above the surface, in feet. */ edge: number; /** * A `saddle` roof's measure, in the drawing's frame: the middle of its round plan and its radius, the unit direction of the line through its two high points, the height of those points (`high`) and of the low rim between them * (`low`), in feet over the surface. The roof is the hyperbolic paraboloid through them (`venue.saddle.ts`), and the building round it is round. */ saddle?: { centre: Pt; radius: number; axis: Pt; low: number; high: number; }; /** Towers that stand apart from the bowl (Lumen Field's, at the open end), each a box on its outline in the drawing's frame, `height` feet high; `face` is the unit direction its scoreboard looks, towards the field. */ towers?: { ring: Pt[]; height: number; face: Pt; }[]; } /** The stands of a real venue, worked out from its building (`venueBowl`): what `layoutOf` takes in place of a sport's usual tiers. */ export interface RealBowl { rings: StandRing[]; /** Blocks of a band a configuration closes (its seats beyond the configuration's own): drawn over the band as empty seats, in the same place every time. */ closedSectors?: StandSector[]; /** How far the first row stands from the surface's edge at each side, in feet (the bench side has more). */ off: { left: number; right: number; top: number; bottom: number; }; /** The ground the venue needs beyond the surface on each side, in feet: the building's, and room for the arrow that says where north is. */ reach: { left: number; right: number; top: number; bottom: number; }; shell: RealShell; } /** The crowd options read: every part has its value. */ export interface Crowd { shape: CrowdShape | undefined; open: "left" | "right"; stadium: "auto" | "purpose" | "nfl" | "cfl"; density: number | undefined; attendance: number | undefined; capacity: number | undefined; seed: number; home: string | undefined; away: string | undefined; awayEnd: "auto" | "left" | "right" | "corner" | "none"; tifo: "home" | "away" | "both" | undefined; tifoDesign: "stripes" | "checks"; gaps: boolean; roof: boolean; wallSeats: boolean | undefined; /** The stands of the arena's real venue, where the package has one for the `arena` asked for. */ real: boolean; /** Whether the seats are drawn (a real venue's building is, without them, when this is false). */ stands: boolean; detail: "auto" | "fine" | "plain"; /** The LED boards as asked (`resolveBoards` reads them), or `undefined` for none. */ boards: boolean | LedBoardOptions | undefined; /** The lighting as asked (`resolveLighting` reads it), or `undefined`. */ lighting: LightingOptions | undefined; } /** The crowd the options ask for, or `undefined` for none. */ export declare function resolveCrowd(value: SurfaceOptions["crowd"]): Crowd | undefined; /** How full the stands are: a density, else attendance over capacity (the ground's, else the model's seats), else 0.85. */ export declare function densityOf(crowd: Crowd, seats: number, groundCapacity: number | undefined): number; /** A small, fast generator (mulberry32): the same seed gives the same numbers on every machine. */ export declare function generator(seed: number): () => number; /** The grounds of the package that are the home of an NFL or a CFL club, where a soccer pitch stands inside a gridiron's stands. From each ground's article. */ export declare const GRIDIRON_GROUNDS: Readonly>; /** The walls the package knows have seats on top of them, by park and the wall's label: Fenway Park's Green Monster (the Monster seats, 2003). */ export declare const WALL_SEATS: Readonly>; /** The point of an outline hit by a ray from `(cx, cy)` at angle `a` (screen angle, y down). */ export declare function rayAt(o: Outline, cx: number, cy: number, a: number): Pt; /** An outline as a path, drawn clockwise, or counter-clockwise when `reverse` (a hole in a band that is filled with the non-zero rule). */ export declare function outlinePath(o: Outline, reverse?: boolean): string; /** An outline as points, for a view that raises the stands: arcs are cut into steps of about 7.5 degrees. */ export declare function outlinePoints(o: Outline): Pt[]; /** The area of an outline, in square feet. */ export declare const areaOfOutline: (o: Outline) => number; /** The seats of a band of the stands: its area at a seat's 2 by 2.3 feet. */ export declare const seatsIn: (region: Outline, hole: Outline | null) => number; /** A point of a rounded rectangle and the outward normal there, by its parameter `u` (any real number, taken modulo 8): the four straight sides are the even whole numbers (the top from left to right, the right from top to bottom and so on round) and the four corners the odd ones. Concentric outlines (the same corners' centres) have the same parameter at the points an aisle joins. */ export declare function rrectAt(o: Extract, u: number): { p: Pt; n: Pt; }; /** The aisles a band has, as parameters of its inner outline: one at each end of every straight side (about every 30 feet along it) and one in the middle of every corner. */ export declare function aisleParameters(hole: Extract): { us: number[]; nh: number; nv: number; }; /** The aisles of a band as lines from its inner edge to its outer. */ export declare function aislesOf(region: Outline, hole: Outline | null): [Pt, Pt][]; /** The polygon of a band between two parameters, cut finely (a thirty-second of a side at a time) so that a block at a corner follows its curve as the band does. */ export declare function sectorPolygon(region: Extract, hole: Extract, u0: number, u1: number): Pt[]; /** What the layout needs of the options and the surface. */ export interface LayoutInput { sport: Sport; /** The playing surface in the wide frame. */ box: Box; crowd: Crowd; /** The side the visitors sit towards (the opposite of the home team's). */ awaySide: Side; /** A ground's key, for the stadium a soccer pitch stands in. */ ground?: string; /** The surface lies on an arena floor that fills most of the hall: the sport's closer stands, where it has them. */ arena?: boolean; /** A hall's gallery instead of the sport's stands (a dojo's balcony, from `dojoRoom`): the distance of its first row from the surface, its depth and the heights of its first and last rows, in feet. */ gallery?: { offset: number; depth: number; height: [number, number]; rows?: number; aisles?: readonly number[]; }; /** A real venue's stands in place of the sport's usual tiers (see `venueBowl`). */ real?: RealBowl; /** * Everything the surface draws round its playing area, in the wide frame: the bounding box (the surface's own view with no margin) and, where the floor is not that rectangle (an athletics track, an oval * ground), its outline as points. The opening of the stands is centred on it and clears it. Without it the floor is the box. */ floor?: { box: Box; points?: readonly (readonly [number, number])[]; }; /** The ballpark's fence as points on the field, for a ballpark (see `parkLayout`). */ fence?: readonly Pt[]; /** The foul lines' length at the poles and the backstop's distance, for a ballpark. */ backstop?: number; } /** The room kept between the floor (everything the surface draws round its playing area) and the first row of seats, in feet. */ export declare const FLOOR_CLEAR = 2; /** The layout of a sport's stands round its surface: rings, covers, sectors and gaps. For a ballpark see `parkLayout`. */ export declare function layoutOf(input: LayoutInput): CrowdStands;