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