From 09e201a0505cd80361169875916be3cc0db24a67 Mon Sep 17 00:00:00 2001 From: Andrew Guterman Date: Mon, 19 Feb 2018 20:23:59 -0800 Subject: [PATCH 1/2] defaultImage and onDraw --- lib/index.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/index.jsx b/lib/index.jsx index e8bbc72..4ea741f 100644 --- a/lib/index.jsx +++ b/lib/index.jsx @@ -15,6 +15,17 @@ class DrawableCanvas extends React.Component { const context = canvas.getContext('2d'); + if(this.props.defaultImage) + { + let image = new Image(); + image.src = this.props.defaultImage; + + image.onload = function() + { + context.drawImage(image, 0, 0, canvas.width, canvas.height); + }; + } + this.setState({ canvas, context @@ -94,6 +105,11 @@ class DrawableCanvas extends React.Component { this.setState({ drawing: false }); + + if(this.props.onDraw) + { + this.props.onDraw(this.state.canvas.toDataURL()); + } } draw(lX, lY, cX, cY) { From 84e21177ae14b8ded03633f6011f226a24193a65 Mon Sep 17 00:00:00 2001 From: Andrew Guterman Date: Fri, 29 Jun 2018 16:07:01 -0700 Subject: [PATCH 2/2] Built new version --- .gitignore | 1 - lib/index.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 lib/index.js diff --git a/.gitignore b/.gitignore index 5d42bc7..57886fa 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,6 @@ Thumbs.db # Custom ##################### node_modules -lib/index.js # Bundles created by webpack **/public/*.js diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..ffcb6a2 --- /dev/null +++ b/lib/index.js @@ -0,0 +1 @@ +"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var a=0;a