From 6ae1dac996358ab1c7a08a052b07c00f46e698ec Mon Sep 17 00:00:00 2001 From: limeng Date: Tue, 20 Jun 2023 21:32:41 +0800 Subject: [PATCH] =?UTF-8?q?matix2d=E7=9A=84multiply=20rotate=E4=B8=A4?= =?UTF-8?q?=E6=8E=A5=E5=BA=9F=E5=BC=83=E6=B5=81=E7=A8=8B=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83,=E4=B8=94=E6=9C=AA=E8=AF=B4=E6=98=8E=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=E6=8E=A5=E5=8F=A3=E6=8E=A8=E8=8D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limeng --- .../arkui-ts/ts-components-canvas-matrix2d.md | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md index a6169aedd5..0a2d7a3044 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md @@ -413,6 +413,70 @@ struct Matrix2DMultiply { } ``` +### rotate(deprecated) + +rotate(rx?: number, ry?: number): Matrix2D + +对当前矩阵进行旋转运算。 + +从API version 9开始,该接口支持在ArkTS卡片中使用。该接口为空接口。 + +该接口从API version 10开始废弃,推荐使用[rotate](#rotate10)。 + +**参数:** + +| 参数 | 类型 | 必填 | 默认值 | 描述 | +| ---- | ------ | ---- | ------ | -------------------------------- | +| rx | number | 否 | 0 | 旋转点的水平方向坐标,单位为vp。 | +| ry | number | 否 | 0 | 旋转点的垂直方向坐标,单位为vp。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | -------------------- | +| [Matrix2D](#matrix2d) | 旋转后结果矩阵对象。 | + +**示例:** + +```ts +// xxx.ets +@Entry +@Component +struct Matrix2DRotate { + @State message: string = 'Matrix2D Rotate' + + printMatrix(title, matrix) { + console.log(title) + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + + ", translateX = " + matrix.translateX + ", translateY = " + matrix.translateY + "]") + } + build() { + Row() { + Column() { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Button("matrix rotate") + .onClick(() => { + var matrix : Matrix2D = new Matrix2D() + matrix.scaleX = 1 + matrix.scaleY = 1 + matrix.rotateX = 0 + matrix.rotateY = 0 + matrix.translateX = 0 + matrix.translateY = 0 + matrix.rotate(10, 10) + this.printMatrix(this.message, matrix) + }) + } + .width('100%') + } + .height('100%') + } +} +``` + ### rotate10+ rotate(degree: number, rx?: number, ry?: number): Matrix2D @@ -598,4 +662,4 @@ struct Matrix2DScale { .height('100%') } } -``` +``` \ No newline at end of file -- GitLab