CanvasRenderingContext2D: imageSmoothingQuality 属性
CanvasRenderingContext2D 接口的 imageSmoothingQuality 属性,是 Canvas API 的一部分,允许你设置图像平滑的质量。
注意: 要使此属性生效,imageSmoothingEnabled 必须设置为 true。
值
以下之一:
默认值为 "low"。
示例
设置图像平滑质量
此示例将 imageSmoothingQuality 属性与缩放图像一起使用。
HTML
html
<canvas id="canvas"></canvas>
JavaScript
js
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let img = new Image();
img.src = "canvas_create_pattern.png";
img.onload = () => {
ctx.imageSmoothingQuality = "low";
ctx.drawImage(img, 0, 0, 300, 150);
};
结果
规范
| 规范 |
|---|
| HTML # dom-context-2d-imagesmoothingquality-dev |
浏览器兼容性
加载中…