0.0.3 • Published 3 years ago

react-arts v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

🎨 React Arts

React Arts is a library of react functional component which provides canvas sketch board in the app.

This library contains two react component CanvasSketch and CanvasSketchTool

Installation

This module is installed via npm:

npm install react-arts

CanvasSketch

CanvasSketch component appends simple canvas where a user can sketch using mouse or touch behaviour on screen.

import './App.css';
import { CanvasSketch } from 'react-arts';

function App() {

  const [clearCanvas, setClearCanvas] = useState()

  return (
    <div className="App">
      <CanvasSketch 
        height={450} 
        width={750}
        getClearCanvas = {setClearCanvas}
    />
    <button onClick={clearCanvas}>Clear Frame</button>
    </div>
  );
}

export default App;

API

NameTypeRequiredDefaultDescription
heightNumbertrue-Height of canvas
widthNumbertrue-Width of canvas
colorStringfalseblackColor for sketch
lineWidthNumberfalse4Width of the pen
lineCapStringfalseroundShape of pen for sketch
optionStringfalsepenOption for sketch pen / paint
getClearCanvasFunctionfalse-Returs clearCanvas function to setState

CanvasSketchTool

CanvasSketchTool component is advance version of CanvasSketch which also comes with a tool kit to change and use properties like color, erase, line width, clear canvas, floodfill.

import './App.css';
import { CanvasSketchTool } from 'react-arts';

function App() {

  return (
    <div className="App">
      <CanvasSketchTool
        height={450} 
        width={750} 
    />
    </div>
  );
}

export default App;

API

NameTypeRequiredDefaultDescription
heightNumbertrue-Height of canvas
widthNumbertrue-Width of canvas

Author

Satyam Lohiya