lasso-canvas-image
v1.4.2
Published
Lasso tool for HTML5 Image in Javascript, using Canvas
Downloads
74
Maintainers
Readme
lasso-canvas-image
Polygon selecting tool for HTML5 Image Element
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
Syntax
function createLasso ({
element: HTMLImageElement,
radius?: number,
onChange?: (polygon: string) => void,
onUpdate?: (polygon: string) => void,
enabled?: boolean
})
Options
element
DOM HTMLImageElement Instanceradius
The radius of the circle's dots on the canvasonChange
Runs when the selected area is updated or points are moved by the useronUpdate
Runs when the selected area is updatedenabled
defaults to true