Licence
Apache-2.0
Version
0.3.3
Deps
0
Size
80 kB
Vulns
0
Weekly
0
water-animation-2d
Library for adding simple 2d water animation by a canvas
Install
npm i water-animation-2d
How to use
- Add canvas on html
<DOCTYPE html />
<html>
...
<canvas id="canvas" width="200px" height="200px">
</canvas>
...
</html>
- Create waterAnimation2d
const canvas = document.getElementById("canvas");
const waterAnim = new WaterAnimation2d(canvas);
- Run animation
waterAnim.run();
- Apply force
const canvasRect = canvas.getBoundingClientRect();
// applying force downward into the center
const forceId = waterAnim.applyForce(canvasRect.width * 0.5, {
x: 0,
y: 500
});
- Cancel force
setTimeout(() => {
waterAnim.cancelForce(forceId)
}, 200)
Example projects
water-animation-2d-exampleAuthor
Vladislav Nikolaev, react frontend developer