-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground_colour_mouse_movement.html
More file actions
47 lines (41 loc) · 1.5 KB
/
background_colour_mouse_movement.html
File metadata and controls
47 lines (41 loc) · 1.5 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Mouse Movement Background</title>
<style>
body {
margin: 0;
height: 100vh;
transition: background-color 0.1s linear;
display: flex;
justify-content: center;
align-items: center;
font-family: sans-serif;
color: #fff;
}
</style>
</head>
<body>
<script>
document.addEventListener('mousemove', function (e) {
const x = e.clientX / window.innerWidth;
const y = e.clientY / window.innerHeight;
// Blue tones (cool tones)
const blueRed = Math.round(150 + x * 50); // 150–200
const blueGreen = Math.round(180 + y * 40); // 180–220
const blueBlue = Math.round(210 + x * 30); // 210–240
// Brown tones (warm tones)
const brownRed = Math.round(180 + x * 40); // 180–220
const brownGreen = Math.round(160 + y * 30); // 160–190
const brownBlue = Math.round(130 + y * 20); // 130–150
// Blend between brown and blue tones
const mixFactor = 0.5; // 0 = full brown, 1 = full blue
const red = Math.round(brownRed * (1 - mixFactor) + blueRed * mixFactor);
const green = Math.round(brownGreen * (1 - mixFactor) + blueGreen * mixFactor);
const blue = Math.round(brownBlue * (1 - mixFactor) + blueBlue * mixFactor);
document.body.style.backgroundColor = `rgb(${red}, ${green}, ${blue})`;
});
</script>
</body>