Skip to content

Instantly share code, notes, and snippets.

@CmdrMahesh
Created February 14, 2022 09:50
Show Gist options
  • Save CmdrMahesh/b29cdbdc825faf03dc71eb5efd284f18 to your computer and use it in GitHub Desktop.
Save CmdrMahesh/b29cdbdc825faf03dc71eb5efd284f18 to your computer and use it in GitHub Desktop.
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