@effing/tween 0.23.1 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm install @effing/tween
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import { tween, easeOutQuad } from "@effing/tween";
|
|
19
|
-
import {
|
|
19
|
+
import { createCanvas, renderReactElement } from "@effing/canvas";
|
|
20
20
|
|
|
21
21
|
async function* generateFrames() {
|
|
22
22
|
yield* tween(90, async ({ lower: progress }) => {
|
|
@@ -27,12 +27,16 @@ async function* generateFrames() {
|
|
|
27
27
|
const scale = 1 + 0.5 * easedProgress;
|
|
28
28
|
const opacity = easedProgress;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const canvas = createCanvas(1080, 1920);
|
|
31
|
+
const ctx = canvas.getContext("2d");
|
|
32
|
+
await renderReactElement(
|
|
33
|
+
ctx,
|
|
31
34
|
<div style={{ transform: `scale(${scale})`, opacity }}>
|
|
32
35
|
Animated!
|
|
33
36
|
</div>,
|
|
34
|
-
{
|
|
37
|
+
{ fonts }
|
|
35
38
|
);
|
|
39
|
+
return canvas.encode("png");
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
```
|
|
@@ -174,4 +178,4 @@ yield *
|
|
|
174
178
|
## Related Packages
|
|
175
179
|
|
|
176
180
|
- [`@effing/annie`](../annie) — Package frames into TAR archives
|
|
177
|
-
- [`@effing/
|
|
181
|
+
- [`@effing/canvas`](../canvas) — Render JSX to PNG for each frame
|