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

canvas-compositor

v3.0.2

Published

a light and performant canvas compositing engine

Downloads

152

Readme

canvas-compositor

A light, performant compositing engine for the HTML5 canvas

Getting started

You should be able to include the compiled files from the dist directory in any HTML page, which will add the CanvasCompositor namespace to your global scope. I like to assign it to a shorthand cc.

You can then start using the CanvasCompositor's scene and graphics APIs by instantiating it with a canvas:

let cc = CanvasCompositor;
let _cc = new cc.Compositor(document.getElementById('myCanvas'));

Our _cc variable will expose a variety of classes for drawing primitives (e.g.: Path, Rectangle, Ellipse, Text, etc.) which are used to build Compositions. Each of these types of objects extends the PrimitiveComponent class, which in turn extends the EventEmitter class from the micro-mvc dependency.

The _cc variable will have a scene property. If you are only drawing pixels to canvas, this property is unnecessary, but if you intend to have any kind of animated or layered interactions, this object will be incredibly important.

The scene property is the entry point to your scene graph. It is an instance of Composition (which is also exposed, and can be extended freely). Compositions have children - the order of the scene's children determines the order in which they are drawn.

Compositions like scene can have children added to them through the addChild or addChildren method. The children can be Compositions or any other inheritor of the PrimitiveComponent class.

Compositions and PrimitiveComponents, in conjunction with Rectangles, Ellipses, Text etc., comprise an implementation of the Composite Pattern - thus, "canvas-compositor".

View the demo here

Dependencies

  • vectorious
    • the Vector class exposed by vectorious is used heavily throughout canvas-compositor
  • micro-mvc
    • the EventEmitter class exposed by micro-mvc is the basis of canvas-compositor's event system

Documentation

Documentation has been generated by ESDoc and can be found on github at https://christophergorexyz.github.io/canvas-compositor/

Tests

Mocha tests are in-development.