File size: 8,579 Bytes
815e811 bc34ddf 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 1f8f55e 815e811 |
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
<!DOCTYPE html>
<html>
<head>
<title>Rotating Arrows System</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #1a1a1a;
font-family: Arial, sans-serif;
color: white;
}
#container {
position: relative;
text-align: center;
}
.screen {
display: none;
margin-bottom: 20px;
}
.active {
display: block;
}
.arrow-config {
background: rgba(255, 255, 255, 0.1);
padding: 15px;
margin: 10px;
border-radius: 8px;
}
button {
padding: 10px 20px;
margin: 5px;
font-size: 16px;
background: #4a90e2;
border: none;
border-radius: 5px;
color: white;
cursor: pointer;
transition: all 0.3s ease;
}
button:hover {
background: #357abd;
transform: translateY(-2px);
}
input {
width: 60px;
padding: 5px;
margin: 5px;
border: none;
border-radius: 3px;
background: rgba(255, 255, 255, 0.2);
color: white;
}
input:focus {
outline: none;
background: rgba(255, 255, 255, 0.3);
}
canvas {
background: #333;
border-radius: 8px;
margin-top: 20px;
}
#resetBtn {
position: fixed;
top: 20px;
right: 20px;
background: #e74c3c;
}
#resetBtn:hover {
background: #c0392b;
}
.controls {
margin-top: 20px;
}
h2 {
color: #4a90e2;
margin-bottom: 20px;
}
.arrow-config label {
display: inline-block;
width: 60px;
text-align: right;
margin-right: 10px;
}
</style>
</head>
<body>
<button id="resetBtn" onclick="reset()" style="display: none;">Reset</button>
<div id="container">
<div id="startScreen" class="screen active">
<h2>Select Number of Arrows</h2>
<div>
<button onclick="selectArrows(2)">2 Arrows</button>
<button onclick="selectArrows(3)">3 Arrows</button>
<button onclick="selectArrows(4)">4 Arrows</button>
<button onclick="selectArrows(5)">5 Arrows</button>
</div>
</div>
<div id="configScreen" class="screen">
<h2>Configure Arrows</h2>
<div id="arrowConfigs"></div>
<button onclick="startAnimation()">Start Animation</button>
</div>
<canvas id="canvas" width="800" height="600" style="display: none;"></canvas>
</div>
<script>
let arrows = [];
let animationId = null;
let canvas, ctx;
let pathPoints = [];
class Arrow {
constructor(length, speed) {
this.length = length * 50;
this.speed = speed;
this.angle = 0;
}
}
function selectArrows(num) {
document.getElementById('startScreen').classList.remove('active');
document.getElementById('configScreen').classList.add('active');
document.getElementById('resetBtn').style.display = 'block';
const configsDiv = document.getElementById('arrowConfigs');
configsDiv.innerHTML = '';
for(let i = 0; i < num; i++) {
const speed = (Math.random() * 4 + 1).toFixed(1);
const length = (Math.random() * 4 + 1).toFixed(1);
const config = document.createElement('div');
config.className = 'arrow-config';
config.innerHTML = `
<h3>Arrow ${i + 1}</h3>
<div>
<label>Speed:</label>
<input type="number" min="0.1" max="5" step="0.1" value="${speed}" id="speed${i}">
</div>
<div>
<label>Length:</label>
<input type="number" min="0.1" max="5" step="0.1" value="${length}" id="length${i}">
</div>
`;
configsDiv.appendChild(config);
}
}
function startAnimation() {
arrows = [];
const inputs = document.querySelectorAll('.arrow-config input');
for(let i = 0; i < inputs.length/2; i++) {
const speed = parseFloat(document.getElementById(`speed${i}`).value);
const length = parseFloat(document.getElementById(`length${i}`).value);
arrows.push(new Arrow(length, speed));
}
document.getElementById('configScreen').classList.remove('active');
canvas = document.getElementById('canvas');
canvas.style.display = 'block';
ctx = canvas.getContext('2d');
pathPoints = [];
if(animationId) cancelAnimationFrame(animationId);
animate();
}
function animate() {
// Clear canvas
ctx.fillStyle = '#333';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Start from center
let x = canvas.width / 2;
let y = canvas.height / 2;
let totalAngle = 0;
// Draw arrows
for(let i = 0; i < arrows.length; i++) {
const arrow = arrows[i];
arrow.angle += arrow.speed * 0.02;
totalAngle += arrow.angle;
// Draw arrow line
ctx.beginPath();
ctx.moveTo(x, y);
const endX = x + Math.cos(totalAngle) * arrow.length;
const endY = y + Math.sin(totalAngle) * arrow.length;
ctx.lineTo(endX, endY);
ctx.strokeStyle = '#4a90e2';
ctx.lineWidth = 3;
ctx.stroke();
// Draw joint
ctx.beginPath();
ctx.arc(x, y, 5, 0, Math.PI * 2);
ctx.fillStyle = '#2ecc71';
ctx.fill();
// Update start point for next arrow
x = endX;
y = endY;
// Store path point for last arrow
if(i === arrows.length - 1) {
pathPoints.push({x, y});
if(pathPoints.length > 200) pathPoints.shift();
}
}
// Draw path
if(pathPoints.length > 1) {
ctx.beginPath();
ctx.moveTo(pathPoints[0].x, pathPoints[0].y);
for(let i = 1; i < pathPoints.length; i++) {
const point = pathPoints[i];
ctx.lineTo(point.x, point.y);
}
ctx.strokeStyle = '#e74c3c';
ctx.lineWidth = 2;
ctx.stroke();
}
animationId = requestAnimationFrame(animate);
}
function reset() {
if(animationId) {
cancelAnimationFrame(animationId);
animationId = null;
}
arrows = [];
pathPoints = [];
document.getElementById('startScreen').classList.add('active');
document.getElementById('configScreen').classList.remove('active');
document.getElementById('canvas').style.display = 'none';
document.getElementById('resetBtn').style.display = 'none';
const configsDiv = document.getElementById('arrowConfigs');
configsDiv.innerHTML = '';
}
// Initialize
window.onload = () => {
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
};
</script>
</body>
</html><script async data-explicit-opt-in="true" data-cookie-opt-in="true" src="https://vercel.live/_next-live/feedback/feedback.js"></script> |