1.4.2 • Published 4 years ago

lasso-canvas-image v1.4.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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
1.4.2

4 years ago

1.4.1

4 years ago

1.3.2

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago