1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { makeScene2D } from "@motion-canvas/2d";
import {
Direction,
beginSlide,
createRef,
slideTransition,
all,
waitFor,
} from "@motion-canvas/core";
import { FunctionBox } from "../components/function_box";
const add = `(a: number, b: number) => {
return a + b;
}`;
export default makeScene2D(function* (view) {
const functionBox = createRef<FunctionBox>();
view.add(<FunctionBox arity={2} source={add} ref={functionBox} />);
yield* slideTransition(Direction.Left);
yield* beginSlide("Black Box");
for (const [a, b] of [
[-1, 2],
[3, 4],
[5, 6],
] as [number, number][]) {
const inputId = "(" + [a, b].join(",") + ")";
yield* all(functionBox().reset(0.25));
yield* functionBox().setInputs([{ val: a }, { val: b }], 0.5);
yield* beginSlide("Add Inputs " + inputId);
yield* functionBox().propogateInput(0.5);
yield* waitFor(0.3);
yield* functionBox().propogateOutput(0.5);
yield* beginSlide("Propogate Outputs of " + inputId);
yield* beginSlide("Propogate Outputs of 1" + inputId);
}
});
|