这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
imageSmoothingQuality
特性为
CanvasRenderingContext2D
interface, part of the
画布 API
, lets you set the quality of image smoothing.
注意:
For this property to have an effect,
imageSmoothingEnabled
必须为
true
.
ctx.imageSmoothingQuality = "low" || "medium" || "high"
可能的值:
"low"
Low quality.
"medium"
Medium quality.
"high"
High quality.
此范例使用
imageSmoothingQuality
property with a scaled image.
<canvas id="canvas"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
let img = new Image();
img.src = 'https://mdn.mozillademos.org/files/222/Canvas_createpattern.png';
img.onload = function() {
ctx.imageSmoothingQuality = 'low';
ctx.drawImage(img, 0, 0, 300, 150);
};
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'imageSmoothingQuality' in that specification. |
实时标准 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
imageSmoothingQuality
|
Chrome 54 | Edge ≤79 | Firefox No | IE ? | Opera 41 | Safari Yes | WebView Android 54 | Chrome Android 54 | Firefox Android No | Opera Android 41 | Safari iOS Yes | Samsung Internet Android 6.0 |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
CanvasRenderingContext2D
CanvasRenderingContext2D.imageSmoothingEnabled
image-rendering
CanvasRenderingContext2D
addHitRegion()
arc()
arcTo()
beginPath()
bezierCurveTo()
clearHitRegions()
clearRect()
clip()
closePath()
createImageData()
createLinearGradient()
createPattern()
createRadialGradient()
drawFocusIfNeeded()
drawImage()
drawWidgetAsOnScreen()
drawWindow()
ellipse()
fill()
fillRect()
fillText()
getImageData()
getLineDash()
getTransform()
isPointInPath()
isPointInStroke()
lineTo()
measureText()
moveTo()
putImageData()
quadraticCurveTo()
rect()
removeHitRegion()
resetTransform()
restore()
rotate()
save()
scale()
scrollPathIntoView()
setLineDash()
setTransform()
stroke()
strokeRect()
strokeText()
transform()
translate()