--- import { getMessages } from '../../i18n/messages.ts'; interface Props { locale: string; /** Unique per diagram on the page; prefixes ids inside the SVG. */ uid: string; } const { locale, uid } = Astro.props; const t = getMessages(locale); const arrow = `${uid}-gca-arrow`; // Long labels do not fit the narrow column right of the cross-section on one line: split them in // two at the word boundary that gives the shortest longer line. function twoLines(label: string): [string, string] { const words = label.split(' '); let best: [string, string] = [label, '']; let bestScore = Infinity; for (let i = 1; i < words.length; i++) { const first = words.slice(0, i).join(' '); const second = words.slice(i).join(' '); const score = Math.max(first.length, second.length); if (score < bestScore) { bestScore = score; best = [first, second]; } } return best; } const normalWallLines = twoLines(t['diagram.label.normal-thickness']); const wideLumenLines = twoLines(t['diagram.label.wide-lumen']); const thickWallLines = twoLines(t['diagram.label.thick-wall']); const narrowLumenLines = twoLines(t['diagram.label.narrow-lumen']); const inflamedLines = twoLines(t['diagram.label.inflamed-segments']); // A schematic head seen from the side, face to the right. Only an outline for orientation: the ear // and the eye are landmarks, not part of the disease. The ear lies behind the artery. const head = 'M95,370 C95,330 70,300 55,250 C35,190 45,110 100,72 C150,40 225,48 255,100 C268,122 268,150 270,170 L288,205 C292,212 286,216 278,216 L276,236 C280,242 274,248 270,250 C272,262 262,276 245,278 C225,280 205,284 195,300 L190,370'; const eye = 'M228,160 Q240,151 252,160 Q240,167 228,160 Z'; // The temporal artery rises in front of the ear (x = 172) and divides at the temple into a branch // going forward over the forehead and one going up and back over the scalp. Vessels are wide // strokes: the wall, then the lumen on top of it. const trunk = 'M172,330 V142'; const forward = 'M172,146 C180,120 200,108 218,90'; const backward = 'M172,146 C168,120 160,100 130,74'; // Disease: inflamed segments of the trunk with a thick wall and a narrow lumen, between them the // wall is normal. The cross-section on the right is taken at the lower segment (y = 267). const inflamed = ['M172,282 V252', 'M172,214 V184']; const flow = { trunk: 'M172,326 V150', forward: 'M172,146 C180,120 200,108 214,95', backward: 'M172,146 C168,120 160,100 135,79', }; // The cross-section of the artery, enlarged const cx = 360; const cy = 200; --- {inflamed.map((d) => ( ))} {inflamed.map((d) => ( ))} {inflamed.map((d) => ( ))} {t['diagram.label.to-scalp']} {t['diagram.label.reduced-blood-flow']} {t['diagram.label.temporal-artery']} {inflamedLines[0]} {inflamedLines[1]} {t['diagram.label.temporal-artery-cross-section']} {normalWallLines[0]} {normalWallLines[1]} {wideLumenLines[0]} {wideLumenLines[1]} {thickWallLines[0]} {thickWallLines[1]} {narrowLumenLines[0]} {narrowLumenLines[1]}