@jjlmoya/utils-astronomy 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ const { ui } = Astro.props;
|
|
|
19
19
|
<div class="bortle-bg-gradient"></div>
|
|
20
20
|
|
|
21
21
|
<div id="layer-stars" class="bortle-layer layer-stars">
|
|
22
|
-
<
|
|
22
|
+
<canvas id="canvas-stars" class="stars-canvas"></canvas>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
25
|
<div id="layer-milkyway" class="bortle-layer layer-milkyway">
|
|
@@ -97,6 +97,70 @@ const { ui } = Astro.props;
|
|
|
97
97
|
thumb: document.getElementById('custom-thumb'),
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
+
const canvas = document.getElementById('canvas-stars') as HTMLCanvasElement | null;
|
|
101
|
+
if (canvas) {
|
|
102
|
+
const ctx = canvas.getContext('2d');
|
|
103
|
+
const STAR_COUNT = 2200;
|
|
104
|
+
type Star = { x: number; y: number; r: number; alpha: number; twinkle: number };
|
|
105
|
+
const stars: Star[] = [];
|
|
106
|
+
let cw = 0;
|
|
107
|
+
let ch = 0;
|
|
108
|
+
|
|
109
|
+
function resize(w: number, h: number) {
|
|
110
|
+
cw = w; ch = h;
|
|
111
|
+
canvas.width = w;
|
|
112
|
+
canvas.height = h;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function initStars(w: number, h: number) {
|
|
116
|
+
resize(w, h);
|
|
117
|
+
stars.length = 0;
|
|
118
|
+
for (let i = 0; i < STAR_COUNT; i++) {
|
|
119
|
+
stars.push({
|
|
120
|
+
x: Math.random() * w,
|
|
121
|
+
y: Math.random() * h,
|
|
122
|
+
r: Math.random() < 0.6 ? Math.random() * 0.7 + 0.3 : Math.random() * 1.2 + 0.8,
|
|
123
|
+
alpha: Math.random() * 0.5 + 0.5,
|
|
124
|
+
twinkle: Math.random() * Math.PI * 2,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function drawStars() {
|
|
130
|
+
if (!ctx) return;
|
|
131
|
+
ctx.clearRect(0, 0, cw, ch);
|
|
132
|
+
const now = performance.now() / 1000;
|
|
133
|
+
ctx.fillStyle = '#fff';
|
|
134
|
+
stars.forEach((s) => {
|
|
135
|
+
ctx.globalAlpha = s.alpha * (0.85 + 0.15 * Math.sin(now * 1.5 + s.twinkle));
|
|
136
|
+
ctx.beginPath();
|
|
137
|
+
ctx.arc(s.x, s.y, s.r, 0, Math.PI * 2);
|
|
138
|
+
ctx.fill();
|
|
139
|
+
});
|
|
140
|
+
ctx.globalAlpha = 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let animFrame: number;
|
|
144
|
+
function animateStars() {
|
|
145
|
+
drawStars();
|
|
146
|
+
animFrame = requestAnimationFrame(animateStars);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const ro = new ResizeObserver(() => {
|
|
150
|
+
resize(canvas.offsetWidth, canvas.offsetHeight);
|
|
151
|
+
initStars(cw, ch);
|
|
152
|
+
});
|
|
153
|
+
ro.observe(canvas);
|
|
154
|
+
|
|
155
|
+
document.addEventListener('astro:before-swap', () => {
|
|
156
|
+
cancelAnimationFrame(animFrame);
|
|
157
|
+
ro.disconnect();
|
|
158
|
+
}, { once: true });
|
|
159
|
+
|
|
160
|
+
initStars(canvas.offsetWidth || 800, canvas.offsetHeight || 450);
|
|
161
|
+
animateStars();
|
|
162
|
+
}
|
|
163
|
+
|
|
100
164
|
if (elements.slider) {
|
|
101
165
|
function updateText(level: number, data: ReturnType<typeof getBortleData>) {
|
|
102
166
|
if (elements.title) elements.title.innerText = data.title;
|
|
@@ -187,16 +251,14 @@ const { ui } = Astro.props;
|
|
|
187
251
|
|
|
188
252
|
.layer-stars {
|
|
189
253
|
z-index: 10;
|
|
190
|
-
mix-blend-mode: plus-lighter;
|
|
191
254
|
opacity: 1;
|
|
192
255
|
}
|
|
193
256
|
|
|
194
|
-
.stars-
|
|
257
|
+
.stars-canvas {
|
|
195
258
|
position: absolute;
|
|
196
259
|
inset: 0;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
background-position: center;
|
|
260
|
+
width: 100%;
|
|
261
|
+
height: 100%;
|
|
200
262
|
}
|
|
201
263
|
|
|
202
264
|
.layer-milkyway {
|
|
@@ -174,7 +174,7 @@ const { ui } = Astro.props;
|
|
|
174
174
|
el.className = "scope-object";
|
|
175
175
|
el.dataset.mag = obj.mag.toString();
|
|
176
176
|
el.innerHTML = `
|
|
177
|
-
<div class="scope-obj-icon
|
|
177
|
+
<div class="scope-obj-icon" style="color:${obj.color}">
|
|
178
178
|
<span class="iconify" data-icon="${obj.icon}"></span>
|
|
179
179
|
</div>
|
|
180
180
|
<div class="scope-obj-label">
|
|
@@ -203,7 +203,7 @@ const { ui } = Astro.props;
|
|
|
203
203
|
document.getElementById("modal-alt")!.innerText = `Altitud: ${obj.alt}°`;
|
|
204
204
|
const iconEl = document.getElementById("modal-icon");
|
|
205
205
|
if (iconEl) {
|
|
206
|
-
iconEl.innerHTML = `<span class="iconify
|
|
206
|
+
iconEl.innerHTML = `<span class="iconify" data-icon="${obj.icon}" style="font-size:2.5rem;color:${obj.color}"></span>`;
|
|
207
207
|
}
|
|
208
208
|
const descEl = document.getElementById("modal-desc");
|
|
209
209
|
if (descEl) {
|
|
@@ -23,19 +23,19 @@ export function apertureSliderToMm(sliderValue: number): number {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const DEEP_SPACE_OBJECTS: DeepSpaceObject[] = [
|
|
26
|
-
{ name: 'Venus', type: 'Planeta', mag: -4.5, az: 270, alt: 30, icon: 'mdi:circle', color: '
|
|
27
|
-
{ name: 'Júpiter', type: 'Planeta', mag: -2.5, az: 180, alt: 40, icon: 'mdi:circle', color: '
|
|
28
|
-
{ name: 'Saturno', type: 'Planeta', mag: 0.8, az: 220, alt: 35, icon: 'mdi:circle', color: '
|
|
29
|
-
{ name: 'Marte', type: 'Planeta', mag: 1.5, az: 150, alt: 25, icon: 'mdi:circle', color: '
|
|
30
|
-
{ name: 'Sirio', type: 'Estrella', mag: -1.46, az: 145, alt: 50, icon: 'mdi:star-four-points', color: '
|
|
31
|
-
{ name: 'Canopus', type: 'Estrella', mag: -0.74, az: 200, alt: 20, icon: 'mdi:star-four-points', color: '
|
|
32
|
-
{ name: 'Arcturus', type: 'Estrella', mag: -0.05, az: 60, alt: 55, icon: 'mdi:star-four-points', color: '
|
|
33
|
-
{ name: 'Vega', type: 'Estrella', mag: 0.03, az: 40, alt: 70, icon: 'mdi:star-four-points', color: '
|
|
34
|
-
{ name: 'M42 Orión', type: 'Nebulosa', mag: 4.0, az: 140, alt: 45, icon: 'mdi:creation', color: '
|
|
35
|
-
{ name: 'M45 Pléyades', type: 'Cúmulo', mag: 1.6, az: 100, alt: 60, icon: 'mdi:creation', color: '
|
|
36
|
-
{ name: 'M31 Andrómeda', type: 'Galaxia', mag: 3.4, az: 30, alt: 50, icon: 'mdi:creation', color: '
|
|
37
|
-
{ name: 'M13 Hércules', type: 'Cúmulo', mag: 5.8, az: 80, alt: 65, icon: 'mdi:creation', color: '
|
|
38
|
-
{ name: 'M57 Anillo', type: 'Nebulosa', mag: 8.8, az: 50, alt: 58, icon: 'mdi:creation', color: '
|
|
39
|
-
{ name: 'M81 Bode', type: 'Galaxia', mag: 6.9, az: 340, alt: 55, icon: 'mdi:creation', color: '
|
|
40
|
-
{ name: 'Plutón', type: 'Planeta Enano', mag: 14.3, az: 195, alt: 22, icon: 'mdi:circle-small', color: '
|
|
26
|
+
{ name: 'Venus', type: 'Planeta', mag: -4.5, az: 270, alt: 30, icon: 'mdi:circle', color: '#fef08a', desc: 'El planeta más brillante del cielo nocturno. Visible a plena luz del día.' },
|
|
27
|
+
{ name: 'Júpiter', type: 'Planeta', mag: -2.5, az: 180, alt: 40, icon: 'mdi:circle', color: '#fef9c3', desc: 'El gigante del sistema solar. Con binoculares se pueden ver sus cuatro lunas galileanas.' },
|
|
28
|
+
{ name: 'Saturno', type: 'Planeta', mag: 0.8, az: 220, alt: 35, icon: 'mdi:circle', color: '#fefce8', desc: 'Sus anillos son visibles con un telescopio de 60mm a 50 aumentos.' },
|
|
29
|
+
{ name: 'Marte', type: 'Planeta', mag: 1.5, az: 150, alt: 25, icon: 'mdi:circle', color: '#f87171', desc: 'El planeta rojo. Varía de magnitud -2.9 en oposición a +1.8 en conjunción.' },
|
|
30
|
+
{ name: 'Sirio', type: 'Estrella', mag: -1.46, az: 145, alt: 50, icon: 'mdi:star-four-points', color: '#bfdbfe', desc: 'La estrella más brillante del cielo nocturno. Está a solo 8.6 años-luz.' },
|
|
31
|
+
{ name: 'Canopus', type: 'Estrella', mag: -0.74, az: 200, alt: 20, icon: 'mdi:star-four-points', color: '#fef9c3', desc: 'La segunda estrella más brillante, usada para navegar en el hemisferio sur.' },
|
|
32
|
+
{ name: 'Arcturus', type: 'Estrella', mag: -0.05, az: 60, alt: 55, icon: 'mdi:star-four-points', color: '#fdba74', desc: 'Gigante naranja en la constelación del Boyero. A 36 años-luz de la Tierra.' },
|
|
33
|
+
{ name: 'Vega', type: 'Estrella', mag: 0.03, az: 40, alt: 70, icon: 'mdi:star-four-points', color: '#dbeafe', desc: 'Vértice del Triángulo de Verano. La estrella de referencia para magnitud 0.' },
|
|
34
|
+
{ name: 'M42 Orión', type: 'Nebulosa', mag: 4.0, az: 140, alt: 45, icon: 'mdi:creation', color: '#a5b4fc', desc: 'La gran nebulosa de Orión, a 1344 años-luz. Vivero de estrellas jóvenes.' },
|
|
35
|
+
{ name: 'M45 Pléyades', type: 'Cúmulo', mag: 1.6, az: 100, alt: 60, icon: 'mdi:creation', color: '#93c5fd', desc: 'Las Siete Hermanas. A 444 años-luz, el cúmulo abierto más famoso del cielo.' },
|
|
36
|
+
{ name: 'M31 Andrómeda', type: 'Galaxia', mag: 3.4, az: 30, alt: 50, icon: 'mdi:creation', color: '#d8b4fe', desc: 'La galaxia vecina más grande. A 2.5 millones de años-luz, visible a simple vista en cielos oscuros.' },
|
|
37
|
+
{ name: 'M13 Hércules', type: 'Cúmulo', mag: 5.8, az: 80, alt: 65, icon: 'mdi:creation', color: '#fde047', desc: 'El gran cúmulo globular de Hércules. Contiene 300.000 estrellas a 25.100 años-luz.' },
|
|
38
|
+
{ name: 'M57 Anillo', type: 'Nebulosa', mag: 8.8, az: 50, alt: 58, icon: 'mdi:creation', color: '#67e8f9', desc: 'Nebulosa planetaria en Lyra. Anillo de gas expulsado por una enana blanca.' },
|
|
39
|
+
{ name: 'M81 Bode', type: 'Galaxia', mag: 6.9, az: 340, alt: 55, icon: 'mdi:creation', color: '#c4b5fd', desc: 'Galaxia espiral en la Osa Mayor. Interactuando gravitatoriamente con M82.' },
|
|
40
|
+
{ name: 'Plutón', type: 'Planeta Enano', mag: 14.3, az: 195, alt: 22, icon: 'mdi:circle-small', color: '#cbd5e1', desc: 'El planeta enano más famoso. Requiere un telescopio de 250mm o más y cielos oscuros.' },
|
|
41
41
|
];
|