benchmark with rectangle

This commit is contained in:
Hendrik Schutter 2020-10-12 12:13:15 +02:00
parent 620d7df720
commit 41900f7d93
3 changed files with 55 additions and 50 deletions

View File

@ -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 }
}

View File

@ -3,66 +3,50 @@ import QtQuick.Window 2.12
import QtQuick.Controls 2.3
import be.mindgoo.tools 0.1
Window {
id: rootwin
width: 640
height: 480
width: 1920
height: 1080
visible: true
title: qsTr("Hello World")
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)
}
property var elements: 0
FrequencyMonitor {
id: monitor
refreshPeriod: 500
}
Text {
text: monitor.fps
}
function doSomething(){
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
}
}
/*##^##

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>Rect.qml</file>
</qresource>
</RCC>