ninja-canvashelper
v0.1.1
Published
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/steelWinds/ninja-canvashelper/build-lint?label=build&style=flat-square)
Downloads
21
Readme
ninja-canvashelper
Simple library for simplification work with Canvas
Getting started
Install
pnpm add canvashelper
Usage
import CanvasHelper from 'ninja-canvashelper';
const cHelper = new CanvasHelper();
const canvas = cHelper.createCanvasField(
'canvas-id',
{
iSize: 400,
bSize: 400,
parentSelector: 'body',
styleClass: 'custom-canvas',
}
);
Docs
CanvasHelper
cHelper.createCanvasField(id, options)
- create canvas instance ang get itcHelper.addCanvasField(id, element)
- add canvas element ang get itcHelper.removeCanvasField(id)
- remove canvas instance by idcHelper.getCanvasById(id)
- get canvas instance by idcHelper.collection
- get all created canvases
CanvasItem
canvas.canvasNode
- get canvas elementcanvas.context2D
- get canvas 2d contextcanvas.parent
- get parent node of canvascanvas.draw
- get canvas draw toolcanvas.id
- get canvas SHA-256 id
CanvasDrawing
canvas.draw.clear(full, options)
- clear canvas field full, or with optionscanvas.draw.drawRect(options)
- draw rect with optionscanvas.draw.drawLine(options, lineOptions)
- draw line with optionscanvas.draw.drawArc(options)
- draw circle with options
License
Check license in LICENSE file