-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgpt-index.html
73 lines (68 loc) · 2.22 KB
/
gpt-index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fibonacci Tiling</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
position: relative;
width: 100vw;
height: 100vh;
overflow: hidden;
}
.tile {
box-sizing: border-box;
border: 2px solid #333;
padding: 1em;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
position: absolute;
}
</style>
</head>
<body>
<script>
const fibonacci = (n) => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);
const createTile = (x, y, size, content) => {
const tile = document.createElement("div");
tile.className = "tile";
tile.style.width = `${size}vmin`;
tile.style.height = `${size}vmin`;
tile.style.left = `${x}vmin`;
tile.style.top = `${y}vmin`;
tile.textContent = content;
return tile;
};
const addTiles = (n) => {
let x = 0, y = 0, size;
let direction = 0; // 0: right, 1: down, 2: left, 3: up
for (let i = 1; i <= n; i++) {
size = fibonacci(i) * 10;
document.body.appendChild(createTile(x, y, size, `Fibonacci Tile ${i}: ${size / 10}`));
if (direction === 0) {
x += size;
direction = 1;
} else if (direction === 1) {
y += size;
direction = 2;
} else if (direction === 2) {
x -= size + fibonacci(i - 1) * 10;
y -= fibonacci(i - 2) * 10;
direction = 3;
} else {
y -= size + fibonacci(i - 1) * 10;
x += fibonacci(i - 2) * 10;
direction = 0;
}
}
};
addTiles(7); // Adjust the number to change the number of tiles
</script>
</body>
</html>