Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/thatstupidcomputer / apps/web/src/animation/core/geometry.mjs |
| Date | Not specified in source |
| Repository | Janady13/thatstupidcomputer |
| Revision | 57555cde46910102dd25d6c1c1fb2c359e9655bd |
| Branch | main |
| Path or archive member | apps/web/src/animation/core/geometry.mjs |
| Original SHA-256 | 00f9868f124c22aa6e92db447bf4ea25a328339e63ef2a1462c07d7cda92384d |
| Git blob SHA | cd2fa35c217d082349e8f6eb17fd24cb724f7f21 |
| Reading-copy SHA-256 | 00f9868f124c22aa6e92db447bf4ea25a328339e63ef2a1462c07d7cda92384d |
Recovered source transcript
Download complete source text ↓14 lines · 1.0 KB
/** Construct a trusted, validated rig without parsing or injecting HTML. */
const NS = 'http://www.w3.org/2000/svg';
export function createCharacterSVG(model, prefix) {
const make = (tag, attrs) => { const e = document.createElementNS(NS, tag); for (const [k,v] of Object.entries(attrs)) e.setAttribute(k, String(v)); return e; };
const svg = make('svg', { xmlns: NS, width: model.width, height: model.height, viewBox: `0 0 ${model.width} ${model.height}`, 'aria-hidden': 'true' });
const add = n => {
const attrs = { id: prefix + '--' + n.id, 'data-rig-id': n.id, opacity: n.opacity ?? 1 };
const e = n.type === 'group' ? make('g', { ...attrs, transform: `translate(${n.x ?? 0} ${n.y ?? 0}) rotate(${n.rotation ?? 0}) scale(${n.scaleX ?? 1} ${n.scaleY ?? 1})` }) : make('path', { ...attrs, d: n.d, fill: n.fill, stroke: n.stroke, 'stroke-width': n.strokeWidth, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' });
for (const child of n.children || []) e.append(add(child));
return e;
};
svg.append(add(model.root)); return svg;
}