Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
react-canvas-draw
Advanced tools
A simple yet powerful canvas-drawing component for React (Demo).
Install via NPM:
npm install react-canvas-draw --save
or YARN:
yarn add react-canvas-draw
No additional dependencies needed.
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.
Even more examples are coming, check back soon!
static defaultProps = {
loadTimeOffset: 5,
brushSize: 6,
brushColor: "#444",
canvasWidth: 400,
canvasHeight: 400,
disabled: false
};
Useful functions that you can call, e.g. when having a reference to this component:
getSaveData()
returns the drawing's save-data as stringified JSONloadSaveData(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 completelyundo()
removes the latest change to the drawing. This includes everything drawn since the last MouseDown event.drawLine(line)
to draw a line. This can be useful if you want to automate drawing. The line parameter is an object of the following form:const line = {
color: this.props.brushColor,
size: this.props.brushSize,
startX: this.x,
startY: this.y,
endX: newX,
endY: newY
};
This repo was kickstarted by nwb's awesome react-component starter.
You just need to clone it, yarn it & start it!
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.
MIT, see LICENSE for details.
FAQs
A simple yet powerful canvas-drawing component for React.
The npm package react-canvas-draw receives a total of 5,855 weekly downloads. As such, react-canvas-draw popularity was classified as popular.
We found that react-canvas-draw demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.