|
1 | | -import { makeScene2D, Code, LezerHighlighter, lines } from '@motion-canvas/2d'; |
| 1 | +import { makeScene2D, Code, LezerHighlighter, lines, Node, Rect, Txt, Line } from '@motion-canvas/2d'; |
2 | 2 | import { all, createRef, waitFor } from '@motion-canvas/core'; |
3 | 3 | import { MyStyle } from '../../styles'; |
4 | 4 | import { parser as parser_cpp } from '@lezer/cpp'; |
@@ -118,6 +118,63 @@ export default makeScene2D(function* (view) { |
118 | 118 | yield* centerOn(codeRef(), [lines(23, 23)], 1, 35); |
119 | 119 | yield* waitFor(3); |
120 | 120 |
|
| 121 | + const myFuncRect = createRef<Rect>(); |
| 122 | + const baseRect = createRef<Rect>(); |
| 123 | + const implRect = createRef<Rect>(); |
| 124 | + const tRect = createRef<Rect>(); |
| 125 | + |
| 126 | + const line1 = createRef<Line>(); |
| 127 | + const line2 = createRef<Line>(); |
| 128 | + const line3 = createRef<Line>(); |
| 129 | + |
| 130 | + view.add( |
| 131 | + <Node y={0} scale={1.4}> |
| 132 | + <Rect ref={myFuncRect} width={240} height={60} x={-505} fill="#2d2d2d" radius={10} opacity={0}> |
| 133 | + <Txt text="~MyFunction()" fill="#eeeeee" fontFamily="Fira Mono" fontSize={24} /> |
| 134 | + </Rect> |
| 135 | + <Line ref={line1} points={[[-375, 0], [-295, 0]]} stroke="#569CD6" lineWidth={4} endArrow end={0} /> |
| 136 | + <Rect ref={baseRect} width={260} height={60} x={-155} fill="#2d2d2d" radius={10} opacity={0}> |
| 137 | + <Txt text="~CallableBase()" fill="#eeeeee" fontFamily="Fira Mono" fontSize={24} /> |
| 138 | + </Rect> |
| 139 | + <Line ref={line2} points={[[-15, 0], [65, 0]]} stroke="#569CD6" lineWidth={4} endArrow end={0} /> |
| 140 | + <Rect ref={implRect} width={300} height={60} x={225} fill="#2d2d2d" radius={10} opacity={0}> |
| 141 | + <Txt text="~CallableImpl<T>()" fill="#eeeeee" fontFamily="Fira Mono" fontSize={24} /> |
| 142 | + </Rect> |
| 143 | + <Line ref={line3} points={[[385, 0], [465, 0]]} stroke="#569CD6" lineWidth={4} endArrow end={0} /> |
| 144 | + <Rect ref={tRect} width={150} height={60} x={550} fill="#2d2d2d" radius={10} opacity={0}> |
| 145 | + <Txt text="~T()" fill="#eeeeee" fontFamily="Fira Mono" fontSize={24} /> |
| 146 | + </Rect> |
| 147 | + </Node> |
| 148 | + ); |
| 149 | + |
| 150 | + // 6. Destructors flow |
| 151 | + yield* codeRef().opacity(0, 1); |
| 152 | + |
| 153 | + yield* myFuncRect().opacity(1, 0.5); |
| 154 | + yield* waitFor(0.5); |
| 155 | + yield* line1().end(1, 0.5); |
| 156 | + yield* baseRect().opacity(1, 0.5); |
| 157 | + yield* waitFor(0.5); |
| 158 | + yield* line2().end(1, 0.5); |
| 159 | + yield* implRect().opacity(1, 0.5); |
| 160 | + yield* waitFor(0.5); |
| 161 | + yield* line3().end(1, 0.5); |
| 162 | + yield* tRect().opacity(1, 0.5); |
| 163 | + yield* waitFor(3); |
| 164 | + |
| 165 | + yield* all( |
| 166 | + tRect().opacity(0, 0.5), |
| 167 | + line3().opacity(0, 0.5), |
| 168 | + implRect().opacity(0, 0.5), |
| 169 | + line2().opacity(0, 0.5), |
| 170 | + baseRect().opacity(0, 0.5), |
| 171 | + line1().opacity(0, 0.5), |
| 172 | + myFuncRect().opacity(0, 0.5), |
| 173 | + ); |
| 174 | + |
| 175 | + yield* centerOn(codeRef(), DEFAULT, 0, 20); |
| 176 | + yield* codeRef().opacity(1, 1); |
| 177 | + |
121 | 178 | yield* centerOn(codeRef(), DEFAULT, 1, 20); |
122 | 179 | yield* waitFor(3); |
123 | 180 | }); |
0 commit comments