@@ -7,27 +7,95 @@ class UIRenderer
77
88 static drawGauge ( ctx , x , y , w , h , filled , total , colour )
99 {
10- let empy = "100 100 100" ;
11- let outline = "120 40 0" ;
12- let step = Math . floor ( h / total ) ;
13- let spacing = 1 ;
10+
11+ let empy = "100 100 100" ;
12+ let empylight = "200 200 200" ;
13+ let outline = "120 40 0" ;
14+ let step = Math . floor ( h / total ) ;
15+ let shift = h % step ;
16+ let spacing = 2 ;
17+ if ( step >= 8 )
18+ {
1419 for ( let i = 0 ; i < total ; i ++ )
1520 {
1621 ctx . beginPath ( ) ;
17- ctx . roundRect ( x + 0.5 , y + 0.5 + step * i , w - 1 , step - 1 - spacing , 2 ) ;
18- ctx . lineWidth = 1 ;
22+ ctx . lineWidth = 2 ;
1923 ctx . strokeStyle = this . rgb ( outline ) ;
2024 if ( i < ( total - filled ) )
21- {
25+ {
26+ ctx . roundRect ( x + 0 , y + 0 + shift + step * i , w - 1 , step - 1 - spacing , 3 ) ;
27+ ctx . fillStyle = this . rgb ( empylight ) ;
28+ ctx . fill ( ) ;
29+ ctx . beginPath ( ) ;
30+ ctx . roundRect ( x + 0 + 1 , y + 0 + 1 + shift + step * i , w - 1 - 1 , step - 1 - spacing - 1 , 3 ) ;
2231 ctx . fillStyle = this . rgb ( empy ) ;
32+ ctx . fill ( ) ;
2333 }
2434 else
25- {
35+ {
36+ ctx . roundRect ( x + 0 , y + 0 + shift + step * i , w - 1 , step - 1 - spacing , 3 ) ;
2637 ctx . fillStyle = this . rgb ( colour ) ;
38+ ctx . fill ( ) ;
2739 }
28- ctx . fill ( ) ;
40+ ctx . beginPath ( ) ;
41+ ctx . roundRect ( x + 0 , y + 0 + shift + step * i , w - 1 , step - 1 - spacing , 3 ) ;
2942 ctx . stroke ( ) ;
3043 }
44+ }
45+ else
46+ {
47+ const fillPercent = filled / total ;
48+ const hempty = ( 1 - fillPercent ) * ( h - 1 ) ;
49+ const hfull = fillPercent * ( h - 1 ) ;
50+ ctx . fillStyle = this . rgb ( colour ) ;
51+ ctx . beginPath ( ) ;
52+ ctx . roundRect ( x + 1 , y + 1 , w - 1 , h - 2 , 2 ) ;
53+ ctx . fill ( ) ;
54+ ctx . fillStyle = this . rgb ( empy ) ;
55+ ctx . beginPath ( ) ;
56+ ctx . roundRect ( x + 1 , y + 1 , w - 1 , hempty , 2 ) ;
57+ ctx . fill ( ) ;
58+ ctx . beginPath ( ) ;
59+
60+
61+ ctx . lineWidth = 2 ;
62+ ctx . strokeStyle = this . rgb ( outline ) ;
63+ ctx . roundRect ( x + 0 , y + 0 , w - 1 , h - 1 , 2 ) ;
64+ ctx . stroke ( ) ;
65+
66+ if ( step > 4 )
67+ {
68+ for ( let i = 1 ; i < total ; i ++ )
69+ {
70+ ctx . beginPath ( ) ;
71+ //ctx.roundRect(x+0.5,y+0.5+step*i, w-1,step-1-spacing,2);
72+ ctx . moveTo ( x + 0 , y + 0 + step * i ) ;
73+ ctx . lineTo ( x + 0 + w - 1 , y + 0 + step * i ) ;
74+
75+ ctx . lineWidth = 2 ;
76+ ctx . strokeStyle = this . rgb ( outline ) ;
77+
78+ ctx . stroke ( ) ;
79+ }
80+
81+ }
82+ else if ( step > 1 )
83+ {
84+ for ( let i = 1 ; i < total ; i ++ )
85+ {
86+ ctx . beginPath ( ) ;
87+ //ctx.roundRect(x+0.5,y+0.5+step*i, w-1,step-1-spacing,2);
88+ ctx . moveTo ( x + 0.5 , y + 0.5 + step * i ) ;
89+ ctx . lineTo ( x + 0.5 + w - 1 , y + 0.5 + step * i ) ;
90+
91+ ctx . lineWidth = 1 ;
92+ ctx . strokeStyle = this . rgb ( outline ) ;
93+
94+ ctx . stroke ( ) ;
95+ }
96+
97+ }
98+ }
3199
32100 }
33101
@@ -41,10 +109,10 @@ class UIRenderer
41109 ctx . fillStyle = this . rgb ( main ) ;
42110 ctx . fill ( ) ;
43111 ctx . strokeStyle = this . rgb ( outline ) ;
44- ctx . lineWidth = 5 ;
112+ ctx . lineWidth = 9 ;
45113 ctx . stroke ( ) ;
46114 ctx . strokeStyle = this . rgb ( outline2 ) ;
47- ctx . lineWidth = 3 ;
115+ ctx . lineWidth = 5 ;
48116 ctx . stroke ( ) ;
49117
50118 }
@@ -62,10 +130,10 @@ class UIRenderer
62130 ctx . fillStyle = this . rgb ( bottom ) ;
63131 ctx . fill ( ) ;
64132 ctx . strokeStyle = this . rgb ( outline ) ;
65- ctx . lineWidth = 5 ;
133+ ctx . lineWidth = 9 ;
66134 ctx . stroke ( ) ;
67135 ctx . strokeStyle = this . rgb ( outline2 ) ;
68- ctx . lineWidth = 3 ;
136+ ctx . lineWidth = 5 ;
69137 ctx . stroke ( ) ;
70138 ctx . beginPath ( ) ;
71139 ctx . roundRect ( x + 2.5 , y - 2 , w - 5 , h - 3 , 5 ) ;
0 commit comments