import type { BookLineElement } from '@trek/shared'; import type { CSSProperties } from 'react'; import { useMemo } from 'react'; import { type LineGeometry, lineGeometry } from './lineRender'; /** The paths of a line's geometry in one colour: the body stroked, the heads and the ornament filled. */ export function LinePaths({ g, color, width }: { g: LineGeometry; color: string; width: number }) { const stroke = { fill: 'none', stroke: color, strokeWidth: width, strokeLinejoin: 'round' as const }; return ( <> {g.body.map((d, i) => ( ))} {g.strokes.map((d, i) => ( ))} {g.fills.map((d, i) => ( ))} ); } /** * A line element, drawn: its body stroked, its heads and ornament filled, all * in the millimetres of its own frame (one SVG unit is one millimetre, as for * the shapes). Overflow stays visible so a head on a thin frame is not cut. */ export function LineView({ el, frameStyle }: { el: BookLineElement; frameStyle: CSSProperties }) { const { w, h } = el.frame; const g = useMemo(() => lineGeometry(el, w, h, el.id), [el, w, h]); return (
); }