2 import Sailfish.Silica 1.0
7 property QtObject timerClock
9 // Size of the clock border decoration as a fraction of the radius
10 property real _faceRadiusBase: 84
11 property real _faceHourLength: 14.736 / _faceRadiusBase
17 fillMode: Image.PreserveAspectFit
18 source: "image://theme/graphic-clock-face-3"
22 id: timerVisualization
24 anchors.fill: clockFace
26 visible: stopwatch.update
29 _updateTimerVisualization()
32 property int _seconds: stopwatch.seconds
33 on_SecondsChanged: _updateTimerVisualization()
35 property real outerRadius: 1
36 property real innerRadius: 1 - _faceHourLength
37 property real endAngle
38 property real loopRadius: outerRadius / 10
41 property color highlightColor: Theme.rgba(Theme.highlightColor, 0.75)
43 function _updateTimerVisualization() {
48 count = Math.floor(_seconds / 60)
51 endAngle = 2 * Math.PI * count / 60
52 innerRadius = outerRadius - loopRadius * (parseInt(count / 60) + 1)
56 uniform highp mat4 qt_Matrix;
57 attribute highp vec4 qt_Vertex;
58 attribute highp vec2 qt_MultiTexCoord0;
59 varying highp vec2 coord;
61 coord = qt_MultiTexCoord0;
62 gl_Position = qt_Matrix * qt_Vertex;
65 varying highp vec2 coord;
66 uniform lowp float qt_Opacity;
67 uniform lowp float outerRadius;
68 uniform lowp float innerRadius;
69 uniform lowp float endAngle;
70 uniform lowp float loopRadius;
71 uniform lowp vec4 highlightColor;
72 uniform lowp float count;
74 lowp float PI = 3.14159265358979323846264;
77 highp vec2 vector = 2.0*(coord - vec2(0.5, 0.5));
78 lowp float radius = length(vector);
79 lowp float angle = atan(vector.y, vector.x) + PI/2.0;
80 angle += angle < 0.0 ? 2.0*PI : 0.0;
82 lowp float minRadius = outerRadius - ((count / 60.0) + 1.0) * loopRadius + (loopRadius * angle / (2.0 * PI));
83 lowp float maxRadius = outerRadius - ((mod(count, 60.0) / 60.0) + 1.0) * loopRadius + (loopRadius * angle / (2.0 * PI));
85 if (angle < 2.0 * PI * mod(count, 60.0) / 60.0) {
86 maxRadius += loopRadius;
89 if (radius >= minRadius && radius < maxRadius) {
90 if (mod(radius - minRadius, loopRadius) > 0.2 * loopRadius) {
91 gl_FragColor = highlightColor;
95 gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);