@johnmorrisdotca/kyogijo-stadiums 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +129 -0
- package/LICENSE +21 -0
- package/NOTICE.md +293 -0
- package/README.md +600 -2
- package/dist/annotate.d.ts +47 -0
- package/dist/annotate.js +349 -0
- package/dist/atlas-entry.d.ts +4 -0
- package/dist/atlas-entry.js +3 -0
- package/dist/atlas.d.ts +131 -0
- package/dist/atlas.js +149 -0
- package/dist/background.d.ts +56 -0
- package/dist/background.js +127 -0
- package/dist/ballpark.d.ts +48 -0
- package/dist/ballpark.js +129 -0
- package/dist/canvas-entry.d.ts +2 -0
- package/dist/canvas-entry.js +2 -0
- package/dist/canvas.d.ts +85 -0
- package/dist/canvas.js +279 -0
- package/dist/charts-entry.d.ts +10 -0
- package/dist/charts-entry.js +8 -0
- package/dist/charts.baseball.d.ts +30 -0
- package/dist/charts.baseball.js +152 -0
- package/dist/charts.curling.d.ts +52 -0
- package/dist/charts.curling.js +196 -0
- package/dist/charts.d.ts +172 -0
- package/dist/charts.js +508 -0
- package/dist/charts.network.d.ts +66 -0
- package/dist/charts.network.js +64 -0
- package/dist/charts.soccer.d.ts +43 -0
- package/dist/charts.soccer.js +191 -0
- package/dist/charts.types.d.ts +396 -0
- package/dist/charts.types.js +1 -0
- package/dist/colour.d.ts +29 -0
- package/dist/colour.js +97 -0
- package/dist/common.d.ts +14 -0
- package/dist/common.js +32 -0
- package/dist/court.d.ts +89 -0
- package/dist/court.js +248 -0
- package/dist/courts.style.d.ts +20 -0
- package/dist/courts.style.js +54 -0
- package/dist/cricket.board.d.ts +18 -0
- package/dist/cricket.board.js +67 -0
- package/dist/curling.board.d.ts +24 -0
- package/dist/curling.board.js +147 -0
- package/dist/d3-entry.d.ts +3 -0
- package/dist/d3-entry.js +2 -0
- package/dist/d3.d.ts +45 -0
- package/dist/d3.js +56 -0
- package/dist/draw.d.ts +52 -0
- package/dist/draw.js +705 -0
- package/dist/element-define.d.ts +2 -0
- package/dist/element-define.js +4 -0
- package/dist/element-entry.d.ts +1 -0
- package/dist/element-entry.js +2 -0
- package/dist/element.d.ts +39 -0
- package/dist/element.js +321 -0
- package/dist/eras-entry.d.ts +2 -0
- package/dist/eras-entry.js +2 -0
- package/dist/eras.d.ts +204 -0
- package/dist/eras.js +396 -0
- package/dist/events-entry.d.ts +3 -0
- package/dist/events-entry.js +3 -0
- package/dist/events.d.ts +54 -0
- package/dist/events.data.d.ts +59 -0
- package/dist/events.data.js +297 -0
- package/dist/events.js +127 -0
- package/dist/features.d.ts +31 -0
- package/dist/features.js +284 -0
- package/dist/field.score.d.ts +5 -0
- package/dist/field.score.js +33 -0
- package/dist/fields/afl.d.ts +11 -0
- package/dist/fields/afl.js +103 -0
- package/dist/fields/cricket.d.ts +9 -0
- package/dist/fields/cricket.js +81 -0
- package/dist/fields/fieldhockey.d.ts +6 -0
- package/dist/fields/fieldhockey.js +81 -0
- package/dist/fields/gaelic.d.ts +10 -0
- package/dist/fields/gaelic.js +86 -0
- package/dist/fields/handball.d.ts +6 -0
- package/dist/fields/handball.js +85 -0
- package/dist/fields/lacrosse.d.ts +17 -0
- package/dist/fields/lacrosse.js +169 -0
- package/dist/fields/rugby.d.ts +10 -0
- package/dist/fields/rugby.js +130 -0
- package/dist/fields.d.ts +12 -0
- package/dist/fields.js +44 -0
- package/dist/fields.kit.d.ts +63 -0
- package/dist/fields.kit.js +108 -0
- package/dist/fields.style.d.ts +4 -0
- package/dist/fields.style.js +19 -0
- package/dist/fields.types.d.ts +155 -0
- package/dist/fields.types.js +1 -0
- package/dist/format.d.ts +10 -0
- package/dist/format.js +28 -0
- package/dist/formations.d.ts +18 -0
- package/dist/formations.js +211 -0
- package/dist/frames-entry.d.ts +8 -0
- package/dist/frames-entry.js +7 -0
- package/dist/frames.d.ts +199 -0
- package/dist/frames.js +271 -0
- package/dist/frames.providers.d.ts +16 -0
- package/dist/frames.providers.js +302 -0
- package/dist/geojson-entry.d.ts +2 -0
- package/dist/geojson-entry.js +2 -0
- package/dist/geojson.d.ts +79 -0
- package/dist/geojson.js +147 -0
- package/dist/geometry-entry.d.ts +7 -0
- package/dist/geometry-entry.js +5 -0
- package/dist/geometry.d.ts +295 -0
- package/dist/geometry.js +361 -0
- package/dist/grounds-entry.d.ts +4 -0
- package/dist/grounds-entry.js +3 -0
- package/dist/grounds.d.ts +134 -0
- package/dist/grounds.data.d.ts +2 -0
- package/dist/grounds.data.js +1849 -0
- package/dist/grounds.js +74 -0
- package/dist/heat.colour.d.ts +37 -0
- package/dist/heat.colour.js +54 -0
- package/dist/heat.d.ts +43 -0
- package/dist/heat.js +614 -0
- package/dist/heat.stats.d.ts +123 -0
- package/dist/heat.stats.js +413 -0
- package/dist/heat.types.d.ts +145 -0
- package/dist/heat.types.js +1 -0
- package/dist/heat.zones.d.ts +54 -0
- package/dist/heat.zones.js +424 -0
- package/dist/homeside.d.ts +16 -0
- package/dist/homeside.js +43 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +29 -0
- package/dist/layers-entry.d.ts +19 -0
- package/dist/layers-entry.js +11 -0
- package/dist/layers.d.ts +41 -0
- package/dist/layers.env.d.ts +72 -0
- package/dist/layers.env.js +79 -0
- package/dist/layers.js +533 -0
- package/dist/layers.marks.d.ts +45 -0
- package/dist/layers.marks.js +168 -0
- package/dist/layers.types.d.ts +226 -0
- package/dist/layers.types.js +1 -0
- package/dist/layout.d.ts +97 -0
- package/dist/layout.js +381 -0
- package/dist/layout.style.d.ts +6 -0
- package/dist/layout.style.js +17 -0
- package/dist/layouts-entry.d.ts +5 -0
- package/dist/layouts-entry.js +4 -0
- package/dist/leagues/aussie.d.ts +57 -0
- package/dist/leagues/aussie.js +36 -0
- package/dist/leagues/baseball.d.ts +58 -0
- package/dist/leagues/baseball.js +171 -0
- package/dist/leagues/basketball.d.ts +67 -0
- package/dist/leagues/basketball.js +128 -0
- package/dist/leagues/courts.d.ts +212 -0
- package/dist/leagues/courts.js +114 -0
- package/dist/leagues/cricket.d.ts +45 -0
- package/dist/leagues/cricket.js +34 -0
- package/dist/leagues/curling.d.ts +64 -0
- package/dist/leagues/curling.js +53 -0
- package/dist/leagues/fieldhockey.d.ts +48 -0
- package/dist/leagues/fieldhockey.js +29 -0
- package/dist/leagues/fields.d.ts +10 -0
- package/dist/leagues/fields.js +6 -0
- package/dist/leagues/football.d.ts +8 -0
- package/dist/leagues/football.js +82 -0
- package/dist/leagues/gaelic.d.ts +50 -0
- package/dist/leagues/gaelic.js +29 -0
- package/dist/leagues/handball.d.ts +45 -0
- package/dist/leagues/handball.js +32 -0
- package/dist/leagues/hockey.d.ts +63 -0
- package/dist/leagues/hockey.js +166 -0
- package/dist/leagues/lacrosse.d.ts +103 -0
- package/dist/leagues/lacrosse.js +175 -0
- package/dist/leagues/rugby.d.ts +59 -0
- package/dist/leagues/rugby.js +72 -0
- package/dist/leagues/sources.d.ts +18 -0
- package/dist/leagues/sources.js +95 -0
- package/dist/leagues/types.d.ts +43 -0
- package/dist/leagues/types.js +5 -0
- package/dist/leagues-entry.d.ts +23 -0
- package/dist/leagues-entry.js +15 -0
- package/dist/leagues.d.ts +172 -0
- package/dist/leagues.js +462 -0
- package/dist/look.d.ts +50 -0
- package/dist/look.js +186 -0
- package/dist/mark.d.ts +35 -0
- package/dist/mark.js +59 -0
- package/dist/mount-entry.d.ts +2 -0
- package/dist/mount-entry.js +2 -0
- package/dist/mount.d.ts +63 -0
- package/dist/mount.js +167 -0
- package/dist/mow.d.ts +36 -0
- package/dist/mow.js +111 -0
- package/dist/names.d.ts +77 -0
- package/dist/names.js +97 -0
- package/dist/outline.d.ts +25 -0
- package/dist/outline.js +112 -0
- package/dist/parks-entry.d.ts +4 -0
- package/dist/parks-entry.js +3 -0
- package/dist/parks.d.ts +200 -0
- package/dist/parks.data.d.ts +2 -0
- package/dist/parks.data.js +4489 -0
- package/dist/parks.js +92 -0
- package/dist/plot-entry.d.ts +2 -0
- package/dist/plot-entry.js +2 -0
- package/dist/plot.d.ts +74 -0
- package/dist/plot.js +68 -0
- package/dist/png-entry.d.ts +2 -0
- package/dist/png-entry.js +2 -0
- package/dist/png.d.ts +26 -0
- package/dist/png.js +46 -0
- package/dist/ranges.d.ts +33 -0
- package/dist/ranges.js +178 -0
- package/dist/ranges.names.d.ts +31 -0
- package/dist/ranges.names.js +65 -0
- package/dist/react-entry.d.ts +2 -0
- package/dist/react-entry.js +2 -0
- package/dist/react.d.ts +53 -0
- package/dist/react.js +58 -0
- package/dist/replay-entry.d.ts +5 -0
- package/dist/replay-entry.js +4 -0
- package/dist/replay.control.d.ts +47 -0
- package/dist/replay.control.js +184 -0
- package/dist/replay.d.ts +170 -0
- package/dist/replay.dom.d.ts +21 -0
- package/dist/replay.dom.js +388 -0
- package/dist/replay.js +579 -0
- package/dist/replay.types.d.ts +152 -0
- package/dist/replay.types.js +1 -0
- package/dist/restyle.d.ts +21 -0
- package/dist/restyle.js +70 -0
- package/dist/road.d.ts +26 -0
- package/dist/road.draw.d.ts +6 -0
- package/dist/road.draw.js +269 -0
- package/dist/road.js +59 -0
- package/dist/road.model.d.ts +63 -0
- package/dist/road.model.js +215 -0
- package/dist/road.style.d.ts +7 -0
- package/dist/road.style.js +26 -0
- package/dist/road.types.d.ts +122 -0
- package/dist/road.types.js +1 -0
- package/dist/scene-entry.d.ts +7 -0
- package/dist/scene-entry.js +5 -0
- package/dist/scene.css.d.ts +44 -0
- package/dist/scene.css.js +296 -0
- package/dist/scene.d.ts +27 -0
- package/dist/scene.fit.d.ts +12 -0
- package/dist/scene.fit.js +18 -0
- package/dist/scene.flat.d.ts +38 -0
- package/dist/scene.flat.js +167 -0
- package/dist/scene.js +420 -0
- package/dist/scene.path.d.ts +40 -0
- package/dist/scene.path.js +357 -0
- package/dist/scene.types.d.ts +172 -0
- package/dist/scene.types.js +1 -0
- package/dist/scene.xml.d.ts +31 -0
- package/dist/scene.xml.js +81 -0
- package/dist/score.d.ts +70 -0
- package/dist/score.js +212 -0
- package/dist/sets.board.d.ts +22 -0
- package/dist/sets.board.js +89 -0
- package/dist/sheet.d.ts +18 -0
- package/dist/sheet.js +38 -0
- package/dist/special.d.ts +44 -0
- package/dist/special.js +204 -0
- package/dist/special.style.d.ts +8 -0
- package/dist/special.style.js +36 -0
- package/dist/strings.d.ts +581 -0
- package/dist/strings.js +411 -0
- package/dist/style.d.ts +35 -0
- package/dist/style.js +177 -0
- package/dist/surfaces/baseball.d.ts +33 -0
- package/dist/surfaces/baseball.js +208 -0
- package/dist/surfaces/baseball.walls.d.ts +16 -0
- package/dist/surfaces/baseball.walls.js +150 -0
- package/dist/surfaces/basketball.d.ts +8 -0
- package/dist/surfaces/basketball.js +199 -0
- package/dist/surfaces/curling.d.ts +23 -0
- package/dist/surfaces/curling.js +128 -0
- package/dist/surfaces/field.d.ts +12 -0
- package/dist/surfaces/field.js +163 -0
- package/dist/surfaces/football.d.ts +12 -0
- package/dist/surfaces/football.js +208 -0
- package/dist/surfaces/hockey.d.ts +10 -0
- package/dist/surfaces/hockey.js +166 -0
- package/dist/surfaces/net.d.ts +7 -0
- package/dist/surfaces/net.js +151 -0
- package/dist/surfaces/soccer-providers.d.ts +124 -0
- package/dist/surfaces/soccer-providers.js +334 -0
- package/dist/surfaces/soccer-spec.d.ts +138 -0
- package/dist/surfaces/soccer-spec.js +175 -0
- package/dist/surfaces/soccer.d.ts +25 -0
- package/dist/surfaces/soccer.js +270 -0
- package/dist/surfaces/surface.d.ts +180 -0
- package/dist/surfaces/surface.js +49 -0
- package/dist/team.common.d.ts +75 -0
- package/dist/team.common.js +97 -0
- package/dist/team.formation.d.ts +24 -0
- package/dist/team.formation.js +121 -0
- package/dist/team.geometry.d.ts +66 -0
- package/dist/team.geometry.js +304 -0
- package/dist/team.layers.d.ts +16 -0
- package/dist/team.layers.js +32 -0
- package/dist/team.motion.d.ts +9 -0
- package/dist/team.motion.js +325 -0
- package/dist/team.network.d.ts +43 -0
- package/dist/team.network.js +215 -0
- package/dist/team.shape.d.ts +12 -0
- package/dist/team.shape.js +217 -0
- package/dist/team.types.d.ts +189 -0
- package/dist/team.types.js +1 -0
- package/dist/text.d.ts +31 -0
- package/dist/text.js +88 -0
- package/dist/themes.d.ts +14 -0
- package/dist/themes.js +24 -0
- package/dist/types.d.ts +565 -0
- package/dist/types.js +1 -0
- package/dist/units.d.ts +45 -0
- package/dist/units.js +90 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +234 -4
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// The geometry and the colour of the marks of a data layer: shapes, bowed and wavy lines, arrowheads, the outline of a comet, and
|
|
2
|
+
// a colour run through stops. Pure functions of numbers and text; nothing here knows a sport. Written for this package from the
|
|
3
|
+
// plain geometry (quadratic curves, offsets along a normal); no code of any plotting library is used.
|
|
4
|
+
import { rgbOf, safeColour } from "./colour.js";
|
|
5
|
+
import { num } from "./format.js";
|
|
6
|
+
const hex2 = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
|
|
7
|
+
/**
|
|
8
|
+
* A colour a fraction `t` (0 to 1) of the way through `stops`, as a hex colour, or the nearest stop when one cannot be read without a
|
|
9
|
+
* browser (`var(--x)`, a name that is not a common one). Stops that are not colours are ignored; with none left, `undefined`.
|
|
10
|
+
*/
|
|
11
|
+
export function rampColour(stops, t) {
|
|
12
|
+
const safe = stops.map((stop) => safeColour(stop)).filter((stop) => stop !== undefined);
|
|
13
|
+
if (safe.length === 0)
|
|
14
|
+
return undefined;
|
|
15
|
+
const at = Math.max(0, Math.min(1, Number.isFinite(t) ? t : 0)) * (safe.length - 1);
|
|
16
|
+
const k = Math.min(Math.floor(at), safe.length - 2);
|
|
17
|
+
if (safe.length === 1)
|
|
18
|
+
return safe[0];
|
|
19
|
+
const a = rgbOf(safe[k]);
|
|
20
|
+
const b = rgbOf(safe[k + 1]);
|
|
21
|
+
if (a === undefined || b === undefined)
|
|
22
|
+
return safe[Math.round(at)];
|
|
23
|
+
const f = at - k;
|
|
24
|
+
return `#${hex2(a[0] + (b[0] - a[0]) * f)}${hex2(a[1] + (b[1] - a[1]) * f)}${hex2(a[2] + (b[2] - a[2]) * f)}`;
|
|
25
|
+
}
|
|
26
|
+
/** The corners of each shape for a mark of radius 1, as offsets from its centre, with y down. A circle has none. */
|
|
27
|
+
const CORNERS = (() => {
|
|
28
|
+
const plus = (arm, half) => [
|
|
29
|
+
[-half, -arm], [half, -arm], [half, -half], [arm, -half], [arm, half], [half, half], [half, arm], [-half, arm], [-half, half], [-arm, half], [-arm, -half], [-half, -half],
|
|
30
|
+
];
|
|
31
|
+
const star = [];
|
|
32
|
+
for (let i = 0; i < 10; i += 1) {
|
|
33
|
+
const r = i % 2 === 0 ? 1.28 : 0.52;
|
|
34
|
+
const a = (i * Math.PI) / 5 - Math.PI / 2;
|
|
35
|
+
star.push([Math.round(r * Math.cos(a) * 1000) / 1000, Math.round(r * Math.sin(a) * 1000) / 1000]);
|
|
36
|
+
}
|
|
37
|
+
const turn45 = (list) => list.map(([x, y]) => [Math.round((x - y) * Math.SQRT1_2 * 1000) / 1000, Math.round((x + y) * Math.SQRT1_2 * 1000) / 1000]);
|
|
38
|
+
return {
|
|
39
|
+
square: [[-0.88, -0.88], [0.88, -0.88], [0.88, 0.88], [-0.88, 0.88]],
|
|
40
|
+
triangle: [[0, -1.2], [1.05, 0.62], [-1.05, 0.62]],
|
|
41
|
+
diamond: [[0, -1.25], [1.25, 0], [0, 1.25], [-1.25, 0]],
|
|
42
|
+
cross: plus(1.2, 0.4),
|
|
43
|
+
x: turn45(plus(1.2, 0.4)),
|
|
44
|
+
star,
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
/**
|
|
48
|
+
* The path of a polygon shape of width `width` centred on `(cx, cy)`. When the surface is turned a quarter, the corners are turned
|
|
49
|
+
* back so that the shape stands upright as the eye sees it.
|
|
50
|
+
*/
|
|
51
|
+
export function shapePath(shape, cx, cy, width, turned) {
|
|
52
|
+
const r = width / 2;
|
|
53
|
+
const corners = CORNERS[shape];
|
|
54
|
+
let d = "";
|
|
55
|
+
for (let i = 0; i < corners.length; i += 1) {
|
|
56
|
+
const [ox, oy] = corners[i];
|
|
57
|
+
const x = turned ? oy * r : ox * r;
|
|
58
|
+
const y = turned ? -ox * r : oy * r;
|
|
59
|
+
d += `${i === 0 ? "M" : "L"}${num(cx + x)} ${num(cy + y)}`;
|
|
60
|
+
}
|
|
61
|
+
return `${d}Z`;
|
|
62
|
+
}
|
|
63
|
+
/** True for a shape drawn as a polygon, not a circle. */
|
|
64
|
+
export const isPolygon = (shape) => Object.prototype.hasOwnProperty.call(CORNERS, shape);
|
|
65
|
+
const length = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
66
|
+
function straight(from, to) {
|
|
67
|
+
const chord = length(from, to);
|
|
68
|
+
const u = chord === 0 ? [1, 0] : [(to[0] - from[0]) / chord, (to[1] - from[1]) / chord];
|
|
69
|
+
const at = (s) => [from[0] + u[0] * s, from[1] + u[1] * s];
|
|
70
|
+
return { from, to, length: chord, at, tangent: () => u, trim: (by) => straight(from, at(Math.max(0, chord - Math.min(by, chord * 0.9)))) };
|
|
71
|
+
}
|
|
72
|
+
function bowed(from, control, to) {
|
|
73
|
+
const STEPS = 40;
|
|
74
|
+
const point = (t) => [(1 - t) * (1 - t) * from[0] + 2 * (1 - t) * t * control[0] + t * t * to[0], (1 - t) * (1 - t) * from[1] + 2 * (1 - t) * t * control[1] + t * t * to[1]];
|
|
75
|
+
const along = [0];
|
|
76
|
+
let previous = point(0);
|
|
77
|
+
for (let i = 1; i <= STEPS; i += 1) {
|
|
78
|
+
const here = point(i / STEPS);
|
|
79
|
+
along.push(along[i - 1] + length(previous, here));
|
|
80
|
+
previous = here;
|
|
81
|
+
}
|
|
82
|
+
const total = along[STEPS];
|
|
83
|
+
const param = (s) => {
|
|
84
|
+
const target = Math.max(0, Math.min(total, s));
|
|
85
|
+
let k = 0;
|
|
86
|
+
while (k < STEPS - 1 && along[k + 1] < target)
|
|
87
|
+
k += 1;
|
|
88
|
+
const span = along[k + 1] - along[k];
|
|
89
|
+
return (k + (span === 0 ? 0 : (target - along[k]) / span)) / STEPS;
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
from,
|
|
93
|
+
to,
|
|
94
|
+
control,
|
|
95
|
+
length: total,
|
|
96
|
+
at: (s) => point(param(s)),
|
|
97
|
+
tangent: (s) => {
|
|
98
|
+
const t = param(s);
|
|
99
|
+
const dx = 2 * (1 - t) * (control[0] - from[0]) + 2 * t * (to[0] - control[0]);
|
|
100
|
+
const dy = 2 * (1 - t) * (control[1] - from[1]) + 2 * t * (to[1] - control[1]);
|
|
101
|
+
const m = Math.hypot(dx, dy) || 1;
|
|
102
|
+
return [dx / m, dy / m];
|
|
103
|
+
},
|
|
104
|
+
// Cutting a quadratic curve at a parameter leaves a quadratic curve: its control point is the same fraction of the way to the old one.
|
|
105
|
+
trim: (by) => {
|
|
106
|
+
const t = param(total - Math.min(by, total * 0.9));
|
|
107
|
+
return bowed(from, [from[0] + (control[0] - from[0]) * t, from[1] + (control[1] - from[1]) * t], point(t));
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** A line from `from` to `to` bowed by `bow` times its length (zero for straight). Positive bows to the right of the way it goes as the surface is drawn wide. */
|
|
112
|
+
export function curveBetween(from, to, bow) {
|
|
113
|
+
if (length(from, to) === 0 || !Number.isFinite(bow) || bow === 0)
|
|
114
|
+
return straight(from, to);
|
|
115
|
+
return bowed(from, [(from[0] + to[0]) / 2 - (to[1] - from[1]) * bow, (from[1] + to[1]) / 2 + (to[0] - from[0]) * bow], to);
|
|
116
|
+
}
|
|
117
|
+
/** The path of a straight or bowed line. */
|
|
118
|
+
export function curvePath(curve) {
|
|
119
|
+
const to = curve.to;
|
|
120
|
+
const head = `M${num(curve.from[0])} ${num(curve.from[1])}`;
|
|
121
|
+
return curve.control === undefined ? `${head}L${num(to[0])} ${num(to[1])}` : `${head}Q${num(curve.control[0])} ${num(curve.control[1])} ${num(to[0])} ${num(to[1])}`;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A wave along a line: a chain of quadratic curves, each half a wavelength long, that leans to one side and then the other, so
|
|
125
|
+
* that it starts and ends on the line. The wavelength is stretched a little so that a whole number of waves fits.
|
|
126
|
+
*/
|
|
127
|
+
export function wavePath(curve, amplitude, wavelength) {
|
|
128
|
+
const L = curve.length;
|
|
129
|
+
const halves = Math.max(2, 2 * Math.round(L / Math.max(wavelength, L / 400)));
|
|
130
|
+
const first = curve.at(0);
|
|
131
|
+
let d = `M${num(first[0])} ${num(first[1])}`;
|
|
132
|
+
for (let k = 0; k < halves; k += 1) {
|
|
133
|
+
const mid = curve.at(((k + 0.5) / halves) * L);
|
|
134
|
+
const t = curve.tangent(((k + 0.5) / halves) * L);
|
|
135
|
+
const end = curve.at(((k + 1) / halves) * L);
|
|
136
|
+
if (k === 0) {
|
|
137
|
+
// The first half bows to the left of the way it goes; each next one is its reflection, which `T` makes.
|
|
138
|
+
d += `Q${num(mid[0] - t[1] * 2 * amplitude)} ${num(mid[1] + t[0] * 2 * amplitude)} ${num(end[0])} ${num(end[1])}`;
|
|
139
|
+
}
|
|
140
|
+
else
|
|
141
|
+
d += `T${num(end[0])} ${num(end[1])}`;
|
|
142
|
+
}
|
|
143
|
+
return d;
|
|
144
|
+
}
|
|
145
|
+
/** The path of a head at `tip`, pointing along the unit direction `u`: a filled triangle (closed) or an open chevron. */
|
|
146
|
+
export function headPath(tip, u, headLength, halfWidth, open) {
|
|
147
|
+
const base = [tip[0] - u[0] * headLength, tip[1] - u[1] * headLength];
|
|
148
|
+
const left = [base[0] - u[1] * halfWidth, base[1] + u[0] * halfWidth];
|
|
149
|
+
const right = [base[0] + u[1] * halfWidth, base[1] - u[0] * halfWidth];
|
|
150
|
+
const corner = (p) => `${num(p[0])} ${num(p[1])}`;
|
|
151
|
+
return open ? `M${corner(left)}L${corner(tip)}L${corner(right)}` : `M${corner(tip)}L${corner(left)}L${corner(right)}Z`;
|
|
152
|
+
}
|
|
153
|
+
/** The outline of a comet along a line: a shape that grows from a point at the start to `widest` wide at the end. */
|
|
154
|
+
export function taperPath(curve, widest, steps = 14) {
|
|
155
|
+
const left = [];
|
|
156
|
+
const right = [];
|
|
157
|
+
for (let i = 0; i <= steps; i += 1) {
|
|
158
|
+
const s = (i / steps) * curve.length;
|
|
159
|
+
const p = curve.at(s);
|
|
160
|
+
const t = curve.tangent(s);
|
|
161
|
+
const half = (widest * (0.08 + 0.92 * (i / steps))) / 2;
|
|
162
|
+
left.push(`${num(p[0] - t[1] * half)} ${num(p[1] + t[0] * half)}`);
|
|
163
|
+
right.push(`${num(p[0] + t[1] * half)} ${num(p[1] - t[0] * half)}`);
|
|
164
|
+
}
|
|
165
|
+
return `M${left.join("L")}L${right.reverse().join("L")}Z`;
|
|
166
|
+
}
|
|
167
|
+
/** A polyline's path. */
|
|
168
|
+
export const polylinePath = (points, last) => points.map((p, i) => `${i === 0 ? "M" : "L"}${num(i === points.length - 1 && last !== undefined ? last[0] : p[0])} ${num(i === points.length - 1 && last !== undefined ? last[1] : p[1])}`).join("");
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type { ScoreOptions, SurfaceOptions } from "./types.ts";
|
|
2
|
+
import type { Frame, Attacking, Landmark, SurfaceSize } from "./frames.ts";
|
|
3
|
+
import type { ContourLayer, HeatmapLayer, HexbinLayer, LegendLayer, ZonesLayer } from "./heat.types.ts";
|
|
4
|
+
import type { DelaunayLayer, FlowLayer, FormationLayer, HullLayer, NetworkLayer, SonarLayer, VoronoiLayer } from "./team.types.ts";
|
|
5
|
+
import type { Unit } from "./units.ts";
|
|
6
|
+
/** The shapes a point can be drawn as. A team's logo is `logo`. */
|
|
7
|
+
export type MarkShape = "circle" | "square" | "triangle" | "diamond" | "cross" | "x" | "star";
|
|
8
|
+
/** Which team a mark belongs to: `home` or `away` take the layer's team colours (`--ky-layer-home`, `--ky-layer-away`); any other text is a mark of no team. */
|
|
9
|
+
export type LayerTeam = "home" | "away" | (string & {});
|
|
10
|
+
/** A number mapped to another range: `domain` is the values (the data's least and greatest when missing) and `range` what they become. */
|
|
11
|
+
export interface Scale {
|
|
12
|
+
domain?: readonly [number, number];
|
|
13
|
+
range: readonly [number, number];
|
|
14
|
+
/** For a size: scale the area and not the width, so that twice the value covers twice the ground. On by default. */
|
|
15
|
+
area?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A colour, or a rule for choosing one. A text is any colour `safeColour` accepts. `by: "team"` uses the home and away colours of the layer,
|
|
19
|
+
* `by: "value"` runs through `stops` as a datum's `value` goes from the least to the greatest of the domain, and `by: "outcome"` looks the
|
|
20
|
+
* datum's outcome up in `colors`. A colour a datum carries itself (`color`) always wins.
|
|
21
|
+
*/
|
|
22
|
+
export type Paint = string | {
|
|
23
|
+
by: "team";
|
|
24
|
+
home?: string;
|
|
25
|
+
away?: string;
|
|
26
|
+
other?: string;
|
|
27
|
+
} | {
|
|
28
|
+
by: "value";
|
|
29
|
+
stops: readonly string[];
|
|
30
|
+
domain?: readonly [number, number];
|
|
31
|
+
missing?: string;
|
|
32
|
+
} | {
|
|
33
|
+
by: "outcome";
|
|
34
|
+
colors: Readonly<Record<string, string>>;
|
|
35
|
+
other?: string;
|
|
36
|
+
};
|
|
37
|
+
/** How an outcome looks: a hollow mark (or a dashed line) is a miss, a failed pass or a shot that did not score. */
|
|
38
|
+
export interface OutcomeStyle {
|
|
39
|
+
/** Draw a point hollow and a line dashed. */
|
|
40
|
+
hollow?: boolean;
|
|
41
|
+
/** A shape for this outcome, over the layer's. */
|
|
42
|
+
shape?: MarkShape;
|
|
43
|
+
/** A multiple of the mark's size: 1.4 makes a goal stand out. */
|
|
44
|
+
scale?: number;
|
|
45
|
+
}
|
|
46
|
+
/** What every mark can carry. */
|
|
47
|
+
export interface MarkDatum {
|
|
48
|
+
/** The tooltip, and what a screen reader reads for the mark. */
|
|
49
|
+
title?: string;
|
|
50
|
+
/** `home`, `away` or another team. */
|
|
51
|
+
team?: LayerTeam;
|
|
52
|
+
/** What happened, as a word of your own (`goal`, `miss`, `complete`). The standard ones are in `OUTCOMES`; the layer's `style.outcomes` adds more. */
|
|
53
|
+
outcome?: string;
|
|
54
|
+
/** A number that sizes and colours the mark when the layer's style asks it to (expected goals, speed, distance). */
|
|
55
|
+
value?: number | null;
|
|
56
|
+
/** A colour for this mark alone. */
|
|
57
|
+
color?: string;
|
|
58
|
+
/** 0 to 1. */
|
|
59
|
+
opacity?: number;
|
|
60
|
+
}
|
|
61
|
+
/** A point to mark. */
|
|
62
|
+
export interface PointDatum extends MarkDatum {
|
|
63
|
+
x: number | null;
|
|
64
|
+
y: number | null;
|
|
65
|
+
/** A shape for this mark alone, or `logo` for the logo of its team (or its own `logo`). */
|
|
66
|
+
shape?: MarkShape | "logo";
|
|
67
|
+
/** The width of the mark, in the layer's units. */
|
|
68
|
+
size?: number;
|
|
69
|
+
/** The address of a logo, for the shape `logo`. */
|
|
70
|
+
logo?: string;
|
|
71
|
+
}
|
|
72
|
+
/** A line or an arrow: from `(x, y)` to `(x2, y2)`, or through `points`. */
|
|
73
|
+
export interface LineDatum extends MarkDatum {
|
|
74
|
+
x?: number | null;
|
|
75
|
+
y?: number | null;
|
|
76
|
+
x2?: number | null;
|
|
77
|
+
y2?: number | null;
|
|
78
|
+
/** A path through several points, `[x, y]` each, in place of `x`, `y`, `x2` and `y2`. */
|
|
79
|
+
points?: readonly (readonly [number, number])[];
|
|
80
|
+
/** How far the line bows, as a fraction of its length. Positive bows to the right of the way it goes as the surface is drawn wide. */
|
|
81
|
+
curve?: number;
|
|
82
|
+
/** Make this one wavy (or straight, with false) whatever the layer's style says. */
|
|
83
|
+
wavy?: boolean;
|
|
84
|
+
/** The width of the stroke, in the layer's units. */
|
|
85
|
+
width?: number;
|
|
86
|
+
}
|
|
87
|
+
/** A word or a number to write. */
|
|
88
|
+
export interface TextDatum extends MarkDatum {
|
|
89
|
+
x: number | null;
|
|
90
|
+
y: number | null;
|
|
91
|
+
text: string | number;
|
|
92
|
+
/** The height of the letters, in the layer's units. */
|
|
93
|
+
size?: number;
|
|
94
|
+
/** Turn the text this many degrees, clockwise, as the eye sees it. The text stays upright when the surface is turned. */
|
|
95
|
+
rotate?: number;
|
|
96
|
+
anchor?: "start" | "middle" | "end";
|
|
97
|
+
}
|
|
98
|
+
/** How points look. */
|
|
99
|
+
export interface PointStyle {
|
|
100
|
+
shape?: MarkShape | "logo";
|
|
101
|
+
/** The width of a mark in the layer's units, or a scale from `value`. A default that follows the size of the surface. */
|
|
102
|
+
size?: number | Scale;
|
|
103
|
+
/** A multiple of the default size. */
|
|
104
|
+
scale?: number;
|
|
105
|
+
/** The colour of the fill. The home and away colours for marks that carry a team, the layer colour for the rest. */
|
|
106
|
+
fill?: Paint;
|
|
107
|
+
/** The colour of the edge. A pale or dark line (`--ky-layer-edge`) that sets the mark off the ground. `none` for no edge. */
|
|
108
|
+
stroke?: string | "none";
|
|
109
|
+
opacity?: number;
|
|
110
|
+
/** Looks of outcomes, over the standard ones in `OUTCOMES`. */
|
|
111
|
+
outcomes?: Readonly<Record<string, OutcomeStyle>>;
|
|
112
|
+
/** Logos by team, for the shape `logo`. In a score drawing the teams' own logos are used when these are missing. */
|
|
113
|
+
logos?: {
|
|
114
|
+
home?: string;
|
|
115
|
+
away?: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** The look of a comet: a line that fades in along its length, and may also thicken. */
|
|
119
|
+
export interface Comet {
|
|
120
|
+
/** The opacity at the start, 0 to 1. 0.05 by default. */
|
|
121
|
+
from?: number;
|
|
122
|
+
/** Draw it as a shape that thickens towards the end, not as a stroke of one width. */
|
|
123
|
+
taper?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/** How lines and arrows look. */
|
|
126
|
+
export interface LineStyle {
|
|
127
|
+
/** The width of the stroke in the layer's units, or a scale from `value`. */
|
|
128
|
+
width?: number | Scale;
|
|
129
|
+
scale?: number;
|
|
130
|
+
color?: Paint;
|
|
131
|
+
opacity?: number;
|
|
132
|
+
/** `auto` (the default) dashes the lines of a hollow outcome. */
|
|
133
|
+
dash?: "auto" | "solid" | "dashed" | "dotted";
|
|
134
|
+
/** How far lines bow, as a fraction of their length. */
|
|
135
|
+
curve?: number;
|
|
136
|
+
/** Draw lines as waves, for a carry: `true` for the usual wave, or its size. */
|
|
137
|
+
wavy?: boolean | {
|
|
138
|
+
amplitude?: number;
|
|
139
|
+
wavelength?: number;
|
|
140
|
+
};
|
|
141
|
+
/** The head at the end: a filled triangle, an open chevron or none. Arrows have a triangle by default and lines none. */
|
|
142
|
+
head?: "triangle" | "open" | "none";
|
|
143
|
+
/** The length of the head as a multiple of the width. 3.4 by default. */
|
|
144
|
+
headSize?: number;
|
|
145
|
+
/** Fade a line in along its length (a pass, a run): `true` or its look. Each comet has a gradient of its own, with an id that belongs to the drawing. */
|
|
146
|
+
comet?: boolean | Comet;
|
|
147
|
+
outcomes?: Readonly<Record<string, OutcomeStyle>>;
|
|
148
|
+
}
|
|
149
|
+
/** How text looks. */
|
|
150
|
+
export interface TextStyle {
|
|
151
|
+
/** The height of the letters in the layer's units. A default that follows the size of the surface. */
|
|
152
|
+
size?: number;
|
|
153
|
+
color?: Paint;
|
|
154
|
+
weight?: number;
|
|
155
|
+
anchor?: "start" | "middle" | "end";
|
|
156
|
+
/** Outline the letters in the halo colour (`--ky-halo`) so that they read on any ground. On by default. */
|
|
157
|
+
halo?: boolean;
|
|
158
|
+
opacity?: number;
|
|
159
|
+
}
|
|
160
|
+
/** What every layer takes. */
|
|
161
|
+
export interface LayerBase {
|
|
162
|
+
/** A name for the layer in ids and in the page; letters, digits and hyphens. */
|
|
163
|
+
id?: string;
|
|
164
|
+
/** What the marks are, for the summary: `shots`, `passes`. */
|
|
165
|
+
name?: string;
|
|
166
|
+
/** The accessible title of the layer. Made from the count and `name` when missing, such as "24 shots". */
|
|
167
|
+
title?: string;
|
|
168
|
+
/** The accessible description. Made from the counts by outcome and team when missing. */
|
|
169
|
+
description?: string;
|
|
170
|
+
/** The frame the coordinates are in (a name in `FRAMES`, or a `Frame`). Without it they are the surface's own: feet from the top left of the surface as drawn wide. */
|
|
171
|
+
from?: Frame | string;
|
|
172
|
+
/** The unit of sizes and of `anchors`, and of the coordinates when there is no `from` (a frame's numbers are in the frame's own unit): the drawing's `units`, else feet. `rulebook` is the unit of the sport's rulebook (`SURFACE_UNITS`). */
|
|
173
|
+
units?: Unit | "rulebook";
|
|
174
|
+
/** The end the layer's team attacks in the frame's numbers, for a frame fixed to the surface. */
|
|
175
|
+
attacking?: Attacking;
|
|
176
|
+
/** The surface's size, for a frame that fits any size. */
|
|
177
|
+
surfaceSize?: SurfaceSize;
|
|
178
|
+
/** Landmarks of your own for an axis of the frame. */
|
|
179
|
+
anchors?: {
|
|
180
|
+
x?: readonly Landmark[];
|
|
181
|
+
y?: readonly Landmark[];
|
|
182
|
+
};
|
|
183
|
+
/** Keep the marks on the surface (`surface`) or in a box, instead of cutting what falls outside. */
|
|
184
|
+
limits?: "surface" | {
|
|
185
|
+
x?: readonly [number, number];
|
|
186
|
+
y?: readonly [number, number];
|
|
187
|
+
};
|
|
188
|
+
/** `surface` (the default) cuts the layer to the surface's outline (the boards' corners, the fence, the court's lines); `none` lets it run over the ground round it. */
|
|
189
|
+
clip?: "surface" | "none";
|
|
190
|
+
/** Hide the layer. It is still in `layerTable`. */
|
|
191
|
+
hidden?: boolean;
|
|
192
|
+
}
|
|
193
|
+
export interface PointsLayer extends LayerBase {
|
|
194
|
+
kind: "points";
|
|
195
|
+
data: readonly PointDatum[];
|
|
196
|
+
style?: PointStyle;
|
|
197
|
+
}
|
|
198
|
+
export interface LinesLayer extends LayerBase {
|
|
199
|
+
kind: "lines";
|
|
200
|
+
data: readonly LineDatum[];
|
|
201
|
+
style?: LineStyle;
|
|
202
|
+
}
|
|
203
|
+
export interface ArrowsLayer extends LayerBase {
|
|
204
|
+
kind: "arrows";
|
|
205
|
+
data: readonly LineDatum[];
|
|
206
|
+
style?: LineStyle;
|
|
207
|
+
}
|
|
208
|
+
export interface TextLayer extends LayerBase {
|
|
209
|
+
kind: "text";
|
|
210
|
+
data: readonly TextDatum[];
|
|
211
|
+
style?: TextStyle;
|
|
212
|
+
}
|
|
213
|
+
/** A layer of data on a surface. */
|
|
214
|
+
export type Layer = PointsLayer | LinesLayer | ArrowsLayer | TextLayer | HeatmapLayer | HexbinLayer | ZonesLayer | ContourLayer | LegendLayer | NetworkLayer | FormationLayer | VoronoiLayer | DelaunayLayer | HullLayer | FlowLayer | SonarLayer;
|
|
215
|
+
/** The kinds of layer. */
|
|
216
|
+
export type LayerKind = Layer["kind"];
|
|
217
|
+
/** What `layerTable` takes. */
|
|
218
|
+
export interface TableOptions {
|
|
219
|
+
language?: "en" | "ja";
|
|
220
|
+
/** The most rows to write for one layer. 500 by default; the caption says when rows are left out. */
|
|
221
|
+
maxRows?: number;
|
|
222
|
+
/** A class for each table. `ky-table` by default. */
|
|
223
|
+
className?: string;
|
|
224
|
+
/** The drawing's options (at least `sport`, and `park`, `pitch`, `units` and `language` where they apply): needed for the tables of heat maps, hexagon maps, zone charts and contours, whose cells and zones follow the surface. Without it those layers' marks are listed as points. */
|
|
225
|
+
surface?: SurfaceOptions | ScoreOptions;
|
|
226
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type Background } from "./background.ts";
|
|
2
|
+
import type { MarkShape } from "./layers.types.ts";
|
|
3
|
+
import type { Language, ScoreOptions, SurfaceOptions } from "./types.ts";
|
|
4
|
+
/** The sizes a grid is made for: a social card, a square post and a phone's width. */
|
|
5
|
+
export type GridPreset = "card" | "square" | "phone";
|
|
6
|
+
/** What a preset fixes: the size in pixels (a height of `undefined` is whatever the drawings need), the columns, and whether the page has a ground of its own. */
|
|
7
|
+
export interface GridPresetInfo {
|
|
8
|
+
readonly width: number;
|
|
9
|
+
readonly height: number | undefined;
|
|
10
|
+
readonly columns: number | undefined;
|
|
11
|
+
/** The ground behind the grid when `background` says nothing: a solid one for a picture that will be posted, none for a phone's page. */
|
|
12
|
+
readonly ground: boolean;
|
|
13
|
+
readonly about: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The presets of `drawGrid`: `card` is 1200 by 675 (the 16:9 card that social sites show for a link), `square` is 1080 by 1080, and `phone` is 390 wide in one column with
|
|
17
|
+
* the height the drawings need. A `width`, a `height` or `columns` in the options wins over the preset's.
|
|
18
|
+
*/
|
|
19
|
+
export declare const GRID_PRESETS: Readonly<Record<GridPreset, GridPresetInfo>>;
|
|
20
|
+
/** One mark of the key: what it means, in what colour and shape. */
|
|
21
|
+
export interface GridLegendItem {
|
|
22
|
+
/** What the mark means. */
|
|
23
|
+
label: string;
|
|
24
|
+
/** The mark's colour (`safeColour`); the layers' own when missing. */
|
|
25
|
+
color?: string;
|
|
26
|
+
/** The mark's shape. A circle by default. */
|
|
27
|
+
shape?: MarkShape;
|
|
28
|
+
/** Drawn open, as a miss or a save is. */
|
|
29
|
+
hollow?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** What a cell holds: the options of `drawKyogijo`, a drawing's SVG, or a chart (anything with a `draw()` that returns an SVG). */
|
|
32
|
+
export type GridDrawing = string | SurfaceOptions | ScoreOptions | {
|
|
33
|
+
draw(): string;
|
|
34
|
+
};
|
|
35
|
+
/** A drawing and the caption written over it. A cell may also be the drawing alone. */
|
|
36
|
+
export interface GridCell {
|
|
37
|
+
drawing: GridDrawing;
|
|
38
|
+
/** A caption over the drawing (one line, made smaller to fit). The drawing keeps its own title and description for a screen reader. */
|
|
39
|
+
label?: string;
|
|
40
|
+
}
|
|
41
|
+
/** What `drawGrid` takes. */
|
|
42
|
+
export interface GridOptions {
|
|
43
|
+
/** A size to fit: `card`, `square` or `phone` (see `GRID_PRESETS`). */
|
|
44
|
+
preset?: GridPreset;
|
|
45
|
+
/** The drawings in a row. By default the number that makes the drawings largest in a fixed size, else as many as fit with a cell at least 280 wide. */
|
|
46
|
+
columns?: number;
|
|
47
|
+
/** The space between cells, in the grid's units. About a sixtieth of the width by default. */
|
|
48
|
+
gap?: number;
|
|
49
|
+
/** The width of the picture. The preset's, else 960. */
|
|
50
|
+
width?: number;
|
|
51
|
+
/** The height of the picture. The preset's; without one, the drawings decide. */
|
|
52
|
+
height?: number;
|
|
53
|
+
/** The title, set at the top. It is also the group's accessible title. */
|
|
54
|
+
title?: string;
|
|
55
|
+
/** The line under the title. */
|
|
56
|
+
subtitle?: string;
|
|
57
|
+
/** The line at the foot: a credit, a source, a date. */
|
|
58
|
+
endnote?: string;
|
|
59
|
+
/** The key the drawings share, set under the title. */
|
|
60
|
+
legend?: readonly GridLegendItem[];
|
|
61
|
+
/** The ground behind everything: a pattern, a colour, a photograph. See `BackgroundOptions`. `card` and `square` have a plain one unless it is `"none"`. */
|
|
62
|
+
background?: Background;
|
|
63
|
+
/** The language of the grid's own words: its accessible title and description. Drawings given as options take it too, unless they have their own. */
|
|
64
|
+
language?: Language;
|
|
65
|
+
/** Force light or dark on the grid and on every drawing in it. Without it the grid follows the device and the page, like a drawing does. */
|
|
66
|
+
theme?: "light" | "dark";
|
|
67
|
+
/** A prefix for the ids in the picture. Made from the grid when missing. */
|
|
68
|
+
id?: string;
|
|
69
|
+
/** The group's accessible title in place of `title`, for a grid whose visible title says too little. */
|
|
70
|
+
label?: string;
|
|
71
|
+
/** The group's description, in place of the one made from the drawings' titles. */
|
|
72
|
+
description?: string;
|
|
73
|
+
/** A class for the root, as in `drawKyogijo`. */
|
|
74
|
+
className?: string;
|
|
75
|
+
/** `none` leaves the stylesheet to the page (`KYOGIJO_STYLE` has every rule). */
|
|
76
|
+
style?: "embed" | "none";
|
|
77
|
+
}
|
|
78
|
+
/** The most drawings a grid takes. */
|
|
79
|
+
export declare const GRID_MAX_CELLS = 200;
|
|
80
|
+
/**
|
|
81
|
+
* Many drawings in one SVG, as small multiples: one per park, per period or per player, in columns, under a title and a subtitle and over a credit line, with a key they share.
|
|
82
|
+
* A cell is the options of `drawKyogijo`, a drawing's SVG, a chart, or `{ drawing, label }`. Every drawing keeps its own title and description for a screen reader, with ids
|
|
83
|
+
* of its own, so that the same drawing may appear twice; the group has a title and a description made from them. Each is drawn at the largest size its cell allows, the
|
|
84
|
+
* last row centred. `preset` fits a social card (`card`, 1200 by 675; `square`, 1080 by 1080) or a phone (`phone`, 390 wide in one column); without a size the grid is 960
|
|
85
|
+
* wide and as tall as the drawings need. The scene and every renderer read it like any other drawing. The same cells and options always give the same string.
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { drawGrid } from "@johnmorrisdotca/kyogijo-stadiums/layouts";
|
|
89
|
+
* const svg = drawGrid(
|
|
90
|
+
* [{ drawing: { sport: "nhl" }, label: "Rink" }, { drawing: { sport: "nba" }, label: "Court" }],
|
|
91
|
+
* { columns: 2, title: "Two surfaces", endnote: "Drawn by Kyogijo" },
|
|
92
|
+
* );
|
|
93
|
+
* console.log(svg.startsWith("<svg"), svg.includes("Two surfaces"));
|
|
94
|
+
* // true true
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function drawGrid(cells: readonly (GridCell | GridDrawing)[], options?: GridOptions): string;
|