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

pencil.js

v3.0.2

Published

Nice modular interactive 2D drawing library.

Downloads

2,650

Readme

Pencil.js logo

:pencil2: Pencil.js

NPM Version Vulnerability Maintainability Test Coverage

Nice modular interactive 2D drawing library.

Installation

You can install Pencil.js with the following command :

npm install pencil.js

CDN

On capable browsers, the easiest way is to import the ESM package.

<script type="module">
    import { Scene } from "https://unpkg.com/pencil.js/dist/pencil.esm.js";
    
    const scene = new Scene();
</script>

If you want to go old-school, you can fetch the script with unpkg or jsdelivr.

<script src="https://unpkg.com/pencil.js"></script>
<!-- or -->
<script src="https://cdn.jsdelivr.net/npm/pencil.js"></script>

<script>
    const scene = new Pencil.Scene();
</script>

Usage

Once you have installed the library using NPM, you can start to import it.

You can either import everything under a namespace or only the package you're going to use. Pick the way that fit your style.

// The whole package under a namespace
import Pencil from "pencil.js";

const scene = new Pencil.scene();

/***/

// Just the part you need (recommended)
import { Scene } from "pencil.js";

const scene = new Scene();

In that case, you will need to use a bundler like webpack or browserify.

Documentation

The official documentation Vercel logo.

What Pencil.js do best

Abstraction

Drawing in a canvas is not trivial. First of all, the goal is to ease the use of canvas in a browser; allowing anyone to use it with its comprehensible syntax and extensible options.

OOP

OOP is great, OOP is almighty, OOP saves lives ! Others library exists, but none with a beautiful OOP syntax. It makes code look natural.

Modularity

Splitting the whole code into modules make everything cleaner. It also allows you to grab only what you need or replace what you don't like.

Documentation

A complete documentation goes a long way to help developers. All functions are assured to have a description and typed arguments and returns.

Performance

Pencil.js is able to draw thousands of shapes pretty smoothly without tanking your memory. Even more if you use the Particles generator.

Size

With Package size, Pencil.js is fairly lightweight. Furthermore, with no side effect, it's fully tree-shakable. So, any decent bundler can further reduce its footprint.

Examples

import { Scene, Rectangle } from "pencil.js";

const scene = new Scene(); // create a new scene

const position = [100, 200];
const width = 80;
const height = 50;
const options = {
    fill: "red",
};
const rectangle = new Rectangle(position, width, height, options); // Create a new red rectangle
scene.add(rectangle); // Add the rectangle to the scene

scene.render(); // Render the scene once

Take a look at more advanced examples.

Modules

Core modules

Core modules refer to all classes and methods you'll get within Pencil.js library.

Non-core modules

Non-core modules refer to packages made by us and not part of Pencil.js library. We find them useful, so maybe you will too...

  • spritesheet (CLI) Pack a set of images into a single spritesheet along its json description file.
  • vue-pencil.js Build reactive 2D graphics scene in your Vue project.
  • gif Turn any Pencil.js scene into an animated GIF.
  • text-direction Gives the rendering text direction (left to right or right to left) of a node.
  • test-environment Set a Node.js environment suitable for testing Pencil.js and Pencil.js applications.
  • canvas-gif-encoder Create a GIF stream frame by frame from a canvas rendering context.

Who is using Pencil.js ?

Take a tour of all the awesome project using Pencil.js.

Sponsors

JetBrains logo

Enterprises

We are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Contributions

You want to help us improve ? Please read the contributing manual.

Contributors

All contributions are valued, you can add yourself to this list (or request to be) whatever your contribution is.

License

MIT