Reset canvas before each redraw

pull/2397/head
Alex P 2017-11-16 10:52:52 -08:00
parent 385e3c86da
commit c4b99bf727
1 changed files with 7 additions and 1 deletions

View File

@ -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