Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
canvas-sprite-ts
Advanced tools
Readme
Render sprite animation with canvas
npm i -S canvas-sprite-ts
import CanvasSprite from 'canvas-sprite-ts';
const canvas = document.createElement('canvas');
const cs = new CanvasSprite({
canvas,
fps: 10,
loop: true,
frames: 10,
imageUrl: spriteImg
});
cs.play();
cs.onLoad = () => {
console.log('img is loaded');
};
cs.onLoop = count => {
console.log(count);
};
cs.destroy();
options:
canvas: HTMLCanvasElement; // the canvas we want to render the sprite
fps?: number; // frames rendered per second
frames: number; // the number of sprite frames
imageUrl: string; // the sprite image url
loop?: number | boolean; // should sprite animation loop, number loopmeans loop times; true means infinite loop; default to false
autoPlay?: boolean; // should sprite animation play auto
methods:
play(): void; // play animation
pause(): void; // pause animation, stay in curren frame
stop(): void; // stop animation, reset to first frame
destroy(): void; // destroy animation, should be called when canvas element is removed(unmounted) from DOM, in case of memory leak
reset(config: CanvasSpriteConfig): void; // reset it
events:
onEnd: Function; // function invoked when animation ends if options.loop is false
onLoad: Function; // function invoked when img loaded;
onLoop: Function; // function invoked every time aniamtion loops;
FAQs
Render sprite animation with canvas
We found that canvas-sprite-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).