1111//const svg = SVG.load('https://gist.githubusercontent.com/vschmidt94/7ae2c23fede9f53bf63da4d7ace5fc14/raw/e41ed2bd565a54e90b33209dc820086e93121ab5/retro_gruvbox_linux_wallpaper.svg');
1212
1313/*
14- * Requires fonts
14+ * FONTS
1515 * JetBrains Mono: https://www.jetbrains.com/lp/mono/
1616 * Anurati Regular: https://troisieme-type.com/anurati-pro
17+ * Poppins: https://fonts.google.com/specimen/Poppins
1718 */
1819
20+ function lerp ( from , to , time )
21+ {
22+ from = from . match ( / [ ^ # ] { 2 } / g) . map ( c => parseInt ( c , 16 ) ) ;
23+ to = to . match ( / [ ^ # ] { 2 } / g) . map ( c => parseInt ( c , 16 ) ) ;
24+ tween = [ ] ;
25+
26+ for ( let c = 0 ; c < 3 ; c ++ )
27+ tween [ c ] = Math . round ( from [ c ] + ( to [ c ] - from [ c ] ) * time ) ;
28+
29+ return `#${ tween . map ( c => c . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( '' ) } ` ;
30+ }
31+
1932const viewBox = `0 0 ${ Platform . width } ${ Platform . height } ` . match ( / [ \d \. ] + / gi) . map ( parseFloat ) ;
2033const MARGIN = Platform . height / 200.0 * 3 ;
2134const LINESPACE = Platform . height / 45.0 ;
2235const svg = SVG . blank ( ) ;
23- const used = '31G ' ;
24- const available = '926G ' ;
36+ const used = '32G ' ;
37+ const available = '925G ' ;
2538const percent = 4 / 100.0 ;
2639const battery = 79 ;
2740const fonts = {
28- standard : `fill: #eadcb2; font-size: ${ Platform . height / 70.0 } pt; font-family: 'JetBrains Mono Medium ';` ,
41+ standard : `fill: #eadcb2; font-size: ${ Platform . height / 70.0 } pt; font-family: 'Poppins ';` ,
2942} ;
3043svg . setAttribute ( 'viewBox' , viewBox . join ( ' ' ) ) ;
31- const defs = SVG . element ( 'defs' ) ;
32- const gradient = SVG . element ( 'linearGradient' , {
33- id : 'batteryGradient' ,
34- x1 : '0%' ,
35- x2 : '100%' ,
36- y1 : '0%' ,
37- y2 : '0%' ,
38- } ) ;
39- gradient . appendChild ( SVG . element ( 'stop' , {
40- offset : '0%' ,
41- 'stop-color' : '#cc241d' ,
42- } ) ) ;
43- gradient . appendChild ( SVG . element ( 'stop' , {
44- offset : '50%' ,
45- 'stop-color' : '#d89920' ,
46- } ) ) ;
47- gradient . appendChild ( SVG . element ( 'stop' , {
48- offset : '100%' ,
49- 'stop-color' : '#689e6a' ,
50- } ) ) ;
51- defs . appendChild ( gradient ) ;
52- const blur = SVG . element ( 'filter' , {
53- id : 'blur' ,
54- } ) ;
55- blur . appendChild ( SVG . element ( 'feGaussianBlur' , {
56- in : 'SourceGraphic' ,
57- stdDeviation : 1 ,
58- } ) ) ;
59- defs . appendChild ( blur ) ;
60- svg . appendChild ( defs ) ;
6144svg . appendChild ( SVG . element ( 'rect' , {
6245 x : 0 ,
6346 y : 0 ,
@@ -109,22 +92,28 @@ svg.appendChild(image);
10992const horizontal = SVG . element ( 'g' , {
11093 transform : `translate(${ Platform . width * 0.15 } ${ Platform . height * 0.75 } )` ,
11194} ) ;
112- horizontal . appendChild ( SVG . element ( 'rect' , {
113- x : - 0.8 ,
114- y : - 0.17 ,
115- width : 1.6 ,
116- height : 0.34 ,
117- fill : 'white' ,
118- opacity : 0.2 ,
119- transform : 'scale(50 50)' ,
95+ horizontal . appendChild ( SVG . element ( 'line' , {
96+ x1 : - 40 ,
97+ y1 : 0 ,
98+ x2 : 40 ,
99+ y2 : 0 ,
100+ fill : 'none' ,
101+ stroke : 'white' ,
102+ 'stroke-opacity' : 0.2 ,
103+ 'stroke-linecap' : 'butt' ,
104+ 'stroke-width' : 17 ,
105+ 'stroke-dasharray' : `80 80` ,
120106} ) ) ;
121- horizontal . appendChild ( SVG . element ( 'rect' , {
122- x : - 0.8 ,
123- y : - 0.17 ,
124- width : 0.016 * battery ,
125- height : 0.34 ,
126- fill : 'url(#batteryGradient)' ,
127- transform : 'scale(50 50)' ,
107+ horizontal . appendChild ( SVG . element ( 'line' , {
108+ x1 : - 40 ,
109+ y1 : 0 ,
110+ x2 : 40 ,
111+ y2 : 0 ,
112+ fill : 'none' ,
113+ stroke : battery / 100.0 < 0.5 ? lerp ( '#cc241d' , '#d89920' , battery / 50.0 ) : lerp ( '#d89920' , '#689e6a' , battery / 50.0 - 1 ) ,
114+ 'stroke-linecap' : 'butt' ,
115+ 'stroke-width' : 17 ,
116+ 'stroke-dasharray' : `${ 0.8 * battery } 80` ,
128117} ) ) ;
129118horizontal . appendChild ( SVG . element ( 'text' , {
130119 x : 0 ,
@@ -139,25 +128,25 @@ const gauge = SVG.element('g', {
139128gauge . appendChild ( SVG . element ( 'circle' , {
140129 cx : 0 ,
141130 cy : 0 ,
142- r : 0.85 ,
131+ r : 42.5 ,
143132 fill : 'none' ,
144133 stroke : 'white' ,
145- 'stroke-width' : 0.3 ,
134+ 'stroke-width' : 15 ,
146135 'stroke-linecap' : 'butt' ,
147- 'stroke-dasharray' : '4.0 5.34 ' ,
136+ 'stroke-dasharray' : '200 267 ' ,
148137 'stroke-opacity' : 0.2 ,
149- transform : 'scale(50,50) rotate(135, 0, 0)' ,
138+ transform : 'rotate(135, 0, 0)' ,
150139} ) ) ;
151140gauge . appendChild ( SVG . element ( 'circle' , {
152141 cx : 0 ,
153142 cy : 0 ,
154- r : 0.85 ,
143+ r : 42.5 ,
155144 fill : 'none' ,
156- stroke : 'url(#batteryGradient)' ,
157- 'stroke-width' : 0.3 ,
145+ stroke : percent < 0.5 ? lerp ( '#689e6a' , '#d89920' , 2 * percent ) : lerp ( '#d89920' , '#cc241d' , 2 * percent - 1 ) ,
146+ 'stroke-width' : 15 ,
158147 'stroke-linecap' : 'butt' ,
159- 'stroke-dasharray' : `${ percent * 4.0 } 5.34 ` ,
160- transform : 'scale(50,50) rotate(135, 0, 0)' ,
148+ 'stroke-dasharray' : `${ percent * 200 } 267 ` ,
149+ transform : 'rotate(135, 0, 0)' ,
161150} ) ) ;
162151const text = SVG . element ( 'text' , {
163152 x : 0 ,
@@ -258,11 +247,11 @@ svg.appendChild(SVG.element('text', {
258247 x : '50%' ,
259248 y : Platform . height * 0.15 + Platform . height * 0.05 ,
260249 'text-anchor' : 'middle' ,
261- style : `fill: #eadcb2; font-size: ${ Platform . height / 40.0 } pt; font-family: 'JetBrains Mono';` ,
250+ style : `fill: #eadcb2; font-size: ${ Platform . height / 40.0 } pt; font-family: 'JetBrains Mono Medium ';` ,
262251} , Platform . chrono . ofPattern ( 'yyyy LLL d' ) . toUpperCase ( ) ) ) ;
263252svg . appendChild ( SVG . element ( 'text' , {
264253 x : '50%' ,
265254 y : Platform . height * 0.15 + Platform . height * 0.09 ,
266255 'text-anchor' : 'middle' ,
267- style : `fill: #eadcb2; font-size: ${ Platform . height / 50.0 } pt; font-family: 'JetBrains Mono';` ,
268- } , Platform . chrono . ofPattern ( '— HH:mm — ' ) . toUpperCase ( ) ) ) ;
256+ style : `fill: #eadcb2; font-size: ${ Platform . height / 50.0 } pt; font-family: 'JetBrains Mono Medium ';` ,
257+ } , Platform . chrono . ofPattern ( '· HH:mm · ' ) . toUpperCase ( ) ) ) ;
0 commit comments