benchmark with rectangle
This commit is contained in:
parent
620d7df720
commit
41900f7d93
|
@ -0,0 +1,20 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
|
||||||
|
function randomInteger(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
width:100
|
||||||
|
height:100
|
||||||
|
color:Qt.rgba(Math.random(),Math.random(),Math.random(),1);
|
||||||
|
NumberAnimation on x {loops: Animation.Infinite; from: randomInteger(0, 1920); to: randomInteger(0, 1920); duration: 500 }
|
||||||
|
NumberAnimation on y {loops: Animation.Infinite; from: randomInteger(0, 900); to: randomInteger(0, 900); duration: 500 }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -3,66 +3,50 @@ import QtQuick.Window 2.12
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import be.mindgoo.tools 0.1
|
import be.mindgoo.tools 0.1
|
||||||
|
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
id: rootwin
|
id: rootwin
|
||||||
width: 640
|
width: 1920
|
||||||
height: 480
|
height: 1080
|
||||||
visible: true
|
visible: true
|
||||||
title: qsTr("Hello World")
|
|
||||||
|
|
||||||
|
property var elements: 0
|
||||||
Rectangle {
|
|
||||||
x: 20
|
|
||||||
y: 20
|
|
||||||
width: 100; height: 100
|
|
||||||
color: "forestgreen"
|
|
||||||
|
|
||||||
//NumberAnimation on x { id: ani; loops: Animation.Infinite; to: 250; duration: 1000 }
|
|
||||||
|
|
||||||
NumberAnimation on x { id: ani; loops: Animation.Infinite; from: 0; to: 100; duration: 500 }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
x: 20
|
|
||||||
y: 148
|
|
||||||
width: 100; height: 100
|
|
||||||
color: "blue"
|
|
||||||
|
|
||||||
//NumberAnimation on x { id: ani; loops: Animation.Infinite; to: 250; duration: 1000 }
|
|
||||||
|
|
||||||
NumberAnimation on x { id: ani2; loops: Animation.Infinite; from: 0; to: 1000; duration: 5000 }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function onChecked(checked) {
|
|
||||||
|
|
||||||
if (checked) {
|
|
||||||
ani.resume()
|
|
||||||
} else {
|
|
||||||
ani.pause()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckBox {
|
|
||||||
id: checkBox
|
|
||||||
x: 41
|
|
||||||
y: 279
|
|
||||||
state: active
|
|
||||||
text: qsTr("Check Box")
|
|
||||||
onClicked: rootwin.onChecked(checked)
|
|
||||||
}
|
|
||||||
|
|
||||||
FrequencyMonitor {
|
FrequencyMonitor {
|
||||||
id: monitor
|
id: monitor
|
||||||
refreshPeriod: 500
|
refreshPeriod: 500
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
function doSomething(){
|
||||||
text: monitor.fps
|
rootwin.elements++
|
||||||
}
|
var component = Qt.createComponent("Rect.qml");
|
||||||
|
var rect = component.createObject(rootwin,{"x":0,"y":0});
|
||||||
|
if(rect !== null ) {
|
||||||
|
rect.name = "Test";
|
||||||
|
rect.x = Math.floor(Math.random() * 100 );
|
||||||
|
rect.y = Math.floor(Math.random() * 100 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button{
|
||||||
|
id: doBtn
|
||||||
|
text: "do"
|
||||||
|
x: 20
|
||||||
|
y: 1000
|
||||||
|
onClicked: rootwin.doSomething()
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: fpsCounter
|
||||||
|
x: 200
|
||||||
|
y: 1000
|
||||||
|
text: "FPS: " + monitor.fps
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: elementsCounter
|
||||||
|
x: 300
|
||||||
|
y: 1000
|
||||||
|
text: "Elements: " + rootwin.elements
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*##^##
|
/*##^##
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>main.qml</file>
|
<file>main.qml</file>
|
||||||
|
<file>Rect.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in New Issue