import { Layout, Txt, makeScene2D } from "@motion-canvas/2d"; import { Direction, all, beginSlide, createRef, makeRef, slideTransition, } from "@motion-canvas/core"; import { FunctionBox } from "../components/function_box"; import { theme } from "../theme"; import { PEOPLE, Person } from "../components/person"; const valentineLetterGenerator = ` interface PersonI { name: string; birthday: Date; color: string; } (function valentinesLettersFor(people: PersonI[]) { const letters: string[] = []; for (const person of people) { const letter = "Dear, " + person.name + "\\n" + "Your smile lights up my world.\\n" + "Happy Valentine's Day!"; letters.push(letter); } return letters; })`; export default makeScene2D(function* (view) { const layout = createRef(); const functionBox = createRef(); const people: Person[] = []; const peopleLayout: Layout[] = []; const peopleText: Txt[] = []; view.add( , ); yield* all(slideTransition(Direction.Left), functionBox().showCode(0.75)); yield* functionBox().reset(0.1); yield* beginSlide("Show code"); yield* functionBox().reset(0.1); yield* all( functionBox().hideCode(0.8), functionBox().setInputs( [ { val: PEOPLE, node: ( {PEOPLE.map((person) => ( ))} ), }, ], 0.8, ), ); yield* beginSlide("Show people"); yield* functionBox().propogateInput(0.6); yield* functionBox().propogateOutput(0.6); yield* beginSlide("Generate valentines letters"); yield* functionBox().opacity(0, 0.5); functionBox().remove(); view.add( {PEOPLE.map((person, i) => ( ))} , ); yield* layout().opacity(1, 0.5); yield* all(...peopleText.map((text) => text.text("💌", 0))); yield* all(...peopleText.map((text) => text.fontSize(50, 0.5))); yield* all(...peopleLayout.map((layout) => layout.gap(0, 0.5))); yield* all( ...peopleText.map((text) => all(text.fontSize(0, 0.5), text.opacity(0, 0.5)), ), ); yield* beginSlide("Give people valentines letters"); yield* all(...people.map((person) => person.emit("😊", 0.5))); yield* beginSlide("See their reactions"); yield* all(...people.map((person) => person.opacity(0, 0.5))); });