All Projects → embiem → React Canvas Draw

embiem / React Canvas Draw

Licence: mit
React Component for drawing in canvas

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Canvas Draw

Canvas
Canvas is a Go drawing library based on OpenGL or using software rendering that is very similar to the HTML5 canvas API
Stars: ✭ 358 (-13.11%)
Mutual labels:  drawing, canvas2d, canvas
Drawingboard.js
A canvas based drawing app that you can integrate easily on your website.
Stars: ✭ 2,072 (+402.91%)
Mutual labels:  drawing, canvas
Pixelfarm
From Vectors to (sub) Pixels, C# 2D Rendering Library
Stars: ✭ 120 (-70.87%)
Mutual labels:  drawing, canvas
idraw
A simple JavaScript framework for Drawing on the web.(一个面向Web绘图的JavaScript框架)
Stars: ✭ 436 (+5.83%)
Mutual labels:  drawing, canvas
Pretty Painter
Graphics editor for Android.
Stars: ✭ 105 (-74.51%)
Mutual labels:  drawing, canvas
Omg
🎨 一个让你跳过canvas,直接绘图的 2d 绘图库,上手简单,接口简洁,功能丰富.
Stars: ✭ 107 (-74.03%)
Mutual labels:  drawing, canvas
fabricjs-image-editor-origin
fabric.js javascript image editor
Stars: ✭ 52 (-87.38%)
Mutual labels:  canvas, canvas2d
Literallycanvas
A canvas in your browser. Literally.
Stars: ✭ 1,043 (+153.16%)
Mutual labels:  drawing, canvas
awesome-canvas
Canvas资源库大全中文版。An awesome Canvas packages and resources.
Stars: ✭ 288 (-30.1%)
Mutual labels:  canvas, canvas2d
canvas-color-tracker
A utility to track objects on a canvas by unique px color
Stars: ✭ 29 (-92.96%)
Mutual labels:  drawing, canvas
Pancake
Lightweight, Fast, Easy-to-use HTML5 2D game framework!
Stars: ✭ 79 (-80.83%)
Mutual labels:  canvas, canvas2d
Sketchpad
Sketchpad is fully customisable collaborative whiteboard plugin written in pure JavaScript.
Stars: ✭ 85 (-79.37%)
Mutual labels:  drawing, canvas
Notation
✏️ A simple web app to make drawings that are easy to embed, particularly for Notion.so.
Stars: ✭ 63 (-84.71%)
Mutual labels:  drawing, canvas
Clumsy
A library written on node.js for creating math figures on HTMLCanvas in XKCD style.
Stars: ✭ 107 (-74.03%)
Mutual labels:  drawing, canvas
Mopaint
🎨💪 Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-87.86%)
Mutual labels:  drawing, canvas
Pencil.js
✏️ Nice modular interactive 2D drawing library
Stars: ✭ 204 (-50.49%)
Mutual labels:  drawing, canvas
Angular Canvas Area Draw
Simple library to draw polygons over image with canvas
Stars: ✭ 21 (-94.9%)
Mutual labels:  drawing, canvas
Minipaint
online image editor
Stars: ✭ 1,014 (+146.12%)
Mutual labels:  drawing, canvas
cidrawing
A vector graphics library for Android
Stars: ✭ 35 (-91.5%)
Mutual labels:  drawing, canvas2d
Melonjs
a fresh & lightweight javascript game engine
Stars: ✭ 3,721 (+803.16%)
Mutual labels:  canvas2d, canvas

React Canvas Draw

A simple yet powerful canvas-drawing component for React (Demo)

Travis Coveralls npm package downloads MIT License

All Contributors PRs Welcome

Watch on GitHub Star on GitHub Tweet

Edit 6lv410914w

Installation

Install via NPM:

npm install react-canvas-draw --save

or YARN:

yarn add react-canvas-draw

Usage

import React from "react";
import ReactDOM from "react-dom";
import CanvasDraw from "react-canvas-draw";

ReactDOM.render(<CanvasDraw />, document.getElementById("root"));

For more examples, like saving and loading a drawing ==> look into the /demo/src folder.

Props

These are the defaultProps of CanvasDraw. You can pass along any of these props to customize the CanvasDraw component. Examples of how to use the props are also shown in the /demo/src folder.

  static defaultProps = {
    onChange: null
    loadTimeOffset: 5,
    lazyRadius: 30,
    brushRadius: 12,
    brushColor: "#444",
    catenaryColor: "#0a0302",
    gridColor: "rgba(150,150,150,0.17)",
    hideGrid: false,
    canvasWidth: 400,
    canvasHeight: 400,
    disabled: false,
    imgSrc: "",
    saveData: null,
    immediateLoading: false,
    hideInterface: false
  };

Functions

Useful functions that you can call, e.g. when having a reference to this component:

  • getSaveData() returns the drawing's save-data as a stringified object
  • loadSaveData(saveData: String, immediate: Boolean) loads a previously saved drawing using the saveData string, as well as an optional boolean flag to load it immediately, instead of live-drawing it.
  • clear() clears the canvas completely
  • undo() removes the latest change to the drawing. This includes everything drawn since the last MouseDown event.

Local Development

This repo was kickstarted by nwb's awesome react-component starter.

You just need to clone it, yarn it & start it!

Tips

If you want to save large strings, like the stringified JSON of a drawing, I recommend you to use pieroxy/lz-string for compression. It's LZ compression will bring down your long strings to only ~10% of it's original size.

Acknowledgement

The lazy-brush project as well as its demo app by dulnan have been a heavy influence.

I borrowed a lot of the logic and actually used lazy-brush during the push to v1 of react-canvas-draw. Without it, react-canvas-draw would most likely still be pre v1 and wouldn't feel as good.

Contributors

Thanks goes to these wonderful people (emoji key):


Martin Beierling-Mutz

💻 📖 💡 🤔

Jan Hug

🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT, see LICENSE for details.

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].