All Projects → nitin42 → React Handy Renderer

nitin42 / React Handy Renderer

✏️ Draw 2D primitives in sketchy style with React

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Handy Renderer

Color.js
Extract colors from an image (0.75 KB) 🎨
Stars: ✭ 42 (-25%)
Mutual labels:  colors, canvas
Ditherjs
A javascript library which dithers an <img> using a fixed palette
Stars: ✭ 76 (+35.71%)
Mutual labels:  colors, canvas
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (+1755.36%)
Mutual labels:  canvas
Wz Wireframe Kit
📏 A kit to draw wireframes and note interaction details.
Stars: ✭ 54 (-3.57%)
Mutual labels:  sketch
Creature unity
2D Skeletal Animation Unity Runtimes for Creature
Stars: ✭ 50 (-10.71%)
Mutual labels:  sketch
Literallycanvas
A canvas in your browser. Literally.
Stars: ✭ 1,043 (+1762.5%)
Mutual labels:  canvas
Truncat
A Sketch plugin to truncate text.
Stars: ✭ 52 (-7.14%)
Mutual labels:  sketch
Sketch
A Common Lisp framework for the creation of electronic art, visual design, game prototyping, game making, computer graphics, exploration of human-computer interaction, and more.
Stars: ✭ 1,026 (+1732.14%)
Mutual labels:  sketch
Color Schemer
A React app to help you select a color scheme, built with styled-components and polished
Stars: ✭ 55 (-1.79%)
Mutual labels:  colors
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-10.71%)
Mutual labels:  canvas
Android Toy
不积跬步 无以至千里
Stars: ✭ 54 (-3.57%)
Mutual labels:  canvas
Sketch Name Organizer
🖌 Rename and sort artboards based on their x and y position; Rename layers based on their Style and Symbol.
Stars: ✭ 50 (-10.71%)
Mutual labels:  sketch
Colorette
Easily set the color and style of text in the terminal.
Stars: ✭ 1,047 (+1769.64%)
Mutual labels:  colors
Glslcanvas
Simple tool to load GLSL shaders on HTML Canvas using WebGL
Stars: ✭ 1,067 (+1805.36%)
Mutual labels:  canvas
Anto
🔵 Sketch Tools for AFX Designers
Stars: ✭ 48 (-14.29%)
Mutual labels:  sketch
Deep Viz
A React component library, providing concise and beautiful diversity charts with Canvas, SVG, E-map, WebGL, Dom, based on data visualization experience and commercial data display practice.
Stars: ✭ 55 (-1.79%)
Mutual labels:  canvas
Smileyrating
SmileyRating is a simple rating bar for android. It displays animated smileys as rating icon.
Stars: ✭ 1,038 (+1753.57%)
Mutual labels:  canvas
Chroma.js
JavaScript library for all kinds of color manipulations
Stars: ✭ 8,364 (+14835.71%)
Mutual labels:  colors
Vue Luck Draw
🎖🎖🎖 一个基于 vue2 / vue3 的【大转盘 / 九宫格】抽奖插件;🎉 A lucky draw plug-in based on vue2 / vue3;🎨 奖品 / 文字 / 图片 / 颜色 / 按钮均可配置,支持同步 / 异步抽奖,🎯 概率前 / 后端可控,自动根据 dpr 调整清晰度适配移动端
Stars: ✭ 1,056 (+1785.71%)
Mutual labels:  canvas
Colorschemes.jl
colorschemes, colormaps, gradients, and palettes
Stars: ✭ 55 (-1.79%)
Mutual labels:  colors

react-handy-renderer

✏️   Draw 2D primitives in sketchy style with React

Motivation

Theory on design and effects of sketchy rendering

Demo

You can find the demo here on CodeSandbox (switch on "module view" on the top right and go to /demo)

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 -

import React from 'react';
import { render, Paper, Ellipse } from 'react-handy-renderer';

function Sketch() {
  return (
    <Paper bowing={0.2} width={600} height={500}>
      <Ellipse
        position={{ x: 480, y: 100 }}
        width={50}
        height={50}
        color="mistyrose"
        weight={0.9}
        roughness={3}
      />
    </Paper>    
  );
}

render(<Sketch />, document.getElementById('canvas-container'));

Examples

RoundedRect

bounded-rect

<RoundedRect
  position={{ x: 300, y: 100 }}
  width={50}
  height={50}
  color="red"
  weight={2}
  radius={2}
  roughness={1.8}
/>

Rectangle

rectangle

<Rectangle
  position={{ x: 390, y: 100 }}
  width={50}
  height={50}
  color="green"
  weight={1}
  roughness={2.3}
/>

Ellipse

ellipse

<Ellipse
  position={{ x: 480, y: 100 }}
  width={50}
  height={50}
  color="blue" // or color={[10, 10, 10, 20]}
  weight={0.9}
  roughness={3}
  bowing={9}
  maxOffset={10}
/>

Line

line

<Line
  from={{ x: 230, y: 140 }}
  to={{ x: 530, y: 140 }}
  weight={4}
  color="mistyrose"
  roughness={2}
/>

Curve

curve

<Curve
  c1={{ x: 30, y: 50 }}
  c2={{ x: 70, y: 90 }}
  c3={{ x: 130, y: 510 }}
  c4={{ x: 230, y: 200 }}
  color="blue"
  weight={2}
  roughness={2}
/>

Usage with ReactDOM renderer

You can also render the primitives when working with ReactDOM as this just renders to a canvas node.

Example -

import React, { Component } from 'react'
import {
  render as create,
  Paper,
  Rectangle,
  Main,
  Ellipse,
  Line,
  RoundedRect,
  Curve,
} from 'react-handy-renderer'

function Sketch() {
  return (
    <Paper bowing={0.2} width={500} height={500}>
      <Line
        from={{x: 10, y: 40}}
        to={{x: 40, y: 60}}
        weight={10}
        color="red"
      />
    </Paper>
  )
}

// Renders the canvas node
create(<Sketch />, document.getElementById('root'))

// create function has already rendered the canvas node.
// So now you can continue to use React with ReactDOM as you used to.
// Make changes directly to the <Sketch /> component.
class App extends Component {
  render() {
    return (
      <div>
        REACT HANDY RENDERER
      </div>
    )
  }
}

export default App

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,

Example

Curve

Props

  • c1 - First control point's x and y coordinate values

  • c2 - Second control point's x and y coordinate values

  • c3 - Third control point's x and y coordinate values

  • c4 - Fourth control point's x and y 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

Example

Ellipse

Props

  • position - It is an object that takes x and y 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

Example

Rectangle

Props

  • position - It is an object that takes x and y 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,

Example

RoundedRect

Props

  • position - It is an object that takes x and y 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,

Example

Line

props

  • from - An object that takes x1 and y1 coordinate value.

  • to - An object that takes x2 and y2 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,

Example

Todo

  • [ ] Define hachures
  • [ ] More examples
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].