Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Getting the Axis aligned Bound Box of an item is has transformations (rotation, scaling,...)

$
0
0
I got the solution, I just miss Rect are Axis Aligned so we can simply apply the item transformation to get the AABB : AABB.qml import QtQuick 2.1   Rectangle {     id: aabb     color: "#AAAAFF"       property real   childrenRotation: {         if (children.length)             return children[0].rotation         else             return false     }       property real   childrenScaling: {         if (children.length)             return children[0].scale         else             return false     }       onChildrenRotationChanged: update()     onChildrenScalingChanged: update()       function    update()     {         var rect = mapFromItem(children[0], children[0].x, children[0].y, children[0].width, children[0].height)         width = rect.width         height = rect.height     } } main.qml (Center the child in the AABB component) : import QtQuick 2.0   Rectangle {     width: 360     height: 360     AABB {         anchors.centerIn: parent           Text {             text: qsTr("Hello World")             anchors.centerIn: parent             transformOrigin: Item.Center               SequentialAnimation on rotation {                 // Animations on properties start running by default                 running: true                 loops: Animation.Infinite // The animation is set to loop indefinitely                 NumberAnimation { from: 0; to: 359; duration: 50000 }             }             SequentialAnimation on scale {                 // Animations on properties start running by default                 running: true                 loops: Animation.Infinite // The animation is set to loop indefinitely                 NumberAnimation { from: 0.25; to: 4; duration: 50000 }             }         }     }     MouseArea {         anchors.fill: parent         onClicked: {             Qt.quit();         }     } }

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images