New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

anywhere-paint

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anywhere-paint

anywhere-paint is a library to create painting apps.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

paint

FAQs

Package last updated on 25 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts