提交 849ee183 编写于 作者: T tianyu

uodate marrix4

Signed-off-by: Ntianyu <tianyu55@h-partners.com>
上级 075a5c7e
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 导入模块 ## 导入模块
``` ```ts
import matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
``` ```
...@@ -55,10 +55,10 @@ Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵, ...@@ -55,10 +55,10 @@ Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵,
| m33 | number | 是 | 齐次坐标下生效,产生透视投影效果。 | | m33 | number | 是 | 齐次坐标下生效,产生透视投影效果。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
// 创建一个四阶矩阵 // 创建一个四阶矩阵
let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, let matrix = matrix4.init([1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0]) 0.0, 0.0, 0.0, 1.0])
...@@ -79,9 +79,9 @@ Matrix的初始化函数,可以返回一个单位矩阵对象。 ...@@ -79,9 +79,9 @@ Matrix的初始化函数,可以返回一个单位矩阵对象。
| Object | 单位矩阵对象。 | | Object | 单位矩阵对象。 |
- 示例 - 示例
``` ```ts
// matrix1 和 matrix2 效果一致 // matrix1 和 matrix2 效果一致
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0,
...@@ -104,12 +104,12 @@ Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。 ...@@ -104,12 +104,12 @@ Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。
| Object | 当前矩阵的拷贝对象。 | | Object | 当前矩阵的拷贝对象。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@Entry @Entry
@Component @Component
struct Test { struct Test {
private matrix1 = Matrix4.identity().translate({x:100}) private matrix1 = matrix4.identity().translate({x:100})
private matrix2 = this.matrix1.copy().scale({x:2}) private matrix2 = this.matrix1.copy().scale({x:2})
build() { build() {
Column() { Column() {
...@@ -152,13 +152,13 @@ Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个 ...@@ -152,13 +152,13 @@ Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个
| Object | 矩阵叠加后的对象。 | | Object | 矩阵叠加后的对象。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@Entry @Entry
@Component @Component
struct Test { struct Test {
private matrix1 = Matrix4.identity().translate({x:200}).copy() private matrix1 = matrix4.identity().translate({x:200}).copy()
private matrix2 = Matrix4.identity().scale({x:2}).copy() private matrix2 = matrix4.identity().scale({x:2}).copy()
build() { build() {
Column() { Column() {
// 先平移x轴100px,再缩放两倍x轴 // 先平移x轴100px,再缩放两倍x轴
...@@ -188,8 +188,8 @@ Matrix的逆函数,可以返回一个当前矩阵对象的逆矩阵,即效 ...@@ -188,8 +188,8 @@ Matrix的逆函数,可以返回一个当前矩阵对象的逆矩阵,即效
| Object | 当前矩阵的逆矩阵对象。 | | Object | 当前矩阵的逆矩阵对象。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
// matrix1(宽放大2倍) 和 matrix2(宽缩小2倍) 效果相反 // matrix1(宽放大2倍) 和 matrix2(宽缩小2倍) 效果相反
let matrix1 = Matrix4.identity().scale({x:2}) let matrix1 = Matrix4.identity().scale({x:2})
let matrix2 = matrix1.copy().invert() let matrix2 = matrix1.copy().invert()
...@@ -218,12 +218,12 @@ Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 ...@@ -218,12 +218,12 @@ Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。
| Object | 增加好平移效果后的矩阵对象。 | | Object | 增加好平移效果后的矩阵对象。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@Entry @Entry
@Component @Component
struct Test { struct Test {
private matrix1 = Matrix4.identity().translate({x:100, y:200, z:30}) private matrix1 = matrix4.identity().translate({x:100, y:200, z:30})
build() { build() {
Column() { Column() {
Image($r("app.media.bg1")).transform(this.matrix1) Image($r("app.media.bg1")).transform(this.matrix1)
...@@ -261,12 +261,12 @@ Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 ...@@ -261,12 +261,12 @@ Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。
| Object | 增加好缩放效果后的矩阵对象。 | | Object | 增加好缩放效果后的矩阵对象。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@Entry @Entry
@Component @Component
struct Test { struct Test {
private matrix1 = Matrix4.identity().scale({x:2, y:3, z:4, centerX:50, centerY:50}) private matrix1 = matrix4.identity().scale({x:2, y:3, z:4, centerX:50, centerY:50})
build() { build() {
Column() { Column() {
Image($r("app.media.bg1")).transform(this.matrix1) Image($r("app.media.bg1")).transform(this.matrix1)
...@@ -305,12 +305,12 @@ Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 ...@@ -305,12 +305,12 @@ Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。
| Object | 增加好旋转效果后的矩阵对象。 | | Object | 增加好旋转效果后的矩阵对象。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@Entry @Entry
@Component @Component
struct Test { struct Test {
private matrix1 = Matrix4.identity().rotate({x:1, y:1, z:2, angle:30}) private matrix1 = matrix4.identity().rotate({x:1, y:1, z:2, angle:30})
build() { build() {
Column() { Column() {
Image($r("app.media.bg1")).transform(this.matrix1) Image($r("app.media.bg1")).transform(this.matrix1)
...@@ -344,14 +344,14 @@ Matrix的坐标点转换函数,可以将当前的变换效果作用到一个 ...@@ -344,14 +344,14 @@ Matrix的坐标点转换函数,可以将当前的变换效果作用到一个
| Point | 返回矩阵变换后的Point对象。 | | Point | 返回矩阵变换后的Point对象。 |
- 示例 - 示例
``` ```ts
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
import prompt from '@system.prompt' import prompt from '@system.prompt'
@Entry @Entry
@Component @Component
struct Test { struct Test {
private matrix1 = Matrix4.identity().transformPoint([100, 10]) private matrix1 = matrix4.identity().transformPoint([100, 10])
build() { build() {
Column() { Column() {
Button("get Point") Button("get Point")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册