Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/thatdeveloperguy-website / tools/svg/model.ts |
| Date | Not specified in source |
| Repository | Janady13/thatdeveloperguy-website |
| Revision | 2bea2ebdff0e34494bff597d4fa9c8422a0c3a94 |
| Branch | main |
| Path or archive member | tools/svg/model.ts |
| Original SHA-256 | 65d542d97c7d37802087b2d2faa54c4272fb65739e171a1eb4ddc04bc467b8dc |
| Git blob SHA | 643bfa91231b65a2bacaaf8588168fa0b78e8ccb |
| Reading-copy SHA-256 | 65d542d97c7d37802087b2d2faa54c4272fb65739e171a1eb4ddc04bc467b8dc |
Recovered source transcript
Download complete source text ↓22 lines · 0.8 KB
export type Point = [number, number];
export type Ring = Point[];
export interface PathNode { kind: 'path'; id: string; fill: string; rings: Ring[] }
export interface GroupNode { kind: 'group'; id: string; label?: string; children: SvgNode[] }
export type SvgNode = PathNode | GroupNode;
export interface SceneDoc { width: number; height: number; title: string; children: SvgNode[] }
export function* walkPaths(nodes: SvgNode[]): Generator<PathNode> {
for (const node of nodes) {
if (node.kind === 'path') yield node; else yield* walkPaths(node.children);
}
}
export function findGroup(nodes: SvgNode[], id: string): GroupNode | null {
for (const node of nodes) {
if (node.kind !== 'group') continue;
if (node.id === id) return node;
const inner = findGroup(node.children, id);
if (inner) return inner;
}
return null;
}