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 |
瀏覽器相容性
載入中…