Changeset View
Changeset View
Standalone View
Standalone View
src/monitor/view/OverlayCenterDiagonal.qml
- This file was added.
1 | import QtQuick.Controls 1.3 | ||||
---|---|---|---|---|---|
2 | import QtQuick.Controls.Styles 1.3 | ||||
3 | import QtQuick 2.0 | ||||
4 | | ||||
5 | Item { | ||||
6 | id: overlay | ||||
7 | property double diagonalLenght: Math.sqrt(Math.pow(parent.height, 2) + Math.pow(parent.width, 2)) | ||||
8 | | ||||
9 | function degreesRotation(width, height) { | ||||
10 | var a = height/width; | ||||
11 | var b = Math.sqrt(1 + Math.pow(a, 2)); | ||||
12 | var angle = Math.acos(Math.pow(a,2) / (a * b)); | ||||
13 | return angle * (180 / Math.PI); | ||||
14 | } | ||||
15 | | ||||
16 | Rectangle { | ||||
17 | color: root.overlayColor | ||||
18 | width: overlay.diagonalLenght | ||||
19 | height: 1 | ||||
20 | rotation: degreesRotation(parent.height, parent.width) | ||||
21 | anchors.centerIn: parent | ||||
22 | antialiasing: true | ||||
23 | } | ||||
24 | | ||||
25 | Rectangle { | ||||
26 | color: root.overlayColor | ||||
27 | height: overlay.diagonalLenght | ||||
28 | width: 1 | ||||
29 | rotation: degreesRotation(parent.width, parent.height) | ||||
30 | anchors.centerIn: parent | ||||
31 | antialiasing: true | ||||
32 | } | ||||
33 | } |