-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathbold-hour-bebas-v2.qml
121 lines (113 loc) · 4.36 KB
/
bold-hour-bebas-v2.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Copyright (C) 2018 - Timo Könnecke <[email protected]>
* 2016 - Sylvia van Os <[email protected]>
* 2015 - Florent Revest <[email protected]>
* 2012 - Vasiliy Sorokin <[email protected]>
* Aleksey Mikhailichenko <[email protected]>
* Arto Jalkanen <[email protected]>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.1
Item {
Canvas {
id: minuteArc
property var centerX: parent.width/2
property var centerY: parent.height/2
anchors.fill: parent
smooth: true
renderStrategy: Canvas.Cooperative
onPaint: {
var ctx = getContext("2d")
var rot = (wallClock.time.getMinutes() -15 )*6
ctx.reset()
ctx.lineWidth = parent.width/10
var gradient = ctx.createConicalGradient (centerX, centerY, 90*0.01745329252)
gradient.addColorStop(1-(wallClock.time.getMinutes()/60), Qt.rgba(0.318, 1, 0.051, 0.7))
gradient.addColorStop(1-(wallClock.time.getMinutes()/60/2), Qt.rgba(0.318, 1, 0.051, 0.0))
ctx.beginPath()
ctx.arc(centerX, centerY, width / 2.75, -90*0.01745329252, rot*0.01745329252, false);
ctx.lineTo(centerX, centerY);
ctx.fillStyle = gradient
ctx.fill()
}
}
Text {
id: hourDisplay
property var offset: height*0.38
renderType: Text.NativeRendering
font.pixelSize: parent.height*0.94
font.family: "Bebas Neue"
font.styleName: "Bold"
color: Qt.rgba(1, 1, 1, 0.85)
style: Text.Outline; styleColor: Qt.rgba(0, 0, 0, 0.4)
horizontalAlignment: Text.AlignHCenter
x: parent.width/2-width/1.88
y: parent.height/2-offset
text: if (use12H.value) {
wallClock.time.toLocaleString(Qt.locale(), "hh ap").slice(0, 2)}
else
wallClock.time.toLocaleString(Qt.locale(), "HH")
}
Canvas {
id: minuteCircle
property var rotM: (wallClock.time.getMinutes() - 15)/60
property var centerX: parent.width/2
property var centerY: parent.height/2
property var minuteX: centerX+Math.cos(rotM * 2 * Math.PI)*width/2.75
property var minuteY: centerY+Math.sin(rotM * 2 * Math.PI)*height/2.75
anchors.fill: parent
smooth: true
renderStrategy: Canvas.Cooperative
onPaint: {
var ctx = getContext("2d")
var rot1 = (0 -15 )*6 *0.01745
var rot2 = (60 -15 )*6 *0.01745
ctx.reset()
ctx.lineWidth = 3
ctx.fillStyle = Qt.rgba(0.184, 0.184, 0.184, 0.98)
ctx.beginPath()
ctx.moveTo(minuteX, minuteY)
ctx.arc(minuteX, minuteY, width / 8.8, rot1, rot2, false);
ctx.lineTo(minuteX, minuteY);
ctx.fill();
}
}
Text {
id: minuteDisplay
property var rotM: (wallClock.time.getMinutes() - 15)/60
property var centerX: parent.width/2-width/2
property var centerY: parent.height/2-height/2
font.pixelSize: parent.height/5.6
font.family: "BebasKai"
font.styleName:'Condensed'
color: "white"
opacity: 1.00
x: centerX+Math.cos(rotM * 2 * Math.PI)*parent.width*0.364
y: centerY+Math.sin(rotM * 2 * Math.PI)*parent.width*0.364
text: wallClock.time.toLocaleString(Qt.locale(), "mm")
}
Connections {
target: wallClock
function onTimeChanged() {
minuteCircle.requestPaint()
minuteArc.requestPaint()
}
}
Component.onCompleted: {
minuteCircle.requestPaint()
minuteArc.requestPaint()
}
}