Created
February 14, 2022 09:50
-
-
Save CmdrMahesh/b29cdbdc825faf03dc71eb5efd284f18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
export default class CanvasRing extends Component { | |
constructor(props) { | |
super(props); | |
} | |
initrender(){ | |
const canvas = ReactDOM.findDOMNode(this.refs.canvas_ring); | |
var ctx = canvas.getContext("2d"); | |
ctx.beginPath(); | |
ctx.arc((this.props.ring_width)/2,(this.props.ring_width)/2,(this.props.ring_width-10)/2,0,2*Math.PI); | |
ctx.strokeStyle = "#bcbce4"; | |
ctx.fillStyle = "red"; | |
ctx.lineWidth = 10; | |
ctx.stroke(); | |
} | |
componentDidMount() { | |
this.initrender(); | |
} | |
componentDidUpdate(){ | |
this.initrender(); | |
} | |
render() { | |
return ( | |
<spui-div class="cenvas_content"> | |
<canvas ref="canvas_ring" id="canvas_ring" width={this.props.ring_width} height={this.props.ring_width}></canvas> | |
</spui-div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment