-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
86 lines (72 loc) · 2.24 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
let newMemberButton = document.getElementById('newMemberButton');
if(newMemberButton != null){
document.getElementById('newMemberButton').addEventListener('click', () => {
window.location.href = '/newmember';
});
}
let photoGallaryButton = document.getElementById('photoGallaryButton');
if(photoGallaryButton != null){
document.getElementById('photoGallaryButton').addEventListener('click', () => {
window.location.href = '/photos';
});
}
let blogButton = document.getElementById('blogButton');
if(blogButton != null){
document.getElementById('blogButton').addEventListener('click', () => {
window.location.href = '/blog';
});
}
let backButton = document.getElementById('homeButton');
if(backButton != null){
document.getElementById('homeButton').addEventListener('click', () => {
window.location.href = '/index';
});
}
const canvas = document.getElementById('snowCanvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let snowflakes = [];
function createSnowflakes() {
for (let i = 0; i < 100; i++) {
snowflakes.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
radius: Math.random() * 3 + 1,
speed: Math.random() * 1 + 0.5,
});
}
}
function drawSnowflakes() {
ctx.fillStyle = 'rgb(32,32,32)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'white';
ctx.beginPath();
snowflakes.forEach(snowflake => {
ctx.moveTo(snowflake.x, snowflake.y);
ctx.arc(snowflake.x, snowflake.y, snowflake.radius, 0, Math.PI * 2);
});
ctx.fill();
updateSnowflakes();
}
function updateSnowflakes() {
snowflakes.forEach(snowflake => {
snowflake.y += snowflake.speed;
if (snowflake.y > canvas.height) {
snowflake.y = 0;
snowflake.x = Math.random() * canvas.width;
}
});
}
function animateSnow() {
drawSnowflakes();
requestAnimationFrame(animateSnow);
}
createSnowflakes();
animateSnow();
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
snowflakes = [];
createSnowflakes();
});