1.4.2 • Published 5 years ago
lasso-canvas-image v1.4.2
lasso-canvas-image
Polygon selecting tool for HTML5 Image Element

Instalation
npm i lasso-canvas-imageUsage
// 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
elementDOM HTMLImageElement InstanceradiusThe radius of the circle's dots on the canvasonChangeRuns when the selected area is updated or points are moved by the useronUpdateRuns when the selected area is updatedenableddefaults to true