@@ -26,7 +26,7 @@ window.addEventListener("load", main, false);
26
26
27
27
function drawCanvas ( canvas , ctx ) {
28
28
const { currentColorIndex, bgColors } = state ;
29
- ctx . font = "24px monospace" ;
29
+ ctx . font = "25px monospace" ;
30
30
ctx . fillStyle = `rgba(${ bgColors [ currentColorIndex ] . join ( ", " ) } , 1)` ;
31
31
ctx . fillRect ( 0 , 0 , canvas . width , canvas . height ) ;
32
32
@@ -43,7 +43,7 @@ function resizeCanvas(canvas, ctx) {
43
43
function drawLines ( canvas , ctx ) {
44
44
const { currentColorIndex, txtColors } = state ;
45
45
const margin = canvas . height / 20 ;
46
- const stroke = 2 ;
46
+ const stroke = ( canvas . height * canvas . width ) / 400000 ;
47
47
48
48
ctx . fillStyle = `rgba(${ txtColors [ currentColorIndex ] . join ( ", " ) } , 1)` ;
49
49
@@ -90,6 +90,7 @@ async function fadeCanvas(canvas, ctx) {
90
90
out = true ;
91
91
}
92
92
canvas . style . opacity = op ;
93
+ canvas . style . filter = "alpha(opacity=" + op * 100 + ")" ;
93
94
op += ( out ? - 1 : 1 ) * 0.01 ;
94
95
} , 50 ) ;
95
96
}
@@ -109,17 +110,19 @@ function main() {
109
110
drawCanvas ( canvas , ctx ) ;
110
111
resizeCanvas ( canvas , ctx ) ;
111
112
fadeCanvas ( canvas , ctx ) ;
112
- } ) ;
113
113
114
- window . addEventListener ( "resize" , ( ) => resizeCanvas ( canvas , ctx ) , false ) ;
114
+ document . body . style . backgroundColor = "white" ;
115
115
116
- canvas . addEventListener ( "click" , ( ) => {
117
- state . currentColorIndex = ( state . currentColorIndex + 1 ) % state . bgColors . length ;
118
- drawCanvas ( canvas , ctx ) ;
119
- } , false ) ;
120
- canvas . addEventListener ( "keydown" , ( e ) => {
121
- if ( e . key === "Enter" || e . key === " " ) {
122
- canvas . click ( ) ;
123
- }
124
- } , false ) ;
116
+ window . addEventListener ( "resize" , ( ) => resizeCanvas ( canvas , ctx ) , false ) ;
117
+
118
+ canvas . addEventListener ( "click" , ( ) => {
119
+ state . currentColorIndex = ( state . currentColorIndex + 1 ) % state . bgColors . length ;
120
+ drawCanvas ( canvas , ctx ) ;
121
+ } , false ) ;
122
+ canvas . addEventListener ( "keydown" , ( e ) => {
123
+ if ( e . key === "Enter" || e . key === " " ) {
124
+ canvas . click ( ) ;
125
+ }
126
+ } , false ) ;
127
+ } ) ;
125
128
}
0 commit comments