Uiuioi commited on
Commit
6cbb002
·
verified ·
1 Parent(s): e12a004

still no map

Browse files
Files changed (2) hide show
  1. script.js +25 -13
  2. style.css +18 -6
script.js CHANGED
@@ -30,7 +30,12 @@ previewButton.addEventListener('click', function() {
30
  async function generateStarMap() {
31
  const containerWidth = starMapContainer.offsetWidth;
32
  const containerHeight = starMapContainer.offsetHeight;
33
- const mapName = mapNameInput.value || 'Unnamed Star Map';
 
 
 
 
 
34
  const latitude = parseFloat(latitudeInput.value) || 0;
35
  const longitude = parseFloat(longitudeInput.value) || 0;
36
  const starDensity = starDensitySelect.value;
@@ -58,29 +63,36 @@ previewButton.addEventListener('click', function() {
58
  return Math.abs(starLat - latitude) < 45 &&
59
  Math.abs(starLng - longitude) < 45;
60
  });
61
-
62
- // Generate stars
63
- visibleStars.forEach(star => {
64
  const starElement = document.createElement('div');
65
  starElement.className = 'star';
66
 
67
- // Convert celestial coordinates to container coordinates
68
  const x = ((star.ra - longitude + 180) % 360) / 360 * containerWidth;
69
  const y = ((star.dec - latitude + 90) % 180) / 180 * containerHeight;
70
 
71
- // Size based on magnitude (simplified)
72
  const size = 1 + Math.random() * 3;
 
73
 
74
- starElement.style.width = `${size}px`;
75
- starElement.style.height = `${size}px`;
76
- starElement.style.left = `${x}px`;
77
- starElement.style.top = `${y}px`;
78
- starElement.style.animationDelay = `${Math.random() * 2}s`;
 
 
 
 
 
 
 
 
79
 
80
  starMapContainer.appendChild(starElement);
81
  });
82
-
83
- // Remove loading text
84
  starMapContainer.removeChild(loadingText);
85
  // Real constellations data with more accurate star positions
86
  const constellations = [
 
30
  async function generateStarMap() {
31
  const containerWidth = starMapContainer.offsetWidth;
32
  const containerHeight = starMapContainer.offsetHeight;
33
+
34
+ // Clear and prepare container
35
+ starMapContainer.innerHTML = '';
36
+ starMapContainer.style.position = 'relative';
37
+ starMapContainer.style.background = 'radial-gradient(ellipse at center, #1a202c 0%, #000000 100%)';
38
+ const mapName = mapNameInput.value || 'Unnamed Star Map';
39
  const latitude = parseFloat(latitudeInput.value) || 0;
40
  const longitude = parseFloat(longitudeInput.value) || 0;
41
  const starDensity = starDensitySelect.value;
 
63
  return Math.abs(starLat - latitude) < 45 &&
64
  Math.abs(starLng - longitude) < 45;
65
  });
66
+ // Generate stars with proper positioning
67
+ visibleStars.slice(0, 200).forEach(star => {
 
68
  const starElement = document.createElement('div');
69
  starElement.className = 'star';
70
 
71
+ // Normalize coordinates to container
72
  const x = ((star.ra - longitude + 180) % 360) / 360 * containerWidth;
73
  const y = ((star.dec - latitude + 90) % 180) / 180 * containerHeight;
74
 
75
+ // Random size and brightness
76
  const size = 1 + Math.random() * 3;
77
+ const brightness = 0.5 + Math.random() * 0.5;
78
 
79
+ starElement.style.cssText = `
80
+ position: absolute;
81
+ width: ${size}px;
82
+ height: ${size}px;
83
+ left: ${x}px;
84
+ top: ${y}px;
85
+ background: white;
86
+ border-radius: 50%;
87
+ box-shadow: 0 0 ${size * 2}px ${size * 0.5}px rgba(255, 255, 255, ${brightness});
88
+ animation: twinkle ${2 + Math.random() * 3}s infinite alternate;
89
+ opacity: ${brightness};
90
+ z-index: 2;
91
+ `;
92
 
93
  starMapContainer.appendChild(starElement);
94
  });
95
+ // Remove loading text
 
96
  starMapContainer.removeChild(loadingText);
97
  // Real constellations data with more accurate star positions
98
  const constellations = [
style.css CHANGED
@@ -12,12 +12,14 @@ body {
12
  position: absolute;
13
  background-color: white;
14
  border-radius: 50%;
15
- box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.7);
16
- animation: twinkle 3s infinite alternate;
17
  pointer-events: none;
18
- z-index: 2;
19
  }
20
 
 
 
 
 
 
21
  .constellation-star {
22
  position: absolute;
23
  background-color: #fff;
@@ -26,9 +28,19 @@ body {
26
  animation: pulse 2s infinite alternate;
27
  z-index: 3;
28
  }
29
- #starMapContainer {
30
- position: relative;
31
- background: radial-gradient(ellipse at center, #1a202c 0%, #000000 100%);
 
 
 
 
 
 
 
 
 
 
32
  }
33
  .constellation-star {
34
  position: absolute;
 
12
  position: absolute;
13
  background-color: white;
14
  border-radius: 50%;
 
 
15
  pointer-events: none;
 
16
  }
17
 
18
+ #starMapContainer {
19
+ position: relative;
20
+ background: radial-gradient(ellipse at center, #1a202c 0%, #000000 100%);
21
+ overflow: hidden;
22
+ }
23
  .constellation-star {
24
  position: absolute;
25
  background-color: #fff;
 
28
  animation: pulse 2s infinite alternate;
29
  z-index: 3;
30
  }
31
+ @keyframes twinkle {
32
+ 0% { transform: scale(0.8); opacity: 0.7; }
33
+ 50% { transform: scale(1); opacity: 1; }
34
+ 100% { transform: scale(0.8); opacity: 0.7; }
35
+ }
36
+
37
+ .constellation-line {
38
+ position: absolute;
39
+ transform-origin: left center;
40
+ z-index: 1;
41
+ background: rgba(255, 255, 255, 0.7);
42
+ height: 1px;
43
+ box-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
44
  }
45
  .constellation-star {
46
  position: absolute;