canvasContext.scale
解释:在调用scale
方法后,之后创建的路径其横纵坐标会被缩放。多次调用scale
,倍数会相乘。
参数:
参数名 | 类型 | 说明 |
---|---|---|
scaleWidth | Number | 横坐标缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%) |
scaleHeight | Number | 纵坐标轴缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%) |
示例:
- const ctx = swan.createCanvasContext('myCanvas');
ctx.strokeRect(10, 10, 25, 15);
ctx.scale(2, 2);
ctx.strokeRect(10, 10, 25, 15);
ctx.scale(2, 2);
ctx.strokeRect(10, 10, 25, 15);
ctx.draw();