Coder Social home page Coder Social logo

using in react? about rough HOT 8 CLOSED

rough-stuff avatar rough-stuff commented on May 17, 2024
using in react?

from rough.

Comments (8)

ooade avatar ooade commented on May 17, 2024 2

Hi! I've bin busy but I quickly made an update.

Installation

 npm install react-rough@next

Usage

For now ReactRough takes render prop and gives you the rough canvas instance, so you could do whatever you wish with it.

This API will not likely change so it's safe to use. I'd just add Rough Components (Circle, Arc, e.t.c), work on docs and make a full release.

import ReactRough from 'react-rough'

render(<ReactRough
		width="500"
		height="200"
		render={rc => {
			rc.circle(80, 120, 50) // centerX, centerY, diameter
			rc.ellipse(300, 100, 150, 80) // centerX, centerY, width, height
			rc.line(80, 120, 300, 100) // x1, y1, x2, y2
		}}
	/>)

from rough.

martpie avatar martpie commented on May 17, 2024 1

You can probably use this library in combination of the componentDidMount function for first draw, and componentWillUpdate for subsequent redraws (if your drawings are dependent of your component props).

from rough.

pshihn avatar pshihn commented on May 17, 2024 1

I'm not a react guy, but someone posted a snippet on Twitter that you may find useful: https://twitter.com/LefiTarik/status/973360236764463105

from rough.

martpie avatar martpie commented on May 17, 2024 1

I could try doing React components, should not be too hard as the lib is quite small. I'll see if I have time this week-end.

from rough.

martpie avatar martpie commented on May 17, 2024

aaaand nevermind, it already exists https://www.npmjs.com/package/react-rough I think this can be closed.

from rough.

pshihn avatar pshihn commented on May 17, 2024

Actually that react imp is for the previous beta version of roughjs. I have since rewritten the code for a simpler API. Maybe you can update that particular package? or create a new one. Don't think that one would work with the new api.

from rough.

martpie avatar martpie commented on May 17, 2024

Yep I could do that

ooade/react-rough#95

from rough.

pshihn avatar pshihn commented on May 17, 2024

@ooade My bad on changing the API on you. It was early and no one was using it at the time. Sorry about that.

from rough.

Related Issues (20)

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.