首页 > 解决方案 > 我可以增加 HTML5 画布分辨率吗?

问题描述

Html 画布会降低图像和形状的分辨率。有什么方法可以提高质量吗?

标签: javascripthtmlcanvasgraphics

解决方案


当然:

const width = ..., height = ..., scale = 2;
const canvas = document.querySelector('...')
canvas.style.width = width;
canvas.style.height = height;
canvas.width = width * scale;
canvas.height = height * scale;

推荐阅读