| 1 |
import QtQuick 2.0 |
| 2 |
import io.thp.pyotherside 1.5 |
| 3 |
|
| 4 |
Item { |
| 5 |
width: 320 |
| 6 |
height: 480 |
| 7 |
|
| 8 |
PyGLArea { |
| 9 |
id: glArea |
| 10 |
anchors.fill: parent |
| 11 |
property var t: 0 |
| 12 |
|
| 13 |
SequentialAnimation on t { |
| 14 |
NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } |
| 15 |
NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } |
| 16 |
loops: Animation.Infinite |
| 17 |
running: true |
| 18 |
} |
| 19 |
|
| 20 |
onTChanged: { |
| 21 |
if (renderer) { |
| 22 |
py.call(py.getattr(renderer, 'set_t'), [t], update); |
| 23 |
} |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
Rectangle { |
| 28 |
color: Qt.rgba(1, 1, 1, 0.7) |
| 29 |
radius: 10 |
| 30 |
border.width: 1 |
| 31 |
border.color: "white" |
| 32 |
anchors.fill: label |
| 33 |
anchors.margins: -10 |
| 34 |
} |
| 35 |
|
| 36 |
Text { |
| 37 |
id: label |
| 38 |
color: "black" |
| 39 |
wrapMode: Text.WordWrap |
| 40 |
text: "The background here is a squircle rendered with raw OpenGL using a PyGLArea. This text label and its border is rendered using QML" |
| 41 |
anchors.right: parent.right |
| 42 |
anchors.left: parent.left |
| 43 |
anchors.bottom: parent.bottom |
| 44 |
anchors.margins: 20 |
| 45 |
} |
| 46 |
|
| 47 |
Python { |
| 48 |
id: py |
| 49 |
|
| 50 |
Component.onCompleted: { |
| 51 |
addImportPath(Qt.resolvedUrl('.')); |
| 52 |
importModule('renderer', function () { |
| 53 |
call('renderer.Renderer', [], function (renderer) { |
| 54 |
glArea.renderer = renderer; |
| 55 |
}); |
| 56 |
}); |
| 57 |
} |
| 58 |
|
| 59 |
onError: console.log(traceback); |
| 60 |
} |
| 61 |
} |