Coder Social home page Coder Social logo

pragmaapps / react-sketch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tbolis/react-sketch

0.0 1.0 0.0 3.61 MB

Sketch Tool for React based applications, backed up by FabricJS

Home Page: http://tbolis.github.io/showcase/react-sketch/

License: MIT License

JavaScript 100.00%

react-sketch's Introduction

react-sketch

GitHub release NPM release NPM downloads Build status

A Sketch tool for React based applications, backed-up by FabricJS

idea-image Please note that this module is still in development! Feel free to send me enhancements and ideas :)

Installation

npm install react-sketch --save

or with yarn

yarn add react-sketch

Source installation

In order to build from source, read the relevant instructions first.

Tested with node versions 6,7,8.

Usage

Import the relevant SketchField component and use it, you can find more on the examples folder of the project

import {SketchField, Tools} from 'react-sketch';

class SketchFieldDemo extends React.Component {
     render() {
        return (
            <SketchField width='1024px' 
                         height='768px' 
                         tool={Tools.Pencil} 
                         lineColor='black'
                         lineWidth={3}/>
        )
     }
}

Configuration Options

Option Type Default Description
tool Enumeration (string) pencil The tool to use, can be select, pencil, circle, rectangle, pan
lineColor String black The color of the line
lineWidth Number 1 The width of the line
fillColor String transparent The fill color (hex format) of the shape when applicable (e.g. circle)
backgroundColor String transparent The the background color of the sketch in hex or rgba
undoSteps Number 15 number of undo/redo steps to maintain
imageFormat String png image format when calling toDataURL, can be png or jpeg
width Number No Value(null) Set/control the canvas width, if left empty the sketch will scale to parent element
height Number 512 Set/control the canvas height, if left empty the sketch will take a reasonable default height
value JSON Property to utilize and handle the sketch data as controlled component
defaultValue JSON Default initial data, to load. If value is set then value will be loaded instead
widthCorrection Number 2 Specify some width correction which will be applied on resize of canvas, this will help to correct some possible border on the canvas style
heightCorrection Number 0 Specify some height correction which will be applied on resize of canvas, this will help to correct some possible border on the canvas style

Available tools

Tool Description
Pencil Free drawing pencil
Line Gives you the ability to draw lines
Rectangle Create rectangles
Circle Create circles
Rectangle Create Rectangles
Select Disables drawing and gives you the ability to modify existing elements in the canvas
Pan Disables drawing and gives you the ability to move the complete canvas at will, useful to adjust the canvas when zooming in or out (thank you wmaillard)

Examples

The project includes a webpack server for running the examples, just run:

git clone https://github.com/tbolis/react-sketch.git
yarn install
npm start

and navigate to http://localhost:23000

You can as well check the live showcase here: http://tbolis.github.io/showcase/react-sketch/

Issues

See https://github.com/tbolis/react-sketch/issues

Changelog

See https://github.com/tbolis/react-sketch/blob/master/CHANGELOG.md

License

MIT, do remember to add a reference if you find it useful :)

react-sketch's People

Contributors

abhinav-maheshwari avatar afilp avatar dhyegocalota avatar fluxehub avatar inf3cti0n95 avatar karlvr avatar narendernagpal avatar pomelyu avatar shafy avatar tarik-djurdjevic avatar tbolis avatar vishalbhatia764 avatar wmaillard avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.