Skip to content

Commit 346e4f0

Browse files
committed
scratch card added.
1 parent d698e8c commit 346e4f0

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,10 @@
268268
<td><a href="random-avatar-creator">Avatar Generator</a></td>
269269
<td><a href="https://glistening-cajeta-a6b4ef.netlify.app/random-avatar-creator/">Link</a></td>
270270
</tr>
271+
<tr>
272+
<td>52</td>
273+
<td><a href="ScratchCard">Scratch Card</a></td>
274+
<td><a href="https://glistening-cajeta-a6b4ef.netlify.app/ScratchCard/">Link</a></td>
275+
</tr>
271276
</tbody>
272277
</table>

ScratchCard/Styles.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
body {
2+
display: flex;
3+
flex-direction: column;
4+
justify-content: center;
5+
align-items: center;
6+
height: 100vh;
7+
margin: 0;
8+
background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
9+
font-family: "Poppins", sans-serif;
10+
}
11+
12+
h1 {
13+
margin: 20px 0;
14+
font-size: 36px;
15+
background: linear-gradient(45deg, #cf6c6f, #cf9e91, #424040, #d37e67);
16+
-webkit-background-clip: text;
17+
-webkit-text-fill-color: transparent;
18+
text-align: center;
19+
font-weight: bold;
20+
animation: change 2s linear infinite alternate;
21+
background-clip: text;
22+
background-size: 200% 200%;
23+
}
24+
25+
@keyframes change {
26+
0% {
27+
background-position: 0% 50%;
28+
}
29+
100% {
30+
background-position: 100% 50%;
31+
}
32+
}
33+
34+
.container {
35+
position: relative;
36+
width: 300px;
37+
height: 200px;
38+
border-radius: 15px;
39+
overflow: hidden;
40+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
41+
border: 2px solid transparent;
42+
background: linear-gradient(white, white) padding-box,
43+
linear-gradient(135deg, #f6d365 0%, #fda085 100%) border-box;
44+
}
45+
46+
#scratchCard {
47+
position: absolute;
48+
top: 0;
49+
left: 0;
50+
width: 100%;
51+
height: 100%;
52+
border-radius: 15px;
53+
z-index: 2;
54+
}
55+
56+
.message {
57+
position: absolute;
58+
top: 50%;
59+
left: 50%;
60+
transform: translate(-50%, -50%);
61+
font-size: 24px;
62+
text-align: center;
63+
font-weight: bold;
64+
color: #333;
65+
z-index: 1;
66+
transition: opacity 0.3s;
67+
}

ScratchCard/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Scratch Card</title>
7+
<link rel="stylesheet" href="styles.css" />
8+
<link rel="shortcut icon" href="/time-management.ico" type="image/x-icon" />
9+
</head>
10+
<body>
11+
<h1>Scratch Card</h1>
12+
<div class="container">
13+
<canvas id="scratchCard"></canvas>
14+
<div class="message" id="message">You won a prize!</div>
15+
</div>
16+
<script src="script.js"></script>
17+
</body>
18+
</html>

ScratchCard/script.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const canvas = document.getElementById("scratchCard");
2+
const ctx = canvas.getContext("2d");
3+
const message = document.getElementById("message");
4+
5+
const init = () => {
6+
ctx.fillStyle = "#888";
7+
ctx.fillRect(0, 0, 300, 200);
8+
};
9+
init();
10+
11+
let isDrawing = false;
12+
13+
function draw(x, y) {
14+
if (!isDrawing) return;
15+
16+
ctx.globalCompositeOperation = "destination-out";
17+
ctx.beginPath();
18+
ctx.arc(x, y, 24, 0, Math.PI * 2, false);
19+
ctx.fill();
20+
}
21+
22+
canvas.addEventListener("mousedown", (e) => {
23+
isDrawing = true;
24+
draw(e.offsetX, e.offsetY);
25+
});
26+
canvas.addEventListener("mousemove", (e) => {
27+
draw(e.offsetX, e.offsetY);
28+
});
29+
canvas.addEventListener("mouseup", () => {
30+
isDrawing = false;
31+
});

index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@
385385
<a href="./random-avatar-creator/" target="_blank">Link</a>
386386
</td>
387387
</tr>
388+
<tr>
389+
<td>52</td>
390+
<td>Scratch Card</td>
391+
<td>
392+
<a href="./ScratchCard/" target="_blank">Link</a>
393+
</td>
394+
</tr>
388395
</tbody>
389396
</table>
390397
</body>

0 commit comments

Comments
 (0)