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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@louis700/drawjs

v1.1.0

Published

This library has been created to draw easier on a canvas.

Readme

drawJS

This library has been created to draw easier on a canvas, you can target one and then don't have to create a global variable to save its context!

How to use it?

Import it

To import DrawJS, you can use npm with the command:

npm i @louis700/drawjs

Then, you have to specify you want to import JS files from your script with the attribute type set to module:

<script type="module" src="script.js"></script>

Target a context

To focus on the canvas to use, you have to call the function setTargetContext(ctx) located in drawJS module. Example:

import {drawJS} from "./node_modules/@louis700/drawjs/index.js";

window.onload = function() {
	let canvas = document.querySelector("canvas");
	drawJS.setTargetContext(canvas.getContext("2d"));
}

To use another context, you have to change the focus or to specify it as the last parameter:

import {shapes} from "./node_modules/@louis700/drawjs/index";

shapes.rect(0, 0, 100, 100, ctx);

Create a color

To create a color, this lib contains the class Color in the module color. There are two ways to create a color:

RGB/RGBA

If you don't know the RGBA color system, this Wikipedia page will help you: RGBA color space. The complete way to create a RGBA color is to specify all the parameters in the constructor Color(r, g, b, a, type):

import {color as color_m} from "./node_modules/@louis700/drawjs/index";

let color = new color_m.Color(255, 52, 52, 1, ColorType.RGB);

But hopefully, there are some shortcuts:

  • When you use the RGBA system, you don't have to specify the type: new Color(r, g, b, a)
  • When you want a color with an opacity of 1, you could write it like this: new Color(r, g, b)
  • And if you want to use the same value for the lasts parameters, it will be repeated automatically: new Color(52)new Color(52, 52, 52) new Color(255, 52)new Color(255, 52, 52)

HSL/HSLA

There is a Wikipedia page about the HSLA system: HSL and HSV. This time, there are no shortcuts, you have to specify all the parameters each time new Color(h, s, l, a, type):

import {color as color_m} from "./node_modules/@louis700/drawjs/index";

let color = new color_m.Color(240, 100, 60, ColorType.HSL);

Draw on the canvas

To draw on the canvas, you can first define the colors (the default color is the black). To define the color of the stroke, you have to you use stroke(color), and to define the color that will fill the shape, you have to use fill(color). If you don't want to draw the stroke or to fill the shape, you can use noFill() and noStroke() (to draw again, you just have to specify color). Two other functions use the color: background(color) and border(color), the first fills the whole canvas with the specified color, and the other one will outline it.

import {style} from "./node_modules/@louis700/drawjs/index.js";

style.stroke(color);
style.fill(color);
style.noFill();
style.noStroke();
style.background(color);
style.border(color);