Skip to content

xiao-e-yun/sakuraFx-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sakuraFx-typescript

Animation based on WebGL.

It is Sakura for TypeScript version.
fork from gryng02

Install pnpm add -D sakurafx-typescript

In html

<canvas id="sakura"></canvas>

In TypeScript

//import
import sakura from "sakurafx-typescript";

//get canvas
const canvas = document.getElementById("sakura") as HTMLCanvasElement

//set canvas size
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

//initialization and get render
const render = sakura(canvas) as () => void

if(render) {
  //creat animation callback
  function callback(){
    render() //render
    requestAnimationFrame(callback) //call self in next frame
  }

  callback()
}