-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctf.js
More file actions
152 lines (128 loc) · 5.59 KB
/
ctf.js
File metadata and controls
152 lines (128 loc) · 5.59 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
$(document).ready(function() {
$('.ctf-item').click(function(e) {
// Check if the click was on an element that should NOT trigger card navigation
if ($(e.target).is('a, button, .no-propagation') ||
$(e.target).closest('a, button, .no-propagation').length) {
return; // Don't navigate, let the element handle its own click
}
window.location.href = $(this).data('url');
});
});
class FloatingPencilArt {
constructor() {
this.container = document.getElementById('ascii-pencils');
this.pencils = [];
// Your provided ASCII art
this.pencilArt = `
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⣷⣄⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠲⣄⠙⢿⣿⡿⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣤⠈⠳⡄⠉⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣴⠟⢁⡴⠂⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣴⠟⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣴⠟⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣴⠟⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣴⠟⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣠⠞⢁⣴⠟⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣠⠞⢁⣴⠟⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠘⢁⣴⠟⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢾⣷⣄⠁⠴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣰⠄⠙⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
`.trim();
this.init();
}
createPencil() {
const pencil = document.createElement('div');
pencil.className = 'pencil';
let x = Math.random() * window.innerWidth*0.45;
let y = Math.random() * window.innerHeight*0.45;
// Random properties
const scale = Math.random()+1;
const rotationSpeed = (Math.random() - 0.5) * 4; // Between -1.5 and 1.5
// Movement properties
const floatAmplitude = Math.random() + 10 + 0.5; // Floating intensity
// Pencil colors
const colors = ['#40be3bff', '#549c44ff', '#75bb6eff', '#22ae03ff'];
const color = colors[Math.floor(Math.random() * colors.length)];
pencil.style.left = x + 'px';
pencil.style.top = y + 'px';
pencil.style.color = color;
pencil.style.opacity = 1;
pencil.textContent = this.pencilArt;
this.container.appendChild(pencil);
return {
element: pencil,
x: x,
y: y,
rotation: Math.random() * 360,
rotationSpeed: rotationSpeed,
scale: scale,
floatOffset: Math.random(),
floatAmplitude: floatAmplitude,
createdAt: Date.now(),
lifeDuration: 4000 + Math.random() * 5000 // 30-60 seconds
};
}
updatePencil(pencil) {
const now = Date.now();
const time = now / 1000;
// Add floating motion
const floatY = Math.sin(time * 2 + pencil.floatOffset) * pencil.floatAmplitude;
// Update rotation
pencil.rotation += pencil.rotationSpeed;
// Apply all transformations
pencil.element.style.transform = `
translate(${pencil.x}px, ${pencil.y + floatY}px)
rotate(${pencil.rotation}deg)
scale(${pencil.scale})
`;
// Fade out pencils that are about to expire
const age = now - pencil.createdAt;
if (age > pencil.lifeDuration - 2000) {
const fadeProgress = (age - (pencil.lifeDuration - 2000)) / 2000;
pencil.element.style.opacity = Math.max(0, pencil.element.style.opacity - fadeProgress * 0.1);
}
return age < pencil.lifeDuration;
}
animate() {
// Update all pencils
this.pencils = this.pencils.filter(pencil => this.updatePencil(pencil));
// Continue animation
requestAnimationFrame(() => this.animate());
}
init() {
this.animate();
// Continuously add new pencils
setInterval(() => {
if (this.pencils.length < 10) {
this.pencils.push(this.createPencil());
}
}, 10);
// Handle window resize
this.handleResize();
}
handleResize() {
window.addEventListener('resize', () => {
// Adjust pencil positions to stay within new bounds
this.pencils.forEach(pencil => {
pencil.x = Math.min(pencil.x, window.innerWidth - 50);
pencil.y = Math.min(pencil.y, window.innerHeight - 50);
});
});
}
}
// Initialize when page loads
document.addEventListener('DOMContentLoaded', () => {
new FloatingPencilArt(); // Use the dynamic version with different movement patterns
});
// Reinitialize on resize to prevent accumulation
window.addEventListener('resize', () => {
const container = document.getElementById('ascii-pencils');
if (container) {
container.innerHTML = '';
setTimeout(() => {
new FloatingPencilArt();
}, 250);
}
});