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

anywhere-paint

v1.0.2

Published

anywhere-paint is a library to create painting apps.

Downloads

19

Readme

anywhere-paint

Test npm version

anywhere-paint is a library to create painting apps. Sample is here!

DEMO

demo

Installation

npm install --save anywhere-paint

How to use

Create an AnywherePaint obj:

const container = document.getElementById('container'); //The aspect ratio of the container should be equal to the resolution.
const width = 600;  //width resolution
const height = 400; //height resolution
const awPaint = new AnywherePaint(container, width, height);

now you can draw lines.

Create a ColorCircle obj:

const container = document.getElementById('cc-container');  //The aspect ratio of the container should be 1:1
awPaint.createColorCircle(container);

color is automatically picked when you draw lines.

Methods

Undo, Redo

awPaint.undo(): void;
awPaint.redo(): void;

Layers

This library supports layer. You can only draw on selected layer. Unique number is assigned to each layer.

awPaint.addLayer(layerNum?: undefined | number): number;

If no arguments are specified, a new layer is added at the top. Otherwise, a new layer is added on top of the layerNum. Returns unique number which is assigned to new layer.

awPaint.removeLayer(layerNum: number): number | null;

Remove specified layer. Returns newly selected layer number. If there is not any layers, this function returns null.

awPaint.renameLayer(layerNum: number, layerName: string): void;

You can assign layer name to each layer.

awPaint.getLayerNames(): Map<number, string>;

Returns Map<layerNum, layerName>.

awPaint.selectLayer(layerNum: number): void;

Select layer which you want to draw.

awPaint.getLayerImages(): Map<number, string>;

Returns Map<layerNum, DataURI>.

awPaint.getSortOrder(): number[];

Returns an array of layerNum sorted by layer overlap order.

awPaint.setSortOrder(sortOrder: number[]): boolean;

sortOrder is an array which includes layerNums.

Example ) [0, 2, 1]. At this time, 0 is the top and 1 is the buttom.

If argument is valid, layers are sorted by input.

Returns argument is valid or not.

Line

awPaint.setColor(r: number, g: number, b: number): void;

Set line color by r (0-255), g (0-255), b (0-255).

awPaint.setLineWidth(px: number): void;

Set line width(px).

Image

awPaint.getIntegratedImage(): string;

Returns DataURI with a layer-integrated image. (png)

Mode

awPaint.changeMode(style: "Pencil" | "Eraser" | "Fill"): void;

Change drawing mode. style is "Pencil", "Eraser" or "Fill".

History

awPaint.addEventListener(callback: (history: History) => void);

Add callback that will be called when canvas is edited. The parameter of callback is command object of canvas operation. Returns listenerID.

awPaint.removeEventListener(listener: number): void;

Remove eventListener.

awPaint.drawByHistory(history: History): void;

Operate canvas using history.

Properties

awPaint.selectingLayer

layerNum which is selecting.

TypeScript

Write this in tsconfig.json.

{
    "compilerOptions": {
        "moduleResolution": "node",
        "esModuleInterop": true,
    }
}

Lisence

MIT