lasso-canvas-image
TypeScript icon, indicating that this package has built-in type declarations

1.4.2 • Public • Published

lasso-canvas-image

Polygon selecting tool for HTML5 Image Element

View

Instalation

npm i lasso-canvas-image

Usage

// ES6 modules with Babel or TypeScript
import createLasso from 'lasso-canvas-image';
 
// CommonJS modules
const createLasso = require('lasso-canvas-image');
 
// Init
const lasso = createLasso({
  element: document.querySelector('img'),
  radius: 10,
  onChange (polygon) {
    console.log('Selection area changed: ' + polygon);
  },
  onUpdate (polygon) {
    console.log('Selection area updated: ' + polygon);
  }
});
 
// Methods
lasso.reset();
lasso.setPath('100,100 300,100 200,200');
 
lasso.disable();
lasso.enable();

Examples

Check out this example

Edit lass-canvas-image

Syntax

function createLasso ({
  element: HTMLImageElement,
  radius?: number,
  onChange?: (polygon: string=> void,
  onUpdate?: (polygon: string=> void,
  enabled?: boolean
})

Options

  • element DOM HTMLImageElement Instance
  • radius The radius of the circle's dots on the canvas
  • onChange Runs when the selected area is updated or points are moved by the user
  • onUpdate Runs when the selected area is updated
  • enabled defaults to true

Package Sidebar

Install

npm i lasso-canvas-image

Weekly Downloads

12

Version

1.4.2

License

MIT

Unpacked Size

12.2 kB

Total Files

5

Last publish

Collaborators

  • akcyp