-
-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(2d): add save and restore methods to nodes (#406)
- Loading branch information
1 parent
8965ab1
commit 870e194
Showing
9 changed files
with
218 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"version": 1, | ||
"seed": 1271865379 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {makeScene2D} from '@motion-canvas/2d'; | ||
import {Circle} from '@motion-canvas/2d/lib/components'; | ||
import {createRef} from '@motion-canvas/core/lib/utils'; | ||
import {all} from '@motion-canvas/core/lib/flow'; | ||
|
||
export default makeScene2D(function* (view) { | ||
const circle = createRef<Circle>(); | ||
|
||
view.add( | ||
<Circle | ||
// highlight-start | ||
ref={circle} | ||
size={150} | ||
position={[-300, -300]} | ||
fill={'#e13238'} | ||
/>, | ||
); | ||
|
||
circle().save(); | ||
yield* all(circle().position.x(0, 1), circle().scale(1.5, 1)); | ||
|
||
circle().save(); | ||
yield* all(circle().position.y(0, 1), circle().scale(0.5, 1)); | ||
|
||
circle().save(); | ||
yield* all(circle().position.x(300, 1), circle().scale(1, 1)); | ||
|
||
yield* circle().restore(1); | ||
yield* circle().restore(1); | ||
yield* circle().restore(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {makeProject} from '@motion-canvas/core'; | ||
|
||
import scene from './scenes/tweening-save-restore?scene'; | ||
|
||
export default makeProject({ | ||
scenes: [scene], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters