@johnmorrisdotca/kyogijo-stadiums 0.20.0 → 0.21.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.
@@ -0,0 +1,12 @@
1
+ import type { BudoPlan } from "./budo/plan.ts";
2
+ import type { RingLayout } from "./budo/ring.ts";
3
+ import { type Plane, type Upright } from "./turn.kit.ts";
4
+ /** The platform of a ring as a solid block: its four sides and its top, which is the drawing's own canvas in the platform's rectangle. */
5
+ export declare function platformPlanes(b: {
6
+ x0: number;
7
+ y0: number;
8
+ x1: number;
9
+ y1: number;
10
+ }, at: (x: number, y: number) => readonly [number, number], h: number): Plane[];
11
+ /** What stands on a ring: the platform, its steps, the posts, the ropes and their ties. */
12
+ export declare function ringUprights(plan: BudoPlan, L: RingLayout, at: (x: number, y: number) => readonly [number, number]): Upright[];
@@ -0,0 +1,76 @@
1
+ import { box, flat, n, pole, bar, wall } from "./turn.kit.js";
2
+ const K = 1 / 0.3048;
3
+ /** The platform of a ring as a solid block: its four sides and its top, which is the drawing's own canvas in the platform's rectangle. */
4
+ export function platformPlanes(b, at, h) {
5
+ const corners = [at(b.x0, b.y0), at(b.x1, b.y0), at(b.x1, b.y1), at(b.x0, b.y1)];
6
+ const planes = [];
7
+ corners.forEach((a, i) => {
8
+ const c = corners[(i + 1) % 4];
9
+ planes.push(wall(`deck-${i + 1}`, "wall", a[0], a[1], c[0], c[1], 0, h, `<rect width="${n(Math.hypot(c[0] - a[0], c[1] - a[1]))}" height="${n(h)}" class="u-deck-side"/>`));
10
+ });
11
+ planes.push({ ...flat("deck-top", "platform", corners[0][0], corners[0][1], corners[2][0], corners[2][1], h, ""), crop: true });
12
+ return planes;
13
+ }
14
+ /** What stands on a ring: the platform, its steps, the posts, the ropes and their ties. */
15
+ export function ringUprights(plan, L, at) {
16
+ const fig = plan.figures;
17
+ const h0 = L.height * K;
18
+ const centre = at(L.centre[0], L.centre[1]);
19
+ const items = [{ id: "deck", kind: "deck", at: centre, height: h0, planes: platformPlanes(L.platform, at, h0) }];
20
+ if (L.steps.length > 0) {
21
+ const s = fig.platform.steps;
22
+ const planes = [];
23
+ for (const st of L.steps) {
24
+ const north = st.edge === "north";
25
+ for (let t = 0; t < s.treads; t += 1) {
26
+ const y0 = north ? st.box.y0 + t * s.tread : st.box.y0;
27
+ const y1 = north ? st.box.y1 : st.box.y1 - t * s.tread;
28
+ const [x0, ya] = at(st.box.x0, y0);
29
+ const [x1, yb] = at(st.box.x1, y1);
30
+ planes.push(...box(`step-${st.corner}-${t + 1}`, "platform", { x0, y0: ya, x1, y1: yb }, (h0 * (t + 1)) / s.treads, "u-step"));
31
+ }
32
+ }
33
+ items.push({ id: "steps", kind: "deck", at: centre, height: h0, planes });
34
+ }
35
+ // The posts: solid, two crossed strips as wide as the pad, in the corner's colour, from the platform to the height the rules give over the ring floor.
36
+ const top = h0 + fig.post.height * K;
37
+ const padW = fig.post.pad * K;
38
+ const posts = L.corners.flatMap((c) => {
39
+ const [px, py] = at(c.post[0], c.post[1]);
40
+ return pole(`post-${c.index + 1}`, "post", px, py, h0, top, padW, `u-corner-${c.colour}`);
41
+ });
42
+ // The ropes: along each side between the corners of the rope square, and at each corner out to the post by the extension.
43
+ const ropeW = Math.max(fig.ropes.diameter.drawn, 0.03) * K;
44
+ const ropes = [];
45
+ fig.ropes.heights.forEach((rh, level) => {
46
+ const z = h0 + rh * K;
47
+ const sq = L.corners.map((c) => at(c.rope[0], c.rope[1]));
48
+ for (let i = 0; i < 4; i += 1) {
49
+ const a = sq[i];
50
+ const b = sq[(i + 1) % 4];
51
+ ropes.push(...bar(`rope-${level + 1}-${i + 1}`, "rail", [a[0], a[1], z], [b[0], b[1], z], ropeW, "u-rope"));
52
+ }
53
+ L.corners.forEach((c, i) => {
54
+ const a = at(c.rope[0], c.rope[1]);
55
+ const p = at(c.post[0], c.post[1]);
56
+ ropes.push(...bar(`rope-${level + 1}-ext-${i + 1}`, "rail", [a[0], a[1], z], [p[0], p[1], z], ropeW, "u-rope"));
57
+ });
58
+ });
59
+ // Two ties on each side, a strip joining the ropes where they are a third and two thirds along, as the rules ask (spacers).
60
+ const lo = h0 + fig.ropes.heights[0] * K;
61
+ const hi = h0 + fig.ropes.heights[fig.ropes.heights.length - 1] * K;
62
+ const ties = [];
63
+ const sq = L.corners.map((c) => at(c.rope[0], c.rope[1]));
64
+ for (let i = 0; i < 4; i += 1) {
65
+ const a = sq[i];
66
+ const b = sq[(i + 1) % 4];
67
+ for (const t of [1 / 3, 2 / 3]) {
68
+ const x = a[0] + (b[0] - a[0]) * t;
69
+ const y = a[1] + (b[1] - a[1]) * t;
70
+ ties.push(...pole(`tie-${i + 1}-${t < 0.5 ? 1 : 2}`, "rail", x, y, lo, hi, 0.1 * K, "u-rope-tie"));
71
+ }
72
+ }
73
+ items.push({ id: "posts", kind: "ring-posts", at: centre, height: top - h0, planes: posts });
74
+ items.push({ id: "ropes", kind: "ring-ropes", at: centre, height: hi - h0, planes: [...ropes, ...ties] });
75
+ return items;
76
+ }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The package's version: the same as package.json's, and a test holds them to each other. */
2
- export declare const VERSION = "0.20.0";
2
+ export declare const VERSION = "0.21.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The package's version: the same as package.json's, and a test holds them to each other. */
2
- export const VERSION = "0.20.0";
2
+ export const VERSION = "0.21.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/kyogijo-stadiums",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Kyogijo Stadiums 競技場, 40 sports' surfaces as SVG, drawn to scale from the rulebooks: NFL, CFL and IFAF football fields, an NHL rink, an NBA court, MLB ballparks, soccer pitches, curling sheets, athletics stadiums, speed skating, short track and figure skating rinks, swimming pools, water polo fields, diving wells, artistic swimming areas, and the courts and fields of tennis, volleyball (indoor, beach and sitting), badminton, pickleball, table tennis, padel, squash, racquetball, sepak takraw, teqball, roundnet, netball, lacrosse, rugby, Australian football, Gaelic games, cricket, field hockey and handball, and the budo of judo, karate, kendo, sumo and kyudo with a dojo of tatami laid as real units, the MMA cage, with each team's name and logo on its side and the score in the middle, stands and a crowd, a pageant of flags, and a 3D view. Light and dark, accessible, a compact badge for lists, a helper for React and a custom element. Zero dependencies.",
5
5
  "keywords": [
6
6
  "sports",