@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,86 @@
|
|
|
1
|
+
// The Gaelic games' field plan: GAA Rule 1 (football and hurling share the field), in the frame of a drawing lying wide: x from the left end line, y from the top sideline, in feet.
|
|
2
|
+
import { METRE, arc, at, box, dashesAlongY, dot, endZones, line, middlePlate, poly, sizeIn } from "../fields.kit.js";
|
|
3
|
+
import { gaelicInFeet } from "../leagues/gaelic.js";
|
|
4
|
+
const DEG = 180 / Math.PI;
|
|
5
|
+
/**
|
|
6
|
+
* The plan of the field of a code at the size asked for (or the greatest the rules allow). Lines across at 13, 20, 45 (and, in hurling, 65) m from each end line; the 10 m midline, with dashes of 5 m marked out from its
|
|
7
|
+
* ends at intervals of 5 m to the sidelines; the two rectangles in front of each goal; a 13 m arc on each 20 m line; in football, the 40 m arc round the middle of the goal line outside the 20 m line and the penalty point.
|
|
8
|
+
* The dashes start where the midline ends: the rule says they are "marked out from the 10m midline, at intervals of 5m", and does not say whether a gap comes first.
|
|
9
|
+
*/
|
|
10
|
+
export function gaelicPlan(league, field, askedUnit, full) {
|
|
11
|
+
const s = gaelicInFeet(league.dimensions, league.unit);
|
|
12
|
+
const L = sizeIn(s.length, field?.length, askedUnit, league.unit, "The length");
|
|
13
|
+
const W = sizeIn(s.width, field?.width, askedUnit, league.unit, "The width");
|
|
14
|
+
const cx = L / 2;
|
|
15
|
+
const cy = W / 2;
|
|
16
|
+
const w = s.lineWidth;
|
|
17
|
+
const shapes = [box("boundary", "boundary", 0, 0, L, W, { w })];
|
|
18
|
+
const ends = [{ x0: 0, sign: 1 }, { x0: L, sign: -1 }];
|
|
19
|
+
const half = s.postsApart / 2;
|
|
20
|
+
for (const e of ends) {
|
|
21
|
+
for (const d of s.lines) {
|
|
22
|
+
shapes.push(line("distance-line", "distance-lines", e.x0 + e.sign * d, 0, e.x0 + e.sign * d, W, { w }));
|
|
23
|
+
if (full)
|
|
24
|
+
for (const y of [0, W])
|
|
25
|
+
shapes.push(dot("flag", "flags", e.x0 + e.sign * d, y, 0.4, "post"));
|
|
26
|
+
}
|
|
27
|
+
for (const side of [-1, 1])
|
|
28
|
+
shapes.push(dot("goalpost", "posts", e.x0, cy + side * half, 0.45, "post"));
|
|
29
|
+
for (const [name, r] of [["small-rectangle", s.small], ["large-rectangle", s.large]]) {
|
|
30
|
+
const y = half + r.outside;
|
|
31
|
+
shapes.push(poly(name, "rectangles", [[e.x0, cy - y], [e.x0 + e.sign * r.depth, cy - y], [e.x0 + e.sign * r.depth, cy + y], [e.x0, cy + y]], { w }));
|
|
32
|
+
}
|
|
33
|
+
const d20 = s.lines[1];
|
|
34
|
+
const centre = e.x0 + e.sign * d20;
|
|
35
|
+
shapes.push(arc("thirteen-metre-arc", "arcs", centre, cy, s.arc, e.sign === 1 ? -90 : 270, e.sign === 1 ? 90 : 90, { w }));
|
|
36
|
+
if (s.footballArc !== null) {
|
|
37
|
+
const t = Math.acos(d20 / s.footballArc) * DEG;
|
|
38
|
+
shapes.push(arc("forty-metre-arc", "arcs", e.x0, cy, s.footballArc, e.sign === 1 ? -t : 180 + t, e.sign === 1 ? t : 180 - t, { w }));
|
|
39
|
+
}
|
|
40
|
+
if (s.penaltyPoint !== null)
|
|
41
|
+
shapes.push(dot("penalty-point", "penalty-points", e.x0 + e.sign * s.penaltyPoint, cy, 0.3));
|
|
42
|
+
}
|
|
43
|
+
// The half-way line: a solid midline in the middle, and dashes marked out from its ends.
|
|
44
|
+
shapes.push(line("midline", "midline", cx, cy - s.midline / 2, cx, cy + s.midline / 2, { w }));
|
|
45
|
+
const dashes = dashesAlongY("midline-dash", "midline", cx, cy + s.midline / 2, W, s.dash, s.dash, { w });
|
|
46
|
+
shapes.push(...dashes, ...dashes.map((d) => line("midline-dash", "midline", cx, W - d.y1, cx, W - d.y0, { w })));
|
|
47
|
+
const lr = s.large.outside + half;
|
|
48
|
+
const zones = endZones(L, W, s.lines[1], W * 0.5);
|
|
49
|
+
const d20 = s.lines[1];
|
|
50
|
+
const marks = [
|
|
51
|
+
{ id: "end-line", x: w / 2, y: W * 0.15, side: "top" },
|
|
52
|
+
{ id: "sideline", x: L * 0.3, y: 0, side: "top" },
|
|
53
|
+
{ id: "distance-line", x: s.lines[0], y: W, side: "bottom" },
|
|
54
|
+
{ id: "distance-line", x: d20, y: 0, side: "top" },
|
|
55
|
+
{ id: "distance-line", x: s.lines[2], y: W, side: "bottom" },
|
|
56
|
+
{ id: "large-rectangle", x: s.large.depth / 2, y: cy - lr, side: "top" },
|
|
57
|
+
{ id: "small-rectangle", x: s.small.depth / 2, y: cy + half + s.small.outside, side: "bottom" },
|
|
58
|
+
{ id: "thirteen-metre-arc", x: d20 + s.arc, y: cy, side: "top" },
|
|
59
|
+
{ id: "halfway-line", x: cx, y: 0, side: "top" },
|
|
60
|
+
{ id: "goal-posts", x: 0, y: cy - half, side: "top" },
|
|
61
|
+
];
|
|
62
|
+
if (s.footballArc !== null)
|
|
63
|
+
marks.push({ id: "forty-metre-arc", x: s.footballArc, y: cy + 0.4 * s.footballArc, side: "bottom" }, { id: "penalty-point", x: s.penaltyPoint, y: cy, side: "bottom" });
|
|
64
|
+
return {
|
|
65
|
+
sport: "gaelic",
|
|
66
|
+
league: league.id,
|
|
67
|
+
length: L,
|
|
68
|
+
width: W,
|
|
69
|
+
outline: { kind: "rect" },
|
|
70
|
+
margin: 5 * METRE,
|
|
71
|
+
lineWidth: w,
|
|
72
|
+
drawnLine: Math.max(w, L * 0.0009),
|
|
73
|
+
band: L / 21,
|
|
74
|
+
areas: [],
|
|
75
|
+
shapes,
|
|
76
|
+
goals: [],
|
|
77
|
+
left: zones.left,
|
|
78
|
+
right: zones.right,
|
|
79
|
+
plate: middlePlate(L, W, L * 0.34, L * 0.17),
|
|
80
|
+
ranges: {
|
|
81
|
+
half: { left: at(0, 0, cx, W), right: at(cx, 0, L, W) },
|
|
82
|
+
"large-rectangle": { left: at(0, cy - lr, s.large.depth, cy + lr), right: at(L - s.large.depth, cy - lr, L, cy + lr) },
|
|
83
|
+
},
|
|
84
|
+
marks,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FieldPlan } from "../fields.types.ts";
|
|
2
|
+
import { type HandballLeague } from "../leagues/handball.ts";
|
|
3
|
+
import type { FieldStyle } from "../types.ts";
|
|
4
|
+
import type { Unit } from "../units.ts";
|
|
5
|
+
/** The plan of the court. `full` adds the substitution lines' end marks. */
|
|
6
|
+
export declare function handballPlan(league: HandballLeague, field: FieldStyle | undefined, askedUnit: Unit, full: boolean): FieldPlan;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// The handball court's plan, in the frame of a drawing lying wide: x from the outer edge of the left goal line, y from the outer edge of the top side line, in feet. "All lines on the court are fully part of the area that they
|
|
2
|
+
// enclose": the court's 40 by 20 m is to the outer edges of its lines, and the goal-area line's 6 m is to its front edge.
|
|
3
|
+
import { METRE, arc, at, box, dot, endZones, line, middlePlate, path, ring, sizeIn } from "../fields.kit.js";
|
|
4
|
+
import { handballInFeet } from "../leagues/handball.js";
|
|
5
|
+
import { num } from "../format.js";
|
|
6
|
+
/** The plan of the court. `full` adds the substitution lines' end marks. */
|
|
7
|
+
export function handballPlan(league, field, askedUnit, full) {
|
|
8
|
+
const s = handballInFeet(league.dimensions, league.unit);
|
|
9
|
+
const L = sizeIn(s.length, field?.length, askedUnit, league.unit, "The length");
|
|
10
|
+
const W = sizeIn(s.width, field?.width, askedUnit, league.unit, "The width");
|
|
11
|
+
const cx = L / 2;
|
|
12
|
+
const cy = W / 2;
|
|
13
|
+
const w = s.lineWidth;
|
|
14
|
+
const h = s.goalWidth / 2;
|
|
15
|
+
const a = s.areaLine / 2;
|
|
16
|
+
const shapes = [box("boundary", "boundary", w / 2, w / 2, L - w / 2, W - w / 2, { w })];
|
|
17
|
+
const areas = [];
|
|
18
|
+
const goals = [];
|
|
19
|
+
shapes.push(line("centre-line", "centre-line", cx, 0, cx, W, { w }));
|
|
20
|
+
shapes.push(ring("throw-off-area", "centre-circle", cx, cy, s.throwOff / 2, s.throwOff / 2, { w }));
|
|
21
|
+
const R6 = s.areaDistance - w / 2;
|
|
22
|
+
const R9 = s.areaDistance + s.freeThrowOutside - w / 2;
|
|
23
|
+
for (const [x0, sign, end] of [[0, 1, "left"], [L, -1, "right"]]) {
|
|
24
|
+
// The goal-area line: a straight line `areaLine` long, 6 m from the goal line, and quarter circles of 6 m about the posts' rear inner corners.
|
|
25
|
+
shapes.push(line("goal-area-line", "goal-area-line", x0 + sign * R6, cy - a, x0 + sign * R6, cy + a, { w }));
|
|
26
|
+
shapes.push(arc("goal-area-arc", "goal-area-line", x0, cy - a, R6, sign === 1 ? -90 : 180, sign === 1 ? 0 : 270, { w }), arc("goal-area-arc", "goal-area-line", x0, cy + a, R6, sign === 1 ? 0 : 90, sign === 1 ? 90 : 180, { w }));
|
|
27
|
+
areas.push({ id: "goal-area", feature: "goal-areas", cls: "ky-key", d: `M${num(x0)} ${num(cy - a - R6)}A${num(R6)} ${num(R6)} 0 0 ${sign === 1 ? 1 : 0} ${num(x0 + sign * R6)} ${num(cy - a)}V${num(cy + a)}A${num(R6)} ${num(R6)} 0 0 ${sign === 1 ? 1 : 0} ${num(x0)} ${num(cy + a + R6)}Z` });
|
|
28
|
+
// The free-throw line: broken, 3 m outside the goal-area line, segments and spaces of 15 cm, from its middle outwards.
|
|
29
|
+
const dash = [s.freeThrowDash, s.freeThrowDash];
|
|
30
|
+
// The arcs of the free-throw line reach the side lines (the court is 20 m wide, the goal area and the 3 m round it are wider): they stop there.
|
|
31
|
+
const reach = Math.min(1, (cy - a) / R9);
|
|
32
|
+
const ex = x0 + sign * R9 * Math.sqrt(1 - reach * reach);
|
|
33
|
+
const ey = R9 * reach;
|
|
34
|
+
const top = `M${num(x0 + sign * R9)} ${num(cy)}V${num(cy - a)}A${num(R9)} ${num(R9)} 0 0 ${sign === 1 ? 0 : 1} ${num(ex)} ${num(cy - a - ey)}`;
|
|
35
|
+
const bottom = `M${num(x0 + sign * R9)} ${num(cy)}V${num(cy + a)}A${num(R9)} ${num(R9)} 0 0 ${sign === 1 ? 1 : 0} ${num(ex)} ${num(cy + a + ey)}`;
|
|
36
|
+
shapes.push(path("free-throw-line", "free-throw-line", top, { w, dash, least: w }), path("free-throw-line", "free-throw-line", bottom, { w, dash, least: w }));
|
|
37
|
+
shapes.push(line("seven-metre-line", "seven-metre-line", x0 + sign * (s.sevenDistance - w / 2), cy - s.sevenLine / 2, x0 + sign * (s.sevenDistance - w / 2), cy + s.sevenLine / 2, { w }));
|
|
38
|
+
shapes.push(line("four-metre-line", "four-metre-line", x0 + sign * (s.fourDistance - w / 2), cy - s.fourLine / 2, x0 + sign * (s.fourDistance - w / 2), cy + s.fourLine / 2, { w }));
|
|
39
|
+
shapes.push(line("goal-line", "goal-lines", x0 + (sign * s.goalLineWidth) / 2, cy - h, x0 + (sign * s.goalLineWidth) / 2, cy + h, { w: s.goalLineWidth }));
|
|
40
|
+
for (const side of [-1, 1])
|
|
41
|
+
shapes.push(dot("goal-post", "goal-posts", x0 + (sign * s.goalLineWidth) / 2, cy + side * h, 0.25, "post"));
|
|
42
|
+
goals.push({ end, x: x0 + (sign * s.goalLineWidth) / 2, y: cy, width: s.goalWidth, depth: s.goalDepth, out: (sign === 1 ? -1 : 1) });
|
|
43
|
+
}
|
|
44
|
+
if (full) {
|
|
45
|
+
// The substitution line: a segment of the side line from the centre line to 4.5 m, its end a line across the side line, 15 cm inside it and 15 cm outside.
|
|
46
|
+
for (const sign of [-1, 1])
|
|
47
|
+
shapes.push(line("substitution-line", "substitution-lines", cx + sign * s.substitution, W - w - s.substitutionMark, cx + sign * s.substitution, W + s.substitutionMark, { w }));
|
|
48
|
+
}
|
|
49
|
+
const reach = a + R6;
|
|
50
|
+
const zones = endZones(L, W, s.areaDistance, W * 0.5);
|
|
51
|
+
const marks = [
|
|
52
|
+
{ id: "sideline", x: L * 0.3, y: 0, side: "top" },
|
|
53
|
+
{ id: "goal-line", x: w, y: W * 0.15, side: "top" },
|
|
54
|
+
{ id: "centre-line", x: cx, y: W, side: "bottom" },
|
|
55
|
+
{ id: "goal-area-line", x: R6, y: cy + a, side: "bottom" },
|
|
56
|
+
{ id: "free-throw-line", x: R9, y: cy - a, side: "top" },
|
|
57
|
+
{ id: "seven-metre-line", x: s.sevenDistance, y: cy + s.sevenLine / 2, side: "bottom" },
|
|
58
|
+
{ id: "four-metre-line", x: s.fourDistance, y: cy - s.fourLine / 2, side: "top" },
|
|
59
|
+
{ id: "throw-off-area", x: cx + (s.throwOff / 2) * 0.7, y: cy + (s.throwOff / 2) * 0.7, side: "bottom" },
|
|
60
|
+
{ id: "goal", x: 0, y: cy - h, side: "top" },
|
|
61
|
+
];
|
|
62
|
+
return {
|
|
63
|
+
sport: "handball",
|
|
64
|
+
league: league.id,
|
|
65
|
+
length: L,
|
|
66
|
+
width: W,
|
|
67
|
+
outline: { kind: "rect" },
|
|
68
|
+
margin: 3 * METRE,
|
|
69
|
+
lineWidth: w,
|
|
70
|
+
drawnLine: Math.max(w, L * 0.0017),
|
|
71
|
+
band: 0,
|
|
72
|
+
surfaceFeature: "floor",
|
|
73
|
+
areas,
|
|
74
|
+
shapes,
|
|
75
|
+
goals,
|
|
76
|
+
left: zones.left,
|
|
77
|
+
right: zones.right,
|
|
78
|
+
plate: middlePlate(L, W, L * 0.34, L * 0.17),
|
|
79
|
+
ranges: {
|
|
80
|
+
half: { left: at(0, 0, cx, W), right: at(cx, 0, L, W) },
|
|
81
|
+
"goal-area": { left: at(0, cy - reach, R6 + w / 2, cy + reach), right: at(L - R6 - w / 2, cy - reach, L, cy + reach) },
|
|
82
|
+
},
|
|
83
|
+
marks,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FieldPlan } from "../fields.types.ts";
|
|
2
|
+
import type { LacrosseLeague } from "../leagues/lacrosse.ts";
|
|
3
|
+
import type { FieldStyle } from "../types.ts";
|
|
4
|
+
import type { Unit } from "../units.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Where a ray from a point on the goal line extended (at distance `start` from the middle of the goal line) at 45 degrees to that line meets the circle of radius `radius` about the middle of the goal line: the
|
|
7
|
+
* distance along the ray, and the angle of the meeting point from the middle, in degrees from the direction up the field. The women's game's arc (the NCAA's 8 m arc, World Lacrosse's 11 m marking area) ends there.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fortyFiveMeeting(start: number, radius: number): {
|
|
10
|
+
along: number;
|
|
11
|
+
angle: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The plan of a lacrosse surface of a league, at the size asked for (or the one drawn). The goals stand at `goalLine` from each end; the rest follows from the figures of the league's kind: a floor with boards and
|
|
15
|
+
* a crease cut by a flat; the men's fields' crease circle, goal mouth and attack-area lines; the women's goal circle, marking areas and fans; the PLL's two-point arc.
|
|
16
|
+
*/
|
|
17
|
+
export declare function lacrossePlan(league: LacrosseLeague, field: FieldStyle | undefined, askedUnit: Unit, full: boolean): FieldPlan;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// The lacrosse plans: the box floor of the NLL and of World Lacrosse (boards, the crease, the restraining lines, the face-off circle) and the fields of World Lacrosse, the NCAA and the PLL, in the frame of a
|
|
2
|
+
// drawing lying wide: x from the left end line (the end boards, on a floor), y from the top, in feet. Every figure is the league's (leagues/lacrosse.ts); the lines of the women's game follow the rule that
|
|
3
|
+
// draws them, and the arcs are solved from the distances the rules give.
|
|
4
|
+
import { METRE, arc, at, box, dot, endZones, line, middlePlate, poly, ring, sizeIn } from "../fields.kit.js";
|
|
5
|
+
import { lacrosseInFeet } from "../leagues/lacrosse.js";
|
|
6
|
+
const DEG = 180 / Math.PI;
|
|
7
|
+
/**
|
|
8
|
+
* Where a ray from a point on the goal line extended (at distance `start` from the middle of the goal line) at 45 degrees to that line meets the circle of radius `radius` about the middle of the goal line: the
|
|
9
|
+
* distance along the ray, and the angle of the meeting point from the middle, in degrees from the direction up the field. The women's game's arc (the NCAA's 8 m arc, World Lacrosse's 11 m marking area) ends there.
|
|
10
|
+
*/
|
|
11
|
+
export function fortyFiveMeeting(start, radius) {
|
|
12
|
+
const c = Math.SQRT1_2;
|
|
13
|
+
// |(t c, start + t c)| = radius.
|
|
14
|
+
const b = 2 * start * c;
|
|
15
|
+
const along = (-b + Math.sqrt(b * b - 4 * (start * start - radius * radius))) / 2;
|
|
16
|
+
return { along, angle: Math.atan2(start + along * c, along * c) * DEG };
|
|
17
|
+
}
|
|
18
|
+
/** The box floor's goal: the poles of 4 ft 6 in run back from the posts' bases until they meet, so the net is as deep as the apex of that triangle. */
|
|
19
|
+
const apexDepth = (pole, apart) => Math.sqrt(pole * pole - (apart / 2) ** 2);
|
|
20
|
+
/**
|
|
21
|
+
* The plan of a lacrosse surface of a league, at the size asked for (or the one drawn). The goals stand at `goalLine` from each end; the rest follows from the figures of the league's kind: a floor with boards and
|
|
22
|
+
* a crease cut by a flat; the men's fields' crease circle, goal mouth and attack-area lines; the women's goal circle, marking areas and fans; the PLL's two-point arc.
|
|
23
|
+
*/
|
|
24
|
+
export function lacrossePlan(league, field, askedUnit, full) {
|
|
25
|
+
const s = lacrosseInFeet(league.dimensions, league.unit);
|
|
26
|
+
const L = sizeIn(s.length, field?.length, askedUnit, league.unit, "The length");
|
|
27
|
+
const W = sizeIn(s.width, field?.width, askedUnit, league.unit, "The width");
|
|
28
|
+
const cx = L / 2;
|
|
29
|
+
const cy = W / 2;
|
|
30
|
+
const w = s.lineWidth;
|
|
31
|
+
const centreW = 2 * w;
|
|
32
|
+
const gl = s.goalLine;
|
|
33
|
+
const isBox = s.kind === "box";
|
|
34
|
+
const goalDepth = isBox ? apexDepth(s.netDepth, s.goalWidth) : s.netDepth;
|
|
35
|
+
const shapes = [];
|
|
36
|
+
const areas = [];
|
|
37
|
+
const goals = [];
|
|
38
|
+
const marks = [];
|
|
39
|
+
// One end at a time, drawn at the left (`sign` 1, x measured from the end line) and the right (`sign` -1).
|
|
40
|
+
const ends = [{ end: "left", sign: 1, x0: 0 }, { end: "right", sign: -1, x0: L }];
|
|
41
|
+
const X = (e, d) => e.x0 + e.sign * d;
|
|
42
|
+
const angle = (e, a) => (e.sign === 1 ? a : 180 - a);
|
|
43
|
+
// A floor is bounded by its boards, drawn as a frame; a field by its lines.
|
|
44
|
+
if (!isBox)
|
|
45
|
+
shapes.push(box("boundary", "boundary", 0, 0, L, W, { w }));
|
|
46
|
+
shapes.push(line("centre-line", "centre-line", cx, 0, cx, W, { w: centreW }));
|
|
47
|
+
for (const e of ends) {
|
|
48
|
+
const gx = X(e, gl);
|
|
49
|
+
shapes.push(line("goal-line", "goal-lines", gx, cy - s.goalWidth / 2, gx, cy + s.goalWidth / 2, { w }));
|
|
50
|
+
for (const sign of [-1, 1])
|
|
51
|
+
shapes.push(dot("goal-post", "goal-posts", gx, cy + (sign * s.goalWidth) / 2, Math.max(w * 1.2, 0.18), "post"));
|
|
52
|
+
goals.push({ end: e.end, x: gx, y: cy, width: s.goalWidth, depth: goalDepth, out: (e.sign === 1 ? -1 : 1) });
|
|
53
|
+
if (s.crease !== null && isBox) {
|
|
54
|
+
// The crease: a circle about the middle of the goal line, cut by a flat one foot behind the apex of the goal's poles.
|
|
55
|
+
const flat = goalDepth + s.creaseFlat;
|
|
56
|
+
const half = Math.acos(-flat / s.crease) * DEG;
|
|
57
|
+
const cw = s.creaseLine;
|
|
58
|
+
shapes.push(arc("crease", "crease", gx, cy, s.crease - cw / 2, angle(e, -half), angle(e, half), { w: cw }));
|
|
59
|
+
const fy = Math.sqrt(s.crease * s.crease - flat * flat);
|
|
60
|
+
shapes.push(line("crease-flat", "crease", gx - e.sign * flat, cy - fy, gx - e.sign * flat, cy + fy, { w: cw }));
|
|
61
|
+
}
|
|
62
|
+
else if (s.crease !== null)
|
|
63
|
+
shapes.push(ring("crease", "crease", gx, cy, s.crease, s.crease, { w }));
|
|
64
|
+
if (s.goalMouth !== null)
|
|
65
|
+
shapes.push(arc("goal-mouth", "crease", gx, cy, s.goalMouth, angle(e, -90), angle(e, 90), { w }));
|
|
66
|
+
if (s.goalCircle !== null)
|
|
67
|
+
shapes.push(ring("goal-circle", "crease", gx, cy, s.goalCircle, s.goalCircle, { w }));
|
|
68
|
+
if (s.restraining !== null)
|
|
69
|
+
shapes.push(line("restraining-line", "restraining-lines", X(e, gl + s.restraining), 0, X(e, gl + s.restraining), W, { w }));
|
|
70
|
+
if (s.restrainingFromCentre !== null)
|
|
71
|
+
shapes.push(line("restraining-line", "restraining-lines", cx - e.sign * s.restrainingFromCentre, 0, cx - e.sign * s.restrainingFromCentre, W, { w }));
|
|
72
|
+
if (s.attackHalf !== null && s.attackFrom !== null) {
|
|
73
|
+
const ax = X(e, gl + s.attackFrom);
|
|
74
|
+
for (const sign of [-1, 1])
|
|
75
|
+
shapes.push(line("attack-area-line", "restraining-lines", ax, cy + sign * s.attackHalf, e.x0, cy + sign * s.attackHalf, { w }));
|
|
76
|
+
}
|
|
77
|
+
if (s.semicircle !== null)
|
|
78
|
+
shapes.push(arc("marking-area", "arcs", gx, cy, s.semicircle, angle(e, -90), angle(e, 90), { w }));
|
|
79
|
+
if (s.arcFan !== null && s.goalCircle !== null) {
|
|
80
|
+
// From where the goal line extended meets the goal circle, a line at 45 degrees to it out to the arc, which runs between the two meeting points.
|
|
81
|
+
const meet = fortyFiveMeeting(s.goalCircle, s.arcFan);
|
|
82
|
+
for (const sign of [-1, 1]) {
|
|
83
|
+
const ex = gx + e.sign * meet.along * Math.SQRT1_2;
|
|
84
|
+
shapes.push(line("forty-five-line", "arcs", gx, cy + sign * s.goalCircle, ex, cy + sign * (s.goalCircle + meet.along * Math.SQRT1_2), { w }));
|
|
85
|
+
}
|
|
86
|
+
shapes.push(arc("fan", "arcs", gx, cy, s.arcFan, angle(e, -meet.angle), angle(e, meet.angle), { w }));
|
|
87
|
+
// World Lacrosse marks the goal line extended from the goal circle to the marking area.
|
|
88
|
+
if (league.id === "world-women")
|
|
89
|
+
for (const sign of [-1, 1])
|
|
90
|
+
shapes.push(line("goal-line-extended", "arcs", gx, cy + sign * s.goalCircle, gx, cy + sign * s.semicircle, { w }));
|
|
91
|
+
}
|
|
92
|
+
if (s.twoPoint !== null) {
|
|
93
|
+
// The two-point arc: from the goal line extended, 13 yards from the middle of the goal line, parallel to the sideline until it is 15 yards from the middle, then an arc of 15 yards across the field; and a line from each end of it to the end line.
|
|
94
|
+
const g = s.twoPoint.gle;
|
|
95
|
+
const r = s.twoPoint.radius;
|
|
96
|
+
const dx = Math.sqrt(r * r - g * g);
|
|
97
|
+
const phi = Math.asin(g / r) * DEG;
|
|
98
|
+
for (const sign of [-1, 1]) {
|
|
99
|
+
shapes.push(line("two-point-line", "arcs", e.x0, cy + sign * g, X(e, gl + dx), cy + sign * g, { w: centreW }));
|
|
100
|
+
}
|
|
101
|
+
shapes.push(arc("two-point-arc", "arcs", gx, cy, r, angle(e, -phi), angle(e, phi), { w: centreW }));
|
|
102
|
+
}
|
|
103
|
+
if (isBox) {
|
|
104
|
+
// The corner face-off spots: 5 yards from the boards and 5 yards inside the restraining lines.
|
|
105
|
+
const sx = cx - e.sign * (s.restrainingFromCentre + s.cornerSpotInside);
|
|
106
|
+
if (full)
|
|
107
|
+
for (const y of [s.cornerSpotWall, W - s.cornerSpotWall])
|
|
108
|
+
shapes.push(dot("face-off-spot", "face-off-spots", sx, y, 0.35));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (isBox) {
|
|
112
|
+
shapes.push(ring("face-off-circle", "face-off-circles", cx, cy, s.faceOffOuter, s.faceOffOuter, { w }));
|
|
113
|
+
if (full)
|
|
114
|
+
shapes.push(ring("face-off-dotted-circle", "face-off-circles", cx, cy, s.faceOffInner, s.faceOffInner, { w: w, dash: [0.12, 0.12] }));
|
|
115
|
+
areas.push({ id: "boards", feature: "boards", cls: "ky-boards", frame: { x0: 0, y0: 0, x1: L, y1: W, radius: s.cornerRadius, thick: 1.5 } });
|
|
116
|
+
}
|
|
117
|
+
if (s.wings !== null)
|
|
118
|
+
for (const sign of [-1, 1])
|
|
119
|
+
shapes.push(line("wing-line", "wing-lines", cx - s.wings.half, cy + sign * s.wings.from, cx + s.wings.half, cy + sign * s.wings.from, { w }));
|
|
120
|
+
if (s.centreCircle !== null)
|
|
121
|
+
shapes.push(ring("centre-circle", "centre-circle", cx, cy, s.centreCircle, s.centreCircle, { w }));
|
|
122
|
+
if (s.centreLine !== null)
|
|
123
|
+
shapes.push(line("centre-mark-line", "centre-line", cx, cy - s.centreLine / 2, cx, cy + s.centreLine / 2, { w: centreW }));
|
|
124
|
+
if (s.kind === "men") {
|
|
125
|
+
// The centre: an X (World Lacrosse) or a 4-inch square, drawn small.
|
|
126
|
+
const k = 0.35;
|
|
127
|
+
shapes.push(poly("centre-x", "centre-line", [[cx - k, cy - k], [cx + k, cy + k]], { w }), poly("centre-x", "centre-line", [[cx - k, cy + k], [cx + k, cy - k]], { w }));
|
|
128
|
+
}
|
|
129
|
+
const depth = Math.max(gl + (s.restraining ?? 0) * 0.5, L * 0.1);
|
|
130
|
+
const zones = endZones(L, W, depth, W * 0.8);
|
|
131
|
+
marks.push({ id: "end-line", x: w / 2, y: W * 0.2, side: "top" }, { id: "sideline", x: L * 0.3, y: 0, side: "top" }, { id: "centre-line", x: cx, y: W, side: "bottom" }, { id: "goal", x: gl, y: cy - s.goalWidth / 2, side: "top" }, { id: "crease", x: gl + (s.crease ?? s.goalCircle ?? 0) * 0.7, y: cy + (s.crease ?? s.goalCircle ?? 0) * 0.7, side: "bottom" });
|
|
132
|
+
if (s.restraining !== null)
|
|
133
|
+
marks.push({ id: "restraining-line", x: gl + s.restraining, y: W, side: "bottom" });
|
|
134
|
+
if (s.restrainingFromCentre !== null)
|
|
135
|
+
marks.push({ id: "restraining-line", x: cx - s.restrainingFromCentre, y: W, side: "bottom" });
|
|
136
|
+
if (isBox)
|
|
137
|
+
marks.push({ id: "boards", x: L * 0.12, y: W, side: "bottom" }, { id: "face-off-circle", x: cx + s.faceOffOuter * 0.7, y: cy - s.faceOffOuter * 0.7, side: "top" });
|
|
138
|
+
if (s.wings !== null)
|
|
139
|
+
marks.push({ id: "wing-line", x: cx, y: cy - s.wings.from, side: "top" });
|
|
140
|
+
if (s.twoPoint !== null)
|
|
141
|
+
marks.push({ id: "two-point-arc", x: gl + s.twoPoint.radius, y: cy, side: "top" });
|
|
142
|
+
if (s.semicircle !== null)
|
|
143
|
+
marks.push({ id: "marking-area", x: gl + s.semicircle, y: cy, side: "top" });
|
|
144
|
+
if (s.centreCircle !== null)
|
|
145
|
+
marks.push({ id: "centre-circle", x: cx + s.centreCircle * 0.7, y: cy + s.centreCircle * 0.7, side: "bottom" });
|
|
146
|
+
const crease = Math.max(s.crease ?? 0, s.goalCircle ?? 0, s.goalMouth ?? 0);
|
|
147
|
+
return {
|
|
148
|
+
sport: "lacrosse",
|
|
149
|
+
league: league.id,
|
|
150
|
+
length: L,
|
|
151
|
+
width: W,
|
|
152
|
+
outline: { kind: "rect", radius: isBox ? s.cornerRadius : undefined },
|
|
153
|
+
margin: isBox ? 6 : 5 * METRE,
|
|
154
|
+
lineWidth: w,
|
|
155
|
+
drawnLine: Math.max(w, L * 0.0009),
|
|
156
|
+
band: isBox ? 0 : L / 20,
|
|
157
|
+
areas,
|
|
158
|
+
shapes,
|
|
159
|
+
goals,
|
|
160
|
+
left: zones.left,
|
|
161
|
+
right: zones.right,
|
|
162
|
+
plate: middlePlate(L, W, L * 0.34, L * 0.17),
|
|
163
|
+
ranges: {
|
|
164
|
+
half: { left: at(0, 0, cx, W), right: at(cx, 0, L, W) },
|
|
165
|
+
crease: { left: at(0, cy - crease - 1, gl + crease + 1, cy + crease + 1), right: at(L - gl - crease - 1, cy - crease - 1, L, cy + crease + 1) },
|
|
166
|
+
},
|
|
167
|
+
marks,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FieldPlan } from "../fields.types.ts";
|
|
2
|
+
import { type RugbyLeague } from "../leagues/rugby.ts";
|
|
3
|
+
import type { FieldStyle } from "../types.ts";
|
|
4
|
+
import type { Unit } from "../units.ts";
|
|
5
|
+
/**
|
|
6
|
+
* The plan of a rugby field of a league, at the size asked for (or the one drawn). `full` adds the flag posts. Union: the half-way line, the 22-metre lines, the 10-metre dash lines, the dash lines 5 and
|
|
7
|
+
* 15 m from the touchlines and 5 m from the try lines (each dash 5 m, set where Law 1's ground diagram puts them), the half-way mark and the goal posts. League: a line across the field at every 10 m, the 20 m and 40 m
|
|
8
|
+
* lines red where the league has them, the scrum lines, and the goal posts.
|
|
9
|
+
*/
|
|
10
|
+
export declare function rugbyPlan(league: RugbyLeague, field: FieldStyle | undefined, askedUnit: Unit, full: boolean): FieldPlan;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// The rugby field's plan: World Rugby's Law 1 (union) and the NRL's and the IRL's playing field (league), in the frame of a drawing lying wide: x from the left dead-ball line, y from the top touchline, in feet.
|
|
2
|
+
// Where a size is asked for inside the range the rules allow, the lines that "reduce accordingly" (Law 1.3 c and d) are reduced in proportion: the Law says that they are, not by how much.
|
|
3
|
+
import { METRE, at, box, dashesAlongX, dot, endZones, line, middlePlate, sizeIn } from "../fields.kit.js";
|
|
4
|
+
import { rugbyInFeet } from "../leagues/rugby.js";
|
|
5
|
+
/**
|
|
6
|
+
* The plan of a rugby field of a league, at the size asked for (or the one drawn). `full` adds the flag posts. Union: the half-way line, the 22-metre lines, the 10-metre dash lines, the dash lines 5 and
|
|
7
|
+
* 15 m from the touchlines and 5 m from the try lines (each dash 5 m, set where Law 1's ground diagram puts them), the half-way mark and the goal posts. League: a line across the field at every 10 m, the 20 m and 40 m
|
|
8
|
+
* lines red where the league has them, the scrum lines, and the goal posts.
|
|
9
|
+
*/
|
|
10
|
+
export function rugbyPlan(league, field, askedUnit, full) {
|
|
11
|
+
const s = rugbyInFeet(league.dimensions, league.unit);
|
|
12
|
+
const len = sizeIn(s.length, field?.length, askedUnit, league.unit, "The length");
|
|
13
|
+
const wid = sizeIn(s.width, field?.width, askedUnit, league.unit, "The width");
|
|
14
|
+
const ing = sizeIn(s.inGoal, field?.inGoal, askedUnit, league.unit, "The in-goal depth");
|
|
15
|
+
const L = len + 2 * ing;
|
|
16
|
+
const W = wid;
|
|
17
|
+
const cx = L / 2;
|
|
18
|
+
const cy = W / 2;
|
|
19
|
+
const t0 = ing;
|
|
20
|
+
const t1 = ing + len;
|
|
21
|
+
const w = s.lineWidth;
|
|
22
|
+
const shapes = [box("dead-ball-line", "boundary", 0, 0, L, W, { w })];
|
|
23
|
+
for (const x of [t0, t1])
|
|
24
|
+
for (const sign of [-1, 1])
|
|
25
|
+
shapes.push(dot("goal-post", "posts", x, cy + (sign * s.postsApart) / 2, Math.max(w * 0.9, 0.2), "post"));
|
|
26
|
+
for (const x of [t0, t1])
|
|
27
|
+
shapes.push(line("try-line", "try-lines", x, 0, x, W, { w }));
|
|
28
|
+
let marks;
|
|
29
|
+
let twenty;
|
|
30
|
+
if (s.code === "union") {
|
|
31
|
+
const lengthRatio = len / s.length.max;
|
|
32
|
+
const widthRatio = wid / s.width.max;
|
|
33
|
+
const d22 = s.twentyTwo * lengthRatio;
|
|
34
|
+
const d10 = s.tenFromHalfway * lengthRatio;
|
|
35
|
+
const dash = s.dash;
|
|
36
|
+
const t5 = s.dashFromTry;
|
|
37
|
+
const [a5, a15] = s.dashFromTouch;
|
|
38
|
+
const near15 = a15 * widthRatio;
|
|
39
|
+
twenty = d22;
|
|
40
|
+
shapes.push(line("halfway-line", "halfway-line", cx, 0, cx, W, { w }));
|
|
41
|
+
for (const x of [t0 + d22, t1 - d22])
|
|
42
|
+
shapes.push(line("twenty-two-line", "twenty-two-lines", x, 0, x, W, { w }));
|
|
43
|
+
// The dash lines across the field are dashes of `dash` set 5 m, 10 m and 20 m apart by the diagram: at the 10-metre lines at the middle, 10 m either side of it and over the 5 m and 15 m lines; 5 m from the try lines 5 m either side of
|
|
44
|
+
// the middle and over the 5 m and 15 m lines.
|
|
45
|
+
const across = (x, offsets, id) => offsets.map((o) => line(id, "dash-lines", x, cy + o - dash / 2, x, cy + o + dash / 2, { w }));
|
|
46
|
+
const offs15 = [wid / 2 - near15, wid / 2 - a5];
|
|
47
|
+
const tenOffsets = [0, 10 * METRE, -10 * METRE, ...offs15, ...offs15.map((o) => -o)];
|
|
48
|
+
const tryOffsets = [5 * METRE, -5 * METRE, ...offs15, ...offs15.map((o) => -o)];
|
|
49
|
+
for (const x of [cx - d10, cx + d10])
|
|
50
|
+
shapes.push(...across(x, tenOffsets, "ten-metre-line"));
|
|
51
|
+
for (const x of [t0 + t5, t1 - t5])
|
|
52
|
+
shapes.push(...across(x, tryOffsets, "five-metre-line"));
|
|
53
|
+
// The dash lines along the field, 5 m and 15 m from each touchline: from the 5 m line a dash, then one over each 22-metre line, 10-metre line and the half-way line, and a last dash 5 m from the far try line.
|
|
54
|
+
const centres = [t0 + d22, cx - d10, cx, cx + d10, t1 - d22];
|
|
55
|
+
for (const y of [a5, near15, wid - near15, wid - a5]) {
|
|
56
|
+
shapes.push(line("dash-line", "dash-lines", t0 + t5, y, t0 + t5 + dash, y, { w }));
|
|
57
|
+
for (const x of centres)
|
|
58
|
+
shapes.push(line("dash-line", "dash-lines", x - dash / 2, y, x + dash / 2, y, { w }));
|
|
59
|
+
shapes.push(line("dash-line", "dash-lines", t1 - t5 - dash, y, t1 - t5, y, { w }));
|
|
60
|
+
}
|
|
61
|
+
shapes.push(line("halfway-mark", "halfway-line", cx - s.halfwayMark / 2, cy, cx + s.halfwayMark / 2, cy, { w }));
|
|
62
|
+
if (full)
|
|
63
|
+
for (const [x, y] of [[t0, 0], [t0, W], [t1, 0], [t1, W], [0, 0], [0, W], [L, 0], [L, W], ...[t0 + d22, cx, t1 - d22].flatMap((x) => [[x, -s.flagsOutside], [x, W + s.flagsOutside]])])
|
|
64
|
+
shapes.push(dot("flag-post", "flags", x, y, 0.35, "post"));
|
|
65
|
+
marks = [
|
|
66
|
+
{ id: "try-line", x: t0 - 0, y: W * 0.2, side: "top" },
|
|
67
|
+
{ id: "dead-ball-line", x: w / 2, y: W * 0.8, side: "bottom" },
|
|
68
|
+
{ id: "touchline", x: L * 0.3, y: 0, side: "top" },
|
|
69
|
+
{ id: "twenty-two-line", x: t0 + d22, y: W, side: "bottom" },
|
|
70
|
+
{ id: "ten-metre-line", x: cx - d10, y: 0, side: "top" },
|
|
71
|
+
{ id: "halfway-line", x: cx, y: W, side: "bottom" },
|
|
72
|
+
{ id: "in-goal", x: ing / 2, y: cy, side: "top" },
|
|
73
|
+
{ id: "goal-posts", x: t0, y: cy - s.postsApart / 2, side: "top" },
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const step = s.step;
|
|
78
|
+
twenty = 2 * step;
|
|
79
|
+
shapes.push(line("halfway-line", "halfway-line", cx, 0, cx, W, { w }));
|
|
80
|
+
for (let k = 1; k * step < len / 2 - 1e-6; k += 1) {
|
|
81
|
+
const red = s.red.some((r) => Math.abs(r - k * step) < 1e-6);
|
|
82
|
+
for (const x of [t0 + k * step, t1 - k * step])
|
|
83
|
+
shapes.push(line(red ? "red-line" : "ten-metre-line", red ? "red-lines" : "ten-metre-lines", x, 0, x, W, { w, cls: red ? "ky-red" : "ky-line" }));
|
|
84
|
+
}
|
|
85
|
+
for (const d of s.scrum)
|
|
86
|
+
for (const y of [d, W - d])
|
|
87
|
+
shapes.push(...dashesAlongX("scrum-line", "scrum-lines", y, t0, t1, METRE, METRE, { w: s.scrumWidth ?? w }));
|
|
88
|
+
if (full)
|
|
89
|
+
for (const [x, y] of [[t0, 0], [t0, W], [t1, 0], [t1, W]])
|
|
90
|
+
shapes.push(dot("corner-post", "flags", x, y, 0.35, "post"));
|
|
91
|
+
marks = [
|
|
92
|
+
{ id: "goal-line", x: t0, y: W * 0.2, side: "top" },
|
|
93
|
+
{ id: "dead-ball-line", x: w / 2, y: W * 0.8, side: "bottom" },
|
|
94
|
+
{ id: "touchline", x: L * 0.3, y: 0, side: "top" },
|
|
95
|
+
{ id: "ten-metre-line", x: t0 + step, y: W, side: "bottom" },
|
|
96
|
+
{ id: "halfway-line", x: cx, y: W, side: "bottom" },
|
|
97
|
+
{ id: "in-goal", x: ing / 2, y: cy, side: "top" },
|
|
98
|
+
{ id: "goal-posts", x: t0, y: cy - s.postsApart / 2, side: "top" },
|
|
99
|
+
];
|
|
100
|
+
if (s.red.length > 0)
|
|
101
|
+
marks.push({ id: "forty-metre-line", x: t0 + (s.red[s.red.length - 1] ?? 40 * METRE), y: 0, side: "top" });
|
|
102
|
+
}
|
|
103
|
+
const zones = endZones(L, W, ing, W);
|
|
104
|
+
const plate = middlePlate(L, W, L * 0.34, L * 0.17);
|
|
105
|
+
return {
|
|
106
|
+
sport: "rugby",
|
|
107
|
+
league: league.id,
|
|
108
|
+
length: L,
|
|
109
|
+
width: W,
|
|
110
|
+
outline: { kind: "rect" },
|
|
111
|
+
margin: 5 * METRE,
|
|
112
|
+
lineWidth: w,
|
|
113
|
+
drawnLine: Math.max(w, L * 0.0009),
|
|
114
|
+
band: len / 20,
|
|
115
|
+
areas: [],
|
|
116
|
+
shapes,
|
|
117
|
+
goals: [],
|
|
118
|
+
left: zones.left,
|
|
119
|
+
right: zones.right,
|
|
120
|
+
plate,
|
|
121
|
+
ends: { left: at(0, 0, ing, W), right: at(L - ing, 0, L, W) },
|
|
122
|
+
endFeature: "in-goal",
|
|
123
|
+
ranges: {
|
|
124
|
+
half: { left: at(0, 0, cx, W), right: at(cx, 0, L, W) },
|
|
125
|
+
[s.code === "union" ? "twenty-two" : "twenty"]: { left: at(t0, 0, t0 + twenty, W), right: at(t1 - twenty, 0, t1, W) },
|
|
126
|
+
"in-goal": { left: at(0, 0, ing, W), right: at(L - ing, 0, L, W) },
|
|
127
|
+
},
|
|
128
|
+
marks,
|
|
129
|
+
};
|
|
130
|
+
}
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FieldPlan } from "./fields.types.ts";
|
|
2
|
+
import type { FieldSport, SurfaceOptions } from "./types.ts";
|
|
3
|
+
export type { FieldPlan } from "./fields.types.ts";
|
|
4
|
+
/** The field sports, in the order a menu lists them. */
|
|
5
|
+
export declare const FIELD_SPORTS: readonly FieldSport[];
|
|
6
|
+
/** True for a sport whose surface is a field sport's. */
|
|
7
|
+
export declare const isFieldSport: (sport: string) => sport is FieldSport;
|
|
8
|
+
/**
|
|
9
|
+
* The plan the options ask for. A `league` picks the rulebook (the sport's own first one by default); `field` a size within its range and the sport's own parameters; `detail: "simple"` leaves out the small marks.
|
|
10
|
+
* @throws RangeError when a size is outside the league's range, and Error when the ground or the look is not one the sport has.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fieldPlan(o: Pick<SurfaceOptions, "sport" | "league" | "field" | "units" | "detail">): FieldPlan;
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// What a field sport's surface is for a set of options: the league's figures, the size asked for, and the plan that follows. Kept apart from the drawing so that the outline, the description, the ranges, the tests
|
|
2
|
+
// and the drawing agree. Every length that is a rulebook's figure is cited in docs/sources.md; what is ours (the width a line is drawn at where a book prints none, the size drawn within a range) is said to be.
|
|
3
|
+
import { aflPlan } from "./fields/afl.js";
|
|
4
|
+
import { cricketPlan } from "./fields/cricket.js";
|
|
5
|
+
import { fieldHockeyPlan } from "./fields/fieldhockey.js";
|
|
6
|
+
import { gaelicPlan } from "./fields/gaelic.js";
|
|
7
|
+
import { handballPlan } from "./fields/handball.js";
|
|
8
|
+
import { lacrossePlan } from "./fields/lacrosse.js";
|
|
9
|
+
import { rugbyPlan } from "./fields/rugby.js";
|
|
10
|
+
import { chooseLeague, LEAGUES } from "./leagues.js";
|
|
11
|
+
import { lengthUnit } from "./common.js";
|
|
12
|
+
/** The field sports, in the order a menu lists them. */
|
|
13
|
+
export const FIELD_SPORTS = ["lacrosse", "rugby", "afl", "gaelic", "cricket", "fieldhockey", "handball"];
|
|
14
|
+
/** True for a sport whose surface is a field sport's. */
|
|
15
|
+
export const isFieldSport = (sport) => FIELD_SPORTS.includes(sport);
|
|
16
|
+
/**
|
|
17
|
+
* The plan the options ask for. A `league` picks the rulebook (the sport's own first one by default); `field` a size within its range and the sport's own parameters; `detail: "simple"` leaves out the small marks.
|
|
18
|
+
* @throws RangeError when a size is outside the league's range, and Error when the ground or the look is not one the sport has.
|
|
19
|
+
*/
|
|
20
|
+
export function fieldPlan(o) {
|
|
21
|
+
const sport = o.sport;
|
|
22
|
+
if (!isFieldSport(sport))
|
|
23
|
+
throw new Error(`"${String(sport)}" is not a field sport`);
|
|
24
|
+
const { league: picked } = chooseLeague(o);
|
|
25
|
+
const league = picked ?? LEAGUES[sport][0];
|
|
26
|
+
const unit = lengthUnit(o);
|
|
27
|
+
const full = o.detail !== "simple";
|
|
28
|
+
switch (sport) {
|
|
29
|
+
case "lacrosse":
|
|
30
|
+
return lacrossePlan(league, o.field, unit, full);
|
|
31
|
+
case "rugby":
|
|
32
|
+
return rugbyPlan(league, o.field, unit, full);
|
|
33
|
+
case "afl":
|
|
34
|
+
return aflPlan(league, o.field, unit, full);
|
|
35
|
+
case "gaelic":
|
|
36
|
+
return gaelicPlan(league, o.field, unit, full);
|
|
37
|
+
case "cricket":
|
|
38
|
+
return cricketPlan(league, o.field, unit, full);
|
|
39
|
+
case "fieldhockey":
|
|
40
|
+
return fieldHockeyPlan(league, o.field, unit, full);
|
|
41
|
+
default:
|
|
42
|
+
return handballPlan(league, o.field, unit, full);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ArcShape, BarShape, BoxShape, Dash, DotShape, LineShape, Outline, PathShape, PolyShape, RingShape } from "./fields.types.ts";
|
|
2
|
+
import type { Span } from "./leagues/fields.ts";
|
|
3
|
+
import { type PlateSpot, type Zone } from "./surfaces/surface.ts";
|
|
4
|
+
import type { Box } from "./types.ts";
|
|
5
|
+
import { type Unit } from "./units.ts";
|
|
6
|
+
interface Style {
|
|
7
|
+
w?: number;
|
|
8
|
+
dash?: Dash;
|
|
9
|
+
/** The least this shape is drawn at, in feet, when the drawing is not at the true widths (a crease on a pitch has to stay thin beside a ground). */
|
|
10
|
+
least?: number;
|
|
11
|
+
cls?: "ky-line" | "ky-red";
|
|
12
|
+
}
|
|
13
|
+
/** A line from one point to another. */
|
|
14
|
+
export declare const line: (id: string, feature: string, x0: number, y0: number, x1: number, y1: number, style?: Style) => LineShape;
|
|
15
|
+
/** The outline of a rectangle from its corners. */
|
|
16
|
+
export declare const box: (id: string, feature: string, x0: number, y0: number, x1: number, y1: number, style?: Style) => BoxShape;
|
|
17
|
+
/** A circle or an ellipse as a line. */
|
|
18
|
+
export declare const ring: (id: string, feature: string, cx: number, cy: number, rx: number, ry?: number, style?: Style) => RingShape;
|
|
19
|
+
/** An arc of a circle, the angles in degrees from the right, growing clockwise as the eye sees it. */
|
|
20
|
+
export declare const arc: (id: string, feature: string, cx: number, cy: number, r: number, a0: number, a1: number, style?: Style) => ArcShape;
|
|
21
|
+
/** A straight-sided line through points. */
|
|
22
|
+
export declare const poly: (id: string, feature: string, points: readonly (readonly [number, number])[], style?: Style & {
|
|
23
|
+
closed?: boolean;
|
|
24
|
+
}) => PolyShape;
|
|
25
|
+
/** A line along a path of your own. */
|
|
26
|
+
export declare const path: (id: string, feature: string, d: string, style?: Style) => PathShape;
|
|
27
|
+
/** A small filled mark. */
|
|
28
|
+
export declare const dot: (id: string, feature: string, cx: number, cy: number, r: number, paint?: DotShape["paint"]) => DotShape;
|
|
29
|
+
/** A filled rectangle in the line's colour. */
|
|
30
|
+
export declare const bar: (id: string, feature: string, x0: number, y0: number, x1: number, y1: number) => BarShape;
|
|
31
|
+
/** Dashes along a line from `from` to `to` (a line along x, at height `y`), each `on` long, starting with a dash at `from`, the pattern repeating every `on + off`. */
|
|
32
|
+
export declare function dashesAlongX(id: string, feature: string, y: number, from: number, to: number, on: number, off: number, style?: Style): LineShape[];
|
|
33
|
+
/** Dashes along a line from `from` to `to` (a line along y, at `x`), each `on` long, starting with a dash at `from`, the pattern repeating every `on + off`. */
|
|
34
|
+
export declare function dashesAlongY(id: string, feature: string, x: number, from: number, to: number, on: number, off: number, style?: Style): LineShape[];
|
|
35
|
+
/** The path of a rounded rectangle from its corners. */
|
|
36
|
+
export declare function roundedD(x0: number, y0: number, x1: number, y1: number, r: number): string;
|
|
37
|
+
/** The path of the playing surface's edge, in a box of `length` by `width` feet. */
|
|
38
|
+
export declare function outlineD(length: number, width: number, outline: Outline): string;
|
|
39
|
+
/** True when a point is on the playing surface or on its edge. */
|
|
40
|
+
export declare function inOutline(length: number, width: number, outline: Outline, x: number, y: number): boolean;
|
|
41
|
+
/** A metre, in feet. */
|
|
42
|
+
export declare const METRE: number;
|
|
43
|
+
/** A yard, in feet. */
|
|
44
|
+
export declare const YARD = 3;
|
|
45
|
+
/** An inch, in feet. */
|
|
46
|
+
export declare const INCH: number;
|
|
47
|
+
/** A length in feet to the unit asked for (for a test, and for a sentence). */
|
|
48
|
+
export declare const inUnit: (feet: number, unit: Unit) => number;
|
|
49
|
+
/**
|
|
50
|
+
* A size asked for in `askedUnit`, held to the range the rules allow. The range is in feet, as a plan's figures are; the answer is in feet, and without a size asked for it is the one drawn.
|
|
51
|
+
* @throws RangeError with the range in `reportUnit` (the league's own) when the size is outside it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function sizeIn(range: Span, asked: number | undefined, askedUnit: Unit, reportUnit: Unit, label: string): number;
|
|
54
|
+
/** The zones that hold the teams' names at each end, lying along the end (the words run up the left end and down the right, as a football end zone's do). */
|
|
55
|
+
export declare function endZones(length: number, width: number, depth: number, across: number): {
|
|
56
|
+
left: Zone;
|
|
57
|
+
right: Zone;
|
|
58
|
+
};
|
|
59
|
+
/** The place of the score's panel: the middle of the surface, of a size that follows the surface's. */
|
|
60
|
+
export declare function middlePlate(length: number, width: number, w: number, h: number): PlateSpot;
|
|
61
|
+
/** A box from two corners. */
|
|
62
|
+
export declare const at: (x0: number, y0: number, x1: number, y1: number) => Box;
|
|
63
|
+
export {};
|