本页内容

PlanarTransform QML Type

提供用于 4×4 矩阵进行二维变换的辅助函数。更多内容...

Import Statement: import QtQuick
Since: Qt 6.8

方法

  • matrix4x4 fromAffineMatrix(real scaleX, real shearY, real shearX, real scaleY, real translateX, real translateY)
  • matrix4x4 fromRotate(real angle, real originX, real originY)
  • matrix4x4 fromScale(real scaleX, real scaleY, real originX, real originY)
  • matrix4x4 fromShear(float shearX, float shearY, float originX, float originY)
  • matrix4x4 fromTranslate(real translateX, real translateY)
  • matrix4x4 identity()

详细说明

PlanarTransform 是一个包含实用函数的全局对象。

它不可实例化;要使用它,请直接调用全局对象PlanarTransform 的成员。例如:

Item {
    transform: Matrix4x4 { matrix: PlanarTransform.fromAffineMatrix(1, 0, 0.36, 1, -36, 0) }
}

方法文档

matrix4x4 fromAffineMatrix(real scaleX, real shearY, real shearX, real scaleY, real translateX, real translateY)

返回一个 4×4 矩阵,用于执行具有指定值的仿射(非投影)二维变换。

该方法及其参数顺序对应于 SVG 的 `matrix() ` 函数和六参数的 `QTransform ` 构造函数。结果为以下 4×4 矩阵:

scaleXshearX0translateX
shearYscaleY0translateY
0010
0001

matrix4x4 fromRotate(real angle, real originX, real originY)

返回一个 4×4 矩阵,用于执行以下 2D 变换:以点 (originX,originY) 为中心,旋转angle 度。

originX 和originY 为可选参数,默认值为 (0, 0)。

matrix4x4 fromScale(real scaleX, real scaleY, real originX, real originY)

返回一个 4x4 矩阵,用于执行 2D 变换,该变换在水平方向按scaleX 缩放,在垂直方向按scaleY 缩放,并以点 (originX,originY) 为中心。

originX 和originY 为可选参数,默认值为 (0, 0)。

matrix4x4 fromShear(float shearX, float shearY, float originX, float originY)

返回一个 4×4 矩阵,用于执行二维变换,该变换在水平方向上进行剪切(剪切量为shearX ),在垂直方向上进行剪切(剪切量为shearY ),中心点为 (originX,originY)。

originX 和originY 为可选参数,默认值为 (0, 0)。

matrix4x4 fromTranslate(real translateX, real translateY)

返回一个 4×4 矩阵,表示一个 2D 变换,该变换在水平方向上平移translateX ,在垂直方向上平移translateY 。

matrix4x4 identity()

返回一个表示单位变换的4×4矩阵。

这等同于Qt::matrix4x4()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.