forked from motion-canvas/motion-canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add tweening section (motion-canvas#115)
- Loading branch information
1 parent
87666f5
commit 369ded5
Showing
27 changed files
with
370 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
sidebar_position: 5 | ||
--- | ||
|
||
# Time Events | ||
# Time Events |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
sidebar_position: 6 | ||
--- | ||
|
||
# Transitions | ||
# Transitions |
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,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,30 @@ | ||
import {makeScene2D} from '@motion-canvas/2d/lib/scenes'; | ||
import {Circle} from '@motion-canvas/2d/lib/components'; | ||
import {useRef} from '@motion-canvas/core/lib/utils'; | ||
import {tween, easeInOutCubic} from '@motion-canvas/core/lib/tweening'; | ||
import {Color} from '@motion-canvas/core/lib/types'; | ||
|
||
export default makeScene2D(function* (view) { | ||
const circle = useRef<Circle>(); | ||
|
||
view.add( | ||
<Circle | ||
//highlight-start | ||
ref={circle} | ||
width={240} | ||
height={240} | ||
fill="#e13238" | ||
/>, | ||
); | ||
//highlight-start | ||
yield* tween(2, value => { | ||
circle.value.fill( | ||
Color.lerp( | ||
new Color('#e13238'), | ||
new Color('#e6a700'), | ||
easeInOutCubic(value), | ||
), | ||
); | ||
}); | ||
//highlight-end | ||
}); |
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,24 @@ | ||
import {makeScene2D} from '@motion-canvas/2d/lib/scenes'; | ||
import {Circle} from '@motion-canvas/2d/lib/components'; | ||
import {useRef} from '@motion-canvas/core/lib/utils'; | ||
import {tween, map, easeInOutCubic} from '@motion-canvas/core/lib/tweening'; | ||
|
||
export default makeScene2D(function* (view) { | ||
const circle = useRef<Circle>(); | ||
|
||
view.add( | ||
<Circle | ||
//highlight-start | ||
ref={circle} | ||
x={-300} | ||
width={240} | ||
height={240} | ||
fill="#e13238" | ||
/>, | ||
); | ||
//highlight-start | ||
yield* tween(2, value => { | ||
circle.value.position.x(map(-300, 300, easeInOutCubic(value))); | ||
}); | ||
//highlight-end | ||
}); |
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 | ||
} |
Oops, something went wrong.