title: CanvasContext.scale header: develop nav: api
sidebar: canvas_CanvasContext-scale
解释:在调用scale方法后,之后创建的路径其横纵坐标会被缩放。多次调用scale,倍数会相乘。
方法参数
| 参数名 | 属性 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
scaleWidth |
Number | 是 | 横坐标缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%) 。 | |
scaleHeigh |
Number | 是 | 纵坐标轴缩放的倍数 (1 = 100%,0.5 = 50%,2 = 200%)。 |
示例
扫码体验
请使用百度APP扫码
图片示例

代码示例
:::codeTab
const canvasContext = swan.createCanvasContext('myCanvas');canvasContext.strokeRect(10, 10, 25, 15);canvasContext.scale(2, 2);canvasContext.strokeRect(10, 10, 25, 15);canvasContext.scale(2, 2);canvasContext.strokeRect(10, 10, 25, 15);canvasContext.draw();
:::
