// Procedural SVG glyphs for species, fixtures, and pressure icons (SPEC ยง13). // Each returns inner SVG markup (shapes) centered at (x,y) at the given scale. import type { FixtureKind, PressureId } from "../domain/types.ts"; // ---------- Species ---------- /** Producer "Lumiflora": 6-petal diatom/flower around a chloroplast center. Green. */ export function glyphProducer(x: number, y: number, s: number): string { const petals = []; for (let i = 0; i < 6; i++) { const a = (i * 60) * Math.PI / 180; const px = x + Math.cos(a) * s * 0.5; const py = y - Math.sin(a) * s * 0.5; petals.push( ``, ); } return `${petals.join("")}`; } /** Grazer "Vellea": segmented crescent with cilia legs + mouth notch. Amber. */ export function glyphGrazer(x: number, y: number, s: number): string { const cilia: string[] = []; for (let i = 0; i < 3; i++) { const t = (i + 1) / 4; const lx = x - s * 0.45 + t * s * 0.9; cilia.push(``); cilia.push(``); } return ` ${cilia.join("")} `; } /** Phage: lunar-lander virus (hex capsid head + 6 leg spikes). Pink. */ export function glyphPhage(x: number, y: number, s: number): string { const legs: string[] = []; for (let i = 0; i < 6; i++) { const a = (i * 60 + 30) * Math.PI / 180; const x1 = x + Math.cos(a) * s * 0.5; const y1 = y + Math.sin(a) * s * 0.5; const x2 = x + Math.cos(a) * s * 0.78; const y2 = y + Math.sin(a) * s * 0.78; legs.push(``); } const hp = []; for (let i = 0; i < 6; i++) { const a = (90 - 60 * i) * Math.PI / 180; hp.push(`${(x + Math.cos(a) * s * 0.45).toFixed(1)},${(y - Math.sin(a) * s * 0.45).toFixed(1)}`); } return `${legs.join("")}`; } export function glyphSpecies(id: "producer" | "grazer" | "phage", x: number, y: number, s: number): string { if (id === "producer") return glyphProducer(x, y, s); if (id === "grazer") return glyphGrazer(x, y, s); return glyphPhage(x, y, s); } // ---------- Fixtures ---------- export function glyphFixture(kind: FixtureKind, x: number, y: number, s: number): string { switch (kind) { case "nutrientInlet": // pipette/valve dropping a bead (blue) return ` `; case "heatSource": // coiled filament radiating warm rays (orange) { const rays: string[] = []; for (let i=0;i<8;i++){const a=(i*45)*Math.PI/180;rays.push(``);} return `${rays.join("")}`; } case "toxinInlet": // dropper of greenish droplet return ``; case "drain": // funnel siphon return ``; case "immuneNode": // sentinel eye/lens (cyan) return ``; case "objective": // targeting reticle (gold) return ``; } } // ---------- Pressure icons ---------- export function glyphPressure(p: PressureId, x: number, y: number, s: number): string { switch (p) { case "heat": { // radiating sun rays (warm) const r: string[] = []; for (let i=0;i<8;i++){const a=(i*45)*Math.PI/180;r.push(``);} return `${r.join("")}`; } case "hunger": // waning crescent (violet) return ``; case "toxin": // skull-and-drop (green) return ``; case "immunity": // shield (cyan) return ``; } }