I'm looking to make a finished canvas project resizeable. Some websites I've read recommend using CSS to restyle, however I've also seen people say never to do that because it blurs text by stretching things. But if you simply tell the canvas to resize in javascript won't filltexts such as in the example below need to be redone?
var canvas = document.getElementById("example");
var ctx = canvas.getContext('2d');
var cornerRadius = 10;
function drawMe() {
ctx.fillStyle = "red";
ctx.strokeStyle = "red";
ctx.lineJoin = "round";
ctx.lineWidth = cornerRadius;
ctx.strokeRect(5+(cornerRadius/2), 23+(cornerRadius/2), 155-cornerRadius, 406-cornerRadius);
ctx.fillRect(5+(cornerRadius/2), 23+(cornerRadius/2), 155-cornerRadius, 406-cornerRadius);
ctx.font = '16pt Arial';
ctx.fillStyle = 'white';
ctx.textAlign="start";
ctx.fillText('Text', 8, 70);
ctx.fillText('Text', 8, 128);
}
function redraw() {
ctx.strokeStyle = 'blue';
ctx.lineWidth = '5';
ctx.strokeRect(0, 0, window.innerWidth, window.innerHeight);
drawMe();
}
window.onload = function () {
redraw();
};
Example of project.
Canvas is set in html to 1280 x 800.
edited to include https://jsfiddle.net/o1rkg1tf/