0.1.4 • Published 1 year ago

react-polygon-drawer v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-polygon-drawer

Draw polygon over any element

NPM JavaScript Style Guide

Install

npm i react-polygon-drawer

Usage

import React from 'react'
import logo from './Demo.png'

import ReactPolygonDrawer from 'react-polygon-drawer'

const App = () => {
  return <div>
    <img src={logo}/>
    <ReactPolygonDrawer/>
  </div>
}

Props

Prop NameTypeDescriptionDefault Value
heightnumberPass height of the image400
widthnumberPass width of the image400
lineWidthnumber?Width of the line to be sketched on canvas3
lineColorstring?Color of the line to be sketched on canvas'#FF3333'
pointColorstring?Color of the point to be dotted on canvas'#FF3333'
fillColorstring?Color of the fill region of polygon'rgba(205, 92, 92, 0.5)'
disableAutoClosingboolean?if false, double click closes the polygon automatically, else select the closing coordinates manually by clickingfalse
proximitynumber?Approximated value near inital start point of polygon, in the vicinity of which if user clicks, polygon closes20
existingCoordinatesCoordinate[]List of {x,y} coordinates to be rendered-
minPointsnumber?Minimum number of points in polygon-
maxPointsnumber?Maximum number of points in polygon-
onFinish(coordinates: Coordinate[])=>voidCallback function once polygon is drawn-
onPoint(coordinate: Coordinate)=>voidCallback function once point is dotted-
/**
 * @typedef {Object} Coordinate
 * @prop {number} x
 * @prop {number} y
 */

For Contribution and Run Example

git clone "https://github.com/apra-Labs/react-polygon-drawer.git"
cd react-polygon-drawer
npm i
cd examples
npm i
npm start

License

MIT © apra-labs

Contributors