import type { DrawShape } from '../../../shared/drawing' import { num, str, strOrUndefined } from './utils' /** * Triangle rectangle toujours geometriquement valide : angle droit fixe en bas-a-gauche, angle * theta en haut. Le modele ne fournit que des labels/captions, jamais de coordonnees. */ export function buildRightTriangle(params: Record): DrawShape[] { const x = num(params.x, 120, 0, 2000) const y = num(params.y, 80, 0, 2000) const size = num(params.size, 220, 50, 800) const color = str(params.color, '#2a5fb8') const hypotenuseColor = str(params.hypotenuseColor, '#b83a3a') return [ { type: 'line', x, y, x2: x, y2: y + size, color, label: str(params.adjacentLabel, 'Adjacent'), caption: strOrUndefined(params.adjacentCaption) }, { type: 'line', x, y: y + size, x2: x + size, y2: y + size, color, label: str(params.oppositeLabel, 'Opposé'), caption: strOrUndefined(params.oppositeCaption) }, { type: 'line', x, y, x2: x + size, y2: y + size, color: hypotenuseColor, label: str(params.hypotenuseLabel, 'Hypoténuse'), caption: strOrUndefined(params.hypotenuseCaption) }, { type: 'rect', x, y: y + size - 14, width: 14, height: 14, color: '#555555' }, { type: 'arc', x, y, radius: 28, startAngle: 45, endAngle: 90, color: '#555555', label: str(params.angleLabel, 'θ'), caption: strOrUndefined(params.angleCaption) } ] }