canvas in react bad quality code example
Example: how to rescale a canvas in html5 without blurrriness
let dpi = window.devicePixelRatio;
let canvas = document.getElementById('myCanvas');
let ctx = canvas.getContext('2d');
function fix_dpi() {
let style_height =
+getComputedStyle(canvas).getPropertyValue("height").slice(0, -2);
let style_width =
+getComputedStyle(canvas).getPropertyValue("width").slice(0, -2);
canvas.setAttribute('height', style_height * dpi);
canvas.setAttribute('width', style_width * dpi);
}