Skip to content

Commit 0cc88b4

Browse files
committed
fix: revert opacity background color
1 parent 0acd8c1 commit 0cc88b4

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

scripts/main.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ window.addEventListener("load", main, false);
2626

2727
function drawCanvas(canvas, ctx) {
2828
const { currentColorIndex, bgColors } = state;
29-
ctx.font = "24px monospace";
29+
ctx.font = "25px monospace";
3030
ctx.fillStyle = `rgba(${bgColors[currentColorIndex].join(", ")}, 1)`;
3131
ctx.fillRect(0, 0, canvas.width, canvas.height);
3232

@@ -43,7 +43,7 @@ function resizeCanvas(canvas, ctx) {
4343
function drawLines(canvas, ctx) {
4444
const { currentColorIndex, txtColors } = state;
4545
const margin = canvas.height / 20;
46-
const stroke = 2;
46+
const stroke = (canvas.height * canvas.width) / 400000;
4747

4848
ctx.fillStyle = `rgba(${txtColors[currentColorIndex].join(", ")}, 1)`;
4949

@@ -90,6 +90,7 @@ async function fadeCanvas(canvas, ctx) {
9090
out = true;
9191
}
9292
canvas.style.opacity = op;
93+
canvas.style.filter = "alpha(opacity=" + op * 100 + ")";
9394
op += (out ? -1 : 1) * 0.01;
9495
}, 50);
9596
}
@@ -109,17 +110,19 @@ function main() {
109110
drawCanvas(canvas, ctx);
110111
resizeCanvas(canvas, ctx);
111112
fadeCanvas(canvas, ctx);
112-
});
113113

114-
window.addEventListener("resize", () => resizeCanvas(canvas, ctx), false);
114+
document.body.style.backgroundColor = "white";
115115

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+
});
125128
}

styles/globals.css

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ body {
33
height: 100dvh;
44
margin: 0;
55
border: 0;
6+
display: block;
67
overflow: hidden;
78
overscroll-behavior-y: none;
89
touch-action: manipulation;
9-
display: flex;
10-
justify-content: center;
11-
align-items: center;
12-
font-weight: bold;
1310
background-color: rgb(0, 100, 72);
1411
}
1512

1613
canvas {
1714
position: absolute;
18-
width: 100%;
19-
height: 100%;
2015
left: 0;
2116
top: 0;
2217
cursor: pointer;

0 commit comments

Comments
 (0)