npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@curiousmedia/canvas-animator

v1.1.2

Published

Generate AnimateCC spritesheets and display them in a canvas element

Downloads

1

Readme

CanvasAnimator

Generate AnimateCC spritesheets and display them in a canvas element

How to generate a Sprite Sheet from Animate CC for use with Canvas Animator:

Right click on the symbol you want to export and choose Generate Sprite Sheet...

Choose from available export options.

Verify Data Format is set to JSON-Array and click Export

Usage:

Load and Parse the JSON-Array data that was exported from AnimateCC

Make a new instance of CanvasAnimator:

let animation = new CanvasAnimator(
    document.querySelector('canvas'),
    jsonData,
    60,
    false
);

Event Listeners

    animation.on('complete', function(event){
        console.log(event.frame);
    });

new CanvasAnimator(element, data, framerate, loop)

Constructor

| Param | Type | Default | Description | | --- | --- | --- | --- | | element | Canvas | | Required: The canvas element to display the animation on | | data | Object | | Required: The JSON Array data from Animate CC | | framerate | Number | 24 | Optional: Framerate to run the animation at Default: 24 | | loop | Bool | true | Optional: Does the animation loop or play once and stop Default: true |

canvasAnimator.framerate - GETTER

Get the framerate our animation is playing at

canvasAnimator.framerate - SETTER

Set the framerate to play the animation at

| Param | Type | Description | | --- | --- | --- | | rate | Number | FPS for the animation to run at |

canvasAnimator.loop - GETTER

Get the loop property

canvasAnimator.loop - SETTER

Set the loop property to be true or false

| Param | Type | | --- | --- | | bool | Bool |

canvasAnimator.handleImageLoaded()

Image onload handler called when the image is done loading

canvasAnimator.drawFrame(dataFrame)

Draw the image based on data from the JSON data array

| Param | Type | | --- | --- | | dataFrame | Object |

canvasAnimator.play()

Play the animation

canvasAnimator.pause()

Pause the animation

canvasAnimator.gotoAndPlay(frame)

Go to the specific frame number

| Param | Type | Description | | --- | --- | --- | | frame | Number | frame number to go to |

canvasAnimator.render()

Request Animation Frame

canvasAnimator.on(type, listener, useCapture)

Shortcut to add event listeners for the canvas element

| Param | Type | Default | Description | | --- | --- | --- | --- | | type | String | | Required. A String that specifies the name of the event. | | listener | function | | Required. Specifies the function to run when the event occurs. | | useCapture | Bool | false | Optional. A Boolean value that specifies whether the event should be executed in the capturing or in the bubbling phase. |

canvasAnimator.off(type, listener, useCapture)

Shortcut to remove event listeners for the canvas element

| Param | Type | Default | Description | | --- | --- | --- | --- | | type | String | | Required. A String that specifies the name of the event. | | listener | function | | Required. Specifies the function to run when the event occurs. | | useCapture | Bool | false | Optional. A Boolean value that specifies whether the event should be executed in the capturing or in the bubbling phase. |

Events

Start

Called when the image is loaded and the RequestAnimationFrame begins

Change

Called when a new frame in the animation is rendered

Complete

Called when the last frame of the animation has played and the animation is returning to Frame 0 unless loop = false