-
Notifications
You must be signed in to change notification settings - Fork 2
/
StaticProgressBar.qml
72 lines (64 loc) · 2.31 KB
/
StaticProgressBar.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
import QtQuick 2.0
Canvas {
width: parent.width
height: 110
anchors.bottom: footerrect.top
anchors.bottomMargin: -10
z: 1
onPaint: {
var ctx = getContext("2d")
function drawBezierSplit(ctx, x0, y0, x1, y1, x2, y2, t0, t1) {
if( 0.0 == t0 && t1 == 1.0 ) {
ctx.moveTo( x0, y0 );
ctx.quadraticCurveTo( x1, y1, x2, y2 );
return
} else if( t0 != t1 ) {
var t00 = t0 * t0,
t01 = 1.0 - t0,
t02 = t01 * t01,
t03 = 2.0 * t0 * t01;
var nx0 = t02 * x0 + t03 * x1 + t00 * x2,
ny0 = t02 * y0 + t03 * y1 + t00 * y2;
t00 = t1 * t1;
t01 = 1.0 - t1;
t02 = t01 * t01;
t03 = 2.0 * t1 * t01;
var nx2 = t02 * x0 + t03 * x1 + t00 * x2,
ny2 = t02 * y0 + t03 * y1 + t00 * y2;
var nx1 = lerp ( lerp ( x0 , x1 , t0 ) , lerp ( x1 , x2 , t0 ) , t1 ),
ny1 = lerp ( lerp ( y0 , y1 , t0 ) , lerp ( y1 , y2 , t0 ) , t1 );
ctx.moveTo( nx0, ny0 );
ctx.quadraticCurveTo( nx1, ny1, nx2, ny2 );
}
}
/**
* Linearly interpolate between two numbers v0, v1 by t
*/
function lerp(v0, v1, t) {
return ( 1.0 - t ) * v0 + t * v1;
}
ctx.lineJoin = 'round'
ctx.lineWidth = 4
// ctx.strokeStyle = "#1C70E4"
ctx.strokeStyle = "#EEEEEE"
ctx.fillStyle= "#FAFAFA"
// ctx.save();
ctx.beginPath();
ctx.moveTo(0, 100);
ctx.lineTo(40 * (staticcanvas.width / 100), 100);
drawBezierSplit(ctx, (40 * (staticcanvas.width / 100)) - 1, 100, (50 * (staticcanvas.width / 100)), 50, (60 * (staticcanvas.width / 100)), 100, 0, 1);
ctx.lineTo(staticcanvas.width, 100);
// ctx.restore();
ctx.fill()
// ctx.globalAlpha=0.8
ctx.stroke()
}
Text {
anchors.bottom: parent.bottom
anchors.bottomMargin: 5
anchors.horizontalCenter: parent.horizontalCenter
text: !filep.started ? "Ready!" : progresscanvas.value + "%"
font.bold: Font.Bold
font.pixelSize: 15
}
}