https://github.com/tntsuperman/jsvideo
https://github.com/tntsuperman/jsvideo
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tntsuperman/jsvideo
- Owner: TNTSuperMan
- License: other
- Created: 2025-01-28T07:00:21.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-03-04T10:34:11.000Z (3 months ago)
- Last Synced: 2025-03-04T11:34:59.161Z (3 months ago)
- Language: TypeScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.MD
Awesome Lists containing this project
README
# jsvideo
ScratchのアニメーションをJavaScriptで実現したくて作りました。
webmエクスポート可能です。
## usage
```js
import { L, createVideoRenderer } from "jsvideo";const video = createVideoRenderer(640, 480, [
L.rect(function*(state){
state.r = 0;
state.g = 0;
state.b = 0;
state.x = 0;
state.y = 0;
state.width = 640;
state.height = 480;
while(true) yield true;
}),
L.text(function*(state){
state.text = "えーりんえーりん!";
state.r = 255;
state.g = 255;
state.b = 255;
state.x = 0;
state.y = 0;
yield;
for(let j = 0;j < 2;j++){
for(let i = 0;i < 20;i++){
state.y += (100-state.y)/10
yield;
}
for(let i = 0;i < 20;i++){
state.y += (0-state.y)/10
yield;
}
}
})
]);
document.body.appendChild(video.canvas);
requestAnimationFrame(function callback(){
if(video.render()) return;
else requestAnimationFrame(callback);
})
```To install dependencies:
```bash
bun install
```To run:
```bash
bun run src/index.ts
```This project was created using `bun init` in bun v1.1.42. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.