react-handy-renderer
✏️ Draw 2D primitives in sketchy style with React
Install
npm install react-handy-renderer
Usage
react-handy-renderer
exposes a set of five primitives:
- Rectangle
- RoundedRect
- Line
- Curve
- Ellipse
and one wrapper component called Paper which serves as a canvas on which these primitives are drawn.
Here is a basic example -
Examples
RoundedRect
Rectangle
Ellipse
Line
Curve
Usage with ReactDOM renderer
You can also render the primitives when working with ReactDOM as this just renders to a canvas node.
Example -
API
Paper
Wrapper component for creating the canvas.
Props
-
width
- width of the canvas -
height
- height of the canvas -
roughness
- Number value for changing the roughness of shapes -
bowing
- Number value for changing the bowing of lines -
maxOffset
- Number value for giving coordinates an offset,
Curve
Props
-
c1
- First control point'sx
andy
coordinate values -
c2
- Second control point'sx
andy
coordinate values -
c3
- Third control point'sx
andy
coordinate values -
c4
- Fourth control point'sx
andy
coordinate values -
roughness
- Number value for changing the roughness -
bowing
- Number value for changing the bowing of lines -
maxOffset
- Number value for giving coordinates an offset, -
color
- String value for color
Ellipse
Props
-
position
- It is an object that takesx
andy
coordinate values. -
width
- defines width -
height
- defines height -
color
- sets the color for stroke -
weight
- sets the stroke thickness -
roughness
- Number value for changing the roughness -
bowing
- Number value for changing the bowing of lines -
maxOffset
- Number value for giving coordinates an offset, -
fill
- sets the fill color for filling the ellipse
Rectangle
Props
-
position
- It is an object that takesx
andy
coordinate values. -
width
- defines width -
height
- defines height -
color
- sets the color for stroke -
weight
- sets the stroke thickness -
roughness
- Number value for changing the roughness -
bowing
- Number value for changing the bowing of lines -
maxOffset
- Number value for giving coordinates an offset,
RoundedRect
Props
-
position
- It is an object that takesx
andy
coordinate values. -
width
- defines width -
height
- defines height -
radius
- sets the radius -
color
- sets the color for stroke -
weight
- sets the stroke thickness -
roughness
- Number value for changing the roughness -
bowing
- Number value for changing the bowing of lines -
maxOffset
- Number value for giving coordinates an offset,
Line
props
-
from
- An object that takesx1
andy1
coordinate value. -
to
- An object that takesx2
andy2
value -
color
- sets the color for stroke -
weight
- sets the stroke thickness -
roughness
- Number value for changing the roughness -
bowing
- Number value for changing the bowing of lines -
maxOffset
- Number value for giving coordinates an offset,
Todo
- [ ] Define hachures
- [ ] More examples