Skip to content

Commit d93ee6e

Browse files
committed
Final text + initial animation
1 parent 8172786 commit d93ee6e

7 files changed

Lines changed: 216 additions & 49 deletions

File tree

animation/projects/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": 0,
3+
"shared": {
4+
"background": "rgb(10,20,30)",
5+
"range": [
6+
0,
7+
null
8+
],
9+
"size": {
10+
"x": 1920,
11+
"y": 1080
12+
},
13+
"audioOffset": 0
14+
},
15+
"preview": {
16+
"fps": 30,
17+
"resolutionScale": 1
18+
},
19+
"rendering": {
20+
"fps": 60,
21+
"resolutionScale": 1,
22+
"colorSpace": "srgb",
23+
"exporter": {
24+
"name": "@motion-canvas/core/image-sequence",
25+
"options": {
26+
"fileType": "image/png",
27+
"quality": 100,
28+
"groupByScene": false
29+
}
30+
}
31+
}
32+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { makeProject } from '@motion-canvas/core';
2+
3+
import '../../global.css';
4+
5+
import std_function from './scenes/std_function?scene';
6+
7+
export default makeProject({
8+
scenes: [std_function],
9+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 0,
3+
"timeEvents": [],
4+
"seed": 3221513550
5+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { makeScene2D, Code, LezerHighlighter, lines } from '@motion-canvas/2d';
2+
import { all, createRef, waitFor } from '@motion-canvas/core';
3+
import { MyStyle } from '../../styles';
4+
import { parser as parser_cpp } from '@lezer/cpp';
5+
import { DEFAULT } from '@motion-canvas/core/lib/signals';
6+
import { centerOn } from '../../utils';
7+
8+
import templateCode from '@lectures/std_function.md?snippet=std_function/template_button.cpp';
9+
import stdFunctionCode from '@lectures/std_function.md?snippet=std_function/std_function_button.cpp';
10+
import multiButtonCode from '@lectures/std_function.md?snippet=std_function/multi_button.cpp';
11+
import typeErasureCode from '@lectures/std_function.md?snippet=std_function/type_erasure.cpp';
12+
13+
const CppHighlighter = new LezerHighlighter(parser_cpp, MyStyle);
14+
15+
export default makeScene2D(function* (view) {
16+
const codeRef = createRef<Code>();
17+
18+
view.add(
19+
<Code
20+
ref={codeRef}
21+
fontSize={26}
22+
fontFamily={'Fira Mono'}
23+
highlighter={CppHighlighter}
24+
code={templateCode}
25+
/>
26+
);
27+
28+
// Initial delay
29+
yield* waitFor(1);
30+
31+
// 1. Template Button
32+
yield* centerOn(codeRef(), lines(4, 5), 1, 40); // template <typename Callback>
33+
yield* waitFor(3);
34+
35+
yield* centerOn(codeRef(), lines(17, 17), 1, 40); // Callback on_click_;
36+
yield* waitFor(3);
37+
38+
yield* centerOn(codeRef(), DEFAULT, 1, 28);
39+
yield* waitFor(2);
40+
41+
// 3. std::function Button
42+
yield* codeRef().code(templateCode, 0);
43+
yield* centerOn(codeRef(), DEFAULT, 0, 24);
44+
yield* waitFor(1);
45+
yield* codeRef().code(stdFunctionCode, 1);
46+
yield* waitFor(1);
47+
48+
yield* centerOn(codeRef(), lines(8, 9), 1, 40); // explicit Button(std::string name, std::function<void()> callback)
49+
yield* waitFor(3);
50+
51+
yield* centerOn(codeRef(), lines(18, 18), 1, 40); // std::function<void()> on_click_;
52+
yield* waitFor(3);
53+
54+
yield* centerOn(codeRef(), lines(30, 30), 1, 40); // std::vector<Button> buttons{play_button, quit_button};
55+
yield* waitFor(3);
56+
57+
yield* centerOn(codeRef(), DEFAULT, 1, 28);
58+
yield* waitFor(2);
59+
60+
// 4. MultiButton
61+
yield* codeRef().code(multiButtonCode, 1);
62+
yield* waitFor(1);
63+
64+
yield* centerOn(codeRef(), lines(23, 23), 1, 40); // std::vector<std::function<void()>> on_click_callbacks_;
65+
yield* waitFor(3);
66+
67+
yield* centerOn(codeRef(), DEFAULT, 1, 28);
68+
yield* waitFor(2);
69+
70+
// 5. Type Erasure
71+
yield* codeRef().code(typeErasureCode, 1);
72+
yield* waitFor(1);
73+
74+
yield* centerOn(codeRef(), lines(21, 24), 1, 36); // CallableBase
75+
yield* waitFor(3);
76+
77+
yield* centerOn(codeRef(), lines(29, 36), 1, 36); // CallableImpl
78+
yield* waitFor(3);
79+
80+
yield* centerOn(codeRef(), lines(6, 11), 1, 36); // MyFunction constructor
81+
yield* waitFor(3);
82+
83+
yield* centerOn(codeRef(), lines(41, 41), 1, 36); // std::unique_ptr<CallableBase> callable_;
84+
yield* waitFor(3);
85+
86+
yield* centerOn(codeRef(), DEFAULT, 1, 28);
87+
yield* waitFor(3);
88+
});

animation/projects/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig({
1515
motionCanvas({
1616
project: [
1717
'./src/dummy/project.ts',
18+
'./src/std_function/project.ts',
1819
]
1920
}),
2021
ffmpeg(),

0 commit comments

Comments
 (0)