forked from AsteroidOS/unofficial-watchfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
humongous.qml
91 lines (83 loc) · 3.17 KB
/
humongous.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
/*
* 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/>.
*/
/*
* Based on a qml fragmentshader example from http://doc.qt.io and
* a well known pebble watchface design. Utillizing the great Item Font.
*/
import QtQuick 2.1
Item {
Rectangle {
id: layer2mask
width: parent.width; height: parent.height
color: Qt.rgba(0, 0, 0, 1)
visible: true
opacity: 0.0
layer.enabled: true
layer.smooth: true
}
Rectangle {
id: _mask
anchors.fill: layer2mask
color: Qt.rgba(0, 1, 0, 0)
visible: true
Text {
renderType: Text.NativeRendering
font.pixelSize: parent.height*0.585
font.letterSpacing: -parent.width*0.06
font.family: "Item"
font.styleName:"Black"
color: Qt.rgba(1, 1, 1, 1)
x: parent.width / 2 - width / 2.075
y: parent.height / 2 - (height * 0.885)
text: if (use12H.value) {
wallClock.time.toLocaleString(Qt.locale(), "hh ap").slice(0, 2)}
else
wallClock.time.toLocaleString(Qt.locale(), "HH")
}
Text {
renderType: Text.NativeRendering
font.pixelSize: parent.height*0.585
font.letterSpacing: -parent.width*0.06
font.family: "Item"
font.styleName:"Black"
color: Qt.rgba(1, 1, 1, 1)
x: parent.width / 2 - width / 2.075
y: parent.height / 2.65
text: wallClock.time.toLocaleString(Qt.locale(), "mm")
}
layer.enabled: true
layer.samplerName: "maskSource"
layer.effect: ShaderEffect {
property variant source: layer2mask
fragmentShader: "
varying highp vec2 qt_TexCoord0;
uniform highp float qt_Opacity;
uniform lowp sampler2D source;
uniform lowp sampler2D maskSource;
void main(void) {
gl_FragColor = texture2D(source, qt_TexCoord0.st) * (1.0-texture2D(maskSource, qt_TexCoord0.st).a) * qt_Opacity;
}
"
}
}
}