diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-08 20:16:55 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:59 +0200 |
| commit | c9e70ec95f733caa253b362e154b47cd5a26cbfe (patch) | |
| tree | a4e221822909faaab66358ee066036c46a732178 /src/components/map/elements/ImageComponent.js | |
| parent | 6296bb95ba93cb9111e19f06329b6c9b9aec57d5 (diff) | |
Display rack space and energy fill on overlay
Diffstat (limited to 'src/components/map/elements/ImageComponent.js')
| -rw-r--r-- | src/components/map/elements/ImageComponent.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/components/map/elements/ImageComponent.js b/src/components/map/elements/ImageComponent.js new file mode 100644 index 00000000..00766496 --- /dev/null +++ b/src/components/map/elements/ImageComponent.js @@ -0,0 +1,39 @@ +import PropTypes from "prop-types"; +import React from "react"; +import {Image} from "react-konva"; + +class ImageComponent extends React.Component { + static propTypes = { + src: PropTypes.string.isRequired, + x: PropTypes.number.isRequired, + y: PropTypes.number.isRequired, + width: PropTypes.number.isRequired, + height: PropTypes.number.isRequired, + opacity: PropTypes.number.isRequired, + }; + + state = { + image: null + }; + + componentDidMount() { + const image = new window.Image(); + image.src = this.props.src; + image.onload = () => this.setState({image}); + } + + render() { + return ( + <Image + image={this.state.image} + x={this.props.x} + y={this.props.y} + width={this.props.width} + height={this.props.height} + opacity={this.props.opacity} + /> + ) + } +} + +export default ImageComponent; |
