小程序开放平台

文档中心
暂无目录

xhs.scale

更新时间:2024-11-13 19:05:32

在调用scale方法后,之后创建的路径其横纵坐标会被缩放。多次调用scale,倍数会相乘。

参数

Number rotate

属性
类型
默认值
必填
说明
最低版本
scaleWidthNumber是横坐标缩放的倍数( 1 = 100% , 0.5 = 50% , 2 = 200% )
scaleHeighNumber是纵坐标轴缩放的倍数( 1 = 100% , 0.5 = 50% , 2 = 200% )

示例代码

Page({
    onLoad() {
        const canvasContext = xhs.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();
    }
});


该文档是否对您有帮助?