Reset canvas before each redraw
parent
385e3c86da
commit
c4b99bf727
|
@ -17,13 +17,19 @@ class Gauge extends Component {
|
|||
this.updateCanvas()
|
||||
}
|
||||
componentDidUpdate() {
|
||||
console.log('didupdate')
|
||||
this.updateCanvas()
|
||||
}
|
||||
resetCanvas = (canvas, context) => {
|
||||
context.setTransform(1, 0, 0, 1, 0, 0)
|
||||
context.clearRect(0, 0, canvas.width, canvas.height)
|
||||
}
|
||||
|
||||
updateCanvas = () => {
|
||||
const canvas = this.canvasRef
|
||||
const ctx = canvas.getContext('2d')
|
||||
|
||||
this.resetCanvas(canvas, ctx)
|
||||
|
||||
const centerX = canvas.width / 2
|
||||
const centerY = canvas.height / 2 * 1.13
|
||||
const radius = canvas.width / 2 * 0.5
|
||||
|
|
Loading…
Reference in New Issue