import { Layout, Node, NodeProps, SVG, Txt } from "@motion-canvas/2d"; import { theme } from "../theme"; import { all, createRef, waitFor } from "@motion-canvas/core"; export const PEOPLE: PersonI[] = [ { name: "Alan Turing", birthday: new Date("06/23/1912"), color: theme.green.hex, }, { name: "Grace Hopper", birthday: new Date("12/09/1906"), color: theme.flamingo.hex, }, { name: "Edsger Dijkstra", birthday: new Date("07/11/1930"), color: theme.red.hex, }, { name: "Alonzo Church", birthday: new Date("06/14/1912"), color: theme.sapphire.hex, }, { name: "Margaret Hamilton", birthday: new Date("12/09/1902"), color: theme.yellow.hex, }, ]; const profileSrc = (color: string) => ` `; export interface PersonI { name: string; birthday: Date; color: string; } export interface PersonProps extends NodeProps { person: PersonI; width?: number; height?: number; } export class Person extends Node { private readonly svg = createRef(); public constructor(props?: PersonProps) { super({ ...props }); this.add( {props.person.name} , ); } public *emit(text: string, duration: number, cleanUp = true) { const ref = createRef(); this.insert( {text} , 0, ); yield* all(ref().fontSize(40, duration), ref().opacity(1, duration)); if (cleanUp) { yield* waitFor(duration); yield* all(ref().fontSize(0, duration), ref().opacity(0, duration)); yield ref().remove(); } } }