Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,13 @@ no rebuild. An older plan file may also carry `recommender`, `checkin`, `journal
Every person is built by `body()` from the one skeleton (`BONES`), hands and feet are
placed by IK so they touch what they hold or stand on, and each figure has ONE cue in
the accent on what its `watch` is about (#109, the vocabulary is at the top of the
file). `app/figures.test.jsx` holds limb lengths, contacts, cues and the native copy.
file). The 50×42 thumbnail is the primary size: each figure is framed on its person
(`view`), its cue is at least 2px there, and a close-up (`detail`: a finger on the
edge, the tall back) is drawn beside the figure on the card, never on a thumbnail. A
`sided` figure is mirrored for an exercise named "right" (`mirrored`).
`app/figures.test.jsx` holds limb lengths, contacts, framing, cue width, poses that
visibly differ, heads that follow their spines, limbs that never fuse, and the native
copy.
- **Every claim is graded and sourced.** `evidence.grade` is one of `rct`,
`controlled-trial`, `observational`, `mechanistic`, `expert-consensus`, `folklore`;
`transfer` states what is assumed versus demonstrated. Verify citations against the
Expand Down
90 changes: 81 additions & 9 deletions app/figures.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import { readFileSync } from 'node:fs'
import { renderToStaticMarkup } from 'react-dom/server'
import { FIGURES, KINDS, BONES, LIMBS, dist } from './src/lib/figuredata.js'
import { Figure } from './src/lib/figures.jsx'
import { FIGURES, KINDS, BONES, LIMBS, BODIES, dist, bounds, pointsIn, mirrored } from './src/lib/figuredata.js'
import { Figure, FigureDetail } from './src/lib/figures.jsx'

let failed = 0
const check = (name, fn) => {
Expand All @@ -29,6 +29,11 @@ const check = (name, fn) => {
const ok = (cond, msg) => { if (!cond) throw new Error(msg) }
const read = (p) => readFileSync(new URL(p, import.meta.url), 'utf8')
const layers = (f) => ['props', 's', 'a', 'b', 'over', 'detail'].flatMap(l => f[l] || [])
const drawn = (f) => ['props', 's', 'a', 'b', 'over'].flatMap(l => f[l] || [])
const person = (f) => ['s', 'a', 'b', 'over'].flatMap(l => f[l] || [])
/** Pixels per figure unit in the 50×42 row thumbnail (every view has the box's shape). */
const thumbScale = (f) => 50 / f.view[2]
const turn = (a) => ((a % 360) + 540) % 360 - 180
const names = Object.keys(FIGURES)

check('the phone copies the web figure data byte for byte', () => {
Expand Down Expand Up @@ -108,22 +113,89 @@ check('scap-pull: the arms are the same lines in both poses (they never bend)',
ok(!f.a.some(s => s.k === 'cueBody') && !f.b.some(s => s.k === 'cueBody'), 'an arm moves between poses')
})

check('the web renders every shape the data has; thumbnails leave the inset out', () => {
check('the web renders every shape the data has; the close-up is the card\u2019s alone', () => {
for (const n of names) {
const f = FIGURES[n]
const html = renderToStaticMarkup(<Figure name={n} />)
const want = layers(f).filter(s => s.d).length + layers(f).filter(s => s.c).length
const want = drawn(f).length
const got = (html.match(/<path /g) || []).length + (html.match(/<circle /g) || []).length
ok(got === want, `${n}: ${got} elements for ${want} shapes`)
for (const s of layers(f).filter(s => s.d)) ok(html.includes(`d="${s.d}"`), `${n}: a path is missing`)
if (f.detail) {
ok(html.includes('fig-detail'), `${n}: the card has no inset`)
ok(!renderToStaticMarkup(<Figure name={n} detail={false} />).includes('fig-detail'), `${n}: the thumbnail draws the inset`)
for (const s of drawn(f).filter(s => s.d)) ok(html.includes(`d="${s.d}"`), `${n}: a path is missing`)
ok(html.includes(`viewBox="${f.view.join(' ')}"`), `${n}: not drawn in its own framing`)
ok(!html.includes('fig-detail'), `${n}: the figure draws its close-up (a thumbnail would)`)
const det = renderToStaticMarkup(<FigureDetail name={n} />)
ok(Boolean(f.detail) === det.includes('fig-detail'), `${n}: the close-up is ${f.detail ? 'missing' : 'drawn with nothing in it'}`)
ok(!html.includes('NaN') && !det.includes('NaN'), `${n}: NaN in the markup`)
}
})

/* ------------------------------------------------- what reads at 50×42 (#109 r2) */

check('every figure is framed on its person: the body spans at least 70% of the view', () => {
for (const n of names) {
const f = FIGURES[n]
const [x0, y0, x1, y1] = bounds(person(f))
const [, , w, h] = f.view
ok(Math.abs(w / h - 1.2) < 0.01, `${n}: the view is not the box's shape (${w}×${h})`)
const span = Math.max((x1 - x0) / w, (y1 - y0) / h)
ok(span >= 0.7, `${n}: the person spans only ${Math.round(span * 100)}% of the view`)
}
})

check('every cue survives the thumbnail: at least 2px wide at 50×42', () => {
for (const n of names) {
const f = FIGURES[n]
for (const s of drawn(f).filter(s => KINDS[s.k].cue && !KINDS[s.k].fill)) {
const px = (s.w ?? KINDS[s.k].stroke) * thumbScale(f)
ok(px >= 2, `${n}: a cue ${px.toFixed(2)}px wide at 50×42`)
}
ok(!html.includes('NaN'), `${n}: NaN in the markup`)
}
})

check('the two poses visibly differ: ten units on the part that moves', () => {
const far = (from, to) => Math.max(...from.map(p => Math.min(...to.map(q => dist(p, q)))))
for (const n of names.filter(n => FIGURES[n].b)) {
const f = FIGURES[n]
const a = pointsIn(f.a)
const b = pointsIn(f.b)
const moved = Math.max(far(a, b), far(b, a))
ok(moved * thumbScale(f) >= 4, `${n}: the poses differ by ${moved.toFixed(1)} units (${(moved * thumbScale(f)).toFixed(1)}px at 50×42)`)
}
})

check('anatomy: every head follows its spine (within 30°, 40° for a climber looking up)', () => {
ok(BODIES.length > 20, `only ${BODIES.length} bodies were recorded`)
for (const b of BODIES) {
const off = Math.abs(turn(b.neck - b.lean))
ok(off <= (b.looksUp ? 40 : 30), `a head ${Math.round(off)}° off its spine (spine ${Math.round(b.lean)}°, neck ${Math.round(b.neck)}°)`)
}
})

check('anatomy: two arms or two legs never fuse, and a far limb is clearly behind', () => {
const offLine = (p, a, b) => {
const [dx, dy] = [b[0] - a[0], b[1] - a[1]]
return Math.abs(dx * (a[1] - p[1]) - dy * (a[0] - p[0])) / Math.hypot(dx, dy)
}
for (const b of BODIES) {
for (const [x, y] of [['armL', 'armR'], ['legL', 'legR']]) {
const [p, q] = [b.limbs[x], b.limbs[y]]
if (!p || !q) continue
const apart = Math.max(dist(p.mid, q.mid), dist(p.end, q.end))
ok(apart >= 4, `${x}/${y} of a ${b.view} body are ${apart.toFixed(1)} apart: one limb, or a grey sliver`)
ok(offLine(q.end, p.root, p.end) >= 3 || offLine(p.end, q.root, q.end) >= 3 || dist(p.root, q.root) > 6,
`${x}/${y} of a ${b.view} body lie on one line: they read as one pole`)
}
}
})

check('a sided figure is mirrored for the right hand, and only then', () => {
ok(mirrored('no-hang-pull', 'Right hand pulls') && mirrored('no-hang-pull', 'MVC right'), 'the right hand is not mirrored')
ok(!mirrored('no-hang-pull', 'Left hand pulls') && !mirrored('no-hang-pull', 'Bright idea'), 'the left hand is mirrored')
ok(!mirrored('hang-edge', 'Right hand'), 'a figure with no sides is mirrored')
const html = renderToStaticMarkup(<Figure name="no-hang-pull" mirror />)
ok(/transform="matrix\(-1 0 0 1 /.test(html), 'mirror does not flip the drawing')
})

check('the cue is drawn in --fig-cue, never a fixed colour', () => {
const html = renderToStaticMarkup(<Figure name="hang-edge" />)
ok(html.includes('class="fig-cue"'), 'no cue element carries .fig-cue')
Expand Down
11 changes: 10 additions & 1 deletion app/src/css/sheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,19 @@
.how-sheetbody .how-body { padding: 0; }

.how-fig {
height: 132px; margin-bottom: var(--sp-4); padding: var(--sp-2);
display: flex; gap: var(--sp-2); justify-content: center;
height: 176px; margin-bottom: var(--sp-4); padding: var(--sp-2);
background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-control);
color: var(--ink);
}
/* The figure takes the room the close-up leaves; the close-up (a finger on the
edge, the tall back) sits beside it at the card's full height, so it is read
at a real size instead of as a 35px corner (#109). */
.how-fig > .fig { flex: 1 1 auto; min-width: 0; width: auto; }
.how-detail {
flex: 0 0 auto; width: auto; height: 100%; padding: var(--sp-2);
background: var(--panel); border-radius: var(--r-control);
}
.how-gist {
margin: 0 0 var(--sp-3); font-size: var(--fs-body); line-height: 1.5; font-weight: 500; color: var(--ink);
}
Expand Down
15 changes: 9 additions & 6 deletions app/src/howto.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { useState } from 'react'
import { Icon } from './lib/icons.jsx'
import { Popover } from './modal.jsx'
import { Figure } from './lib/figures.jsx'
import { Figure, FigureDetail, hasDetail, mirrored } from './lib/figures.jsx'

/** "3 × 8" — the prescription, short enough to sit in a row. */
export function doseLabel(ex) {
Expand All @@ -43,12 +43,15 @@ export function doseLabel(ex) {
* the free hand turns the weight BEFORE you lower it, and doing those two in
* the other order is the whole mistake the eccentrics card exists to prevent.
*/
export function HowBody({ how, showFigure = true }) {
export function HowBody({ how, showFigure = true, name }) {
if (!how) return null
return (
<div className="how-body">
{showFigure && how.figure && (
<div className="how-fig"><Figure name={how.figure} /></div>
<div className="how-fig">
<Figure name={how.figure} mirror={mirrored(how.figure, name)} />
{hasDetail(how.figure) && <FigureDetail name={how.figure} className="how-detail" />}
</div>
)}
{how.gist && <p className="how-gist">{how.gist}</p>}

Expand Down Expand Up @@ -93,15 +96,15 @@ export function HowRow({ exercise, open, onToggle, meta }) {
return (
<div className={`how-row ${open ? 'on' : ''}`}>
<button className="how-head" onClick={onToggle} aria-expanded={open}>
<span className="how-thumb"><Figure name={how?.figure} detail={false} /></span>
<span className="how-thumb"><Figure name={how?.figure} mirror={mirrored(how?.figure, exercise.name)} /></span>
<span className="how-heads">
<span className="how-name">{exercise.name}</span>
{how?.gist && <span className="how-sub">{how.gist}</span>}
</span>
{dose && <span className="how-dose">{dose}</span>}
<span className="how-chev"><Icon name="ChevronDown" size={17} /></span>
</button>
{open && how && <HowBody how={how} />}
{open && how && <HowBody how={how} name={exercise.name} />}
{open && !how && (
<p className="how-none">
No step-by-step for this one yet — the full protocol is in the sections above.
Expand Down Expand Up @@ -132,7 +135,7 @@ export function HowSheet({ exercise, how, title, onClose }) {
<Icon name="X" size={18} />
</button>
</header>
<div className="how-sheetbody"><HowBody how={card} /></div>
<div className="how-sheetbody"><HowBody how={card} name={name} /></div>
<button className="btn how-got" onClick={onClose}>Got it</button>
</div>
</Popover>
Expand Down
Loading
Loading