这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
CanvasRenderingContext2D
.currentTransform
property of the Canvas 2D API returns or sets a
DOMMatrix
(current specification) or
SVGMatrix
(old specification) object for the current transformation matrix.
ctx.currentTransform [= value];
此范例使用
currentTransform
property to set a transformation matrix. A rectangle is then drawn using that transformation.
<canvas id="canvas"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
let matrix = ctx.currentTransform;
matrix.a = 1;
matrix.b = 1;
matrix.c = 0;
matrix.d = 1;
matrix.e = 0;
matrix.f = 0;
ctx.currentTransform = matrix;
ctx.fillRect(0, 0, 100, 100);
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
currentTransform
|
Chrome
Yes
Disabled
|
Edge ≤18 |
Firefox
No
|
IE No | Opera No |
Safari
No
|
WebView Android No | Chrome Android No | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android No |
返回
DOMMatrix
|
Chrome
No
|
Edge
No
|
Firefox No | IE No | Opera No |
Safari
No
|
WebView Android
No
|
Chrome Android
No
|
Firefox Android No | Opera Android No | Safari iOS No |
Samsung Internet Android
No
|
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
用户必须明确启用此特征。
CanvasPattern
SVGMatrix
DOMMatrix
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()