Mondfinsternis-Einfärbung in der Mondphasenleiste der Monatsvorhersage ergänzen

Analog zu moonyear.php wird die Mondscheibe je nach Finsternisart (total,
partiell, Halbschatten) eingefärbt, basierend auf den bereits geladenen
Mondfinsternis-Ereignissen des Monats.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-13 14:08:39 +02:00
co-authored by Claude Sonnet 5
parent 4c6fe6faeb
commit f550875107
+56 -2
View File
@@ -285,6 +285,7 @@ $planetDataJson = '[]';
$moonDataJson = 'null';
$monthChartCometsJson = '[]';
$moonPhaseEventsJson = '[]';
$monthLunarEclipsesJson = '{}';
$monthEventListJson = '[]';
$starDataErrorJson = 'null';
$observationTipCalendarIcsJson = '""';
@@ -3197,6 +3198,30 @@ $monthChartComets = array_map(
);
$monthChartCometsJson = json_encode($monthChartComets, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$moonPhaseEventsJson = json_encode($moonPhaseEvents, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
// Mondfinsternisse dieses Monats, nach Tag gruppiert (Peak-Ereignis reicht für
// die Einfärbung der Mondscheibe in der Mondphasenleiste, analog zu moonyear.php)
$monthLunarEclipsesByDay = [];
foreach ($eclipseEvents as $eclipseEvent) {
if (!is_array($eclipseEvent)) {
continue;
}
if (($eclipseEvent['category'] ?? '') !== 'lunar_eclipse' || ($eclipseEvent['stage'] ?? '') !== 'peak') {
continue;
}
$eclipseDateParts = explode('.', (string) ($eclipseEvent['local_date'] ?? ''));
$eclipseDay = isset($eclipseDateParts[0]) ? (int) $eclipseDateParts[0] : 0;
if ($eclipseDay < 1) {
continue;
}
$monthLunarEclipsesByDay[$eclipseDay] = [
'kind' => (string) ($eclipseEvent['kind'] ?? ''),
'time' => (string) ($eclipseEvent['local_time'] ?? ''),
];
}
$monthLunarEclipsesJson = json_encode($monthLunarEclipsesByDay, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$starDataErrorJson = json_encode($starDataError, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$observationTipCalendarIcsJson = json_encode($observationTipCalendarIcs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$observationTipCalendarFilenameJson = json_encode(sprintf('astrotools-monatsereignisse-%04d-%02d.ics', $selectedYear, $selectedMonth), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
@@ -3831,6 +3856,7 @@ const MONTH_CHART_PLANETS = <?= $planetDataJson ?: '[]' ?>;
const MONTH_CHART_MOON = <?= $moonDataJson ?: 'null' ?>;
const MONTH_CHART_COMETS = <?= $monthChartCometsJson ?: '[]' ?>;
const MONTH_PHASE_EVENTS = <?= $moonPhaseEventsJson ?: '[]' ?>;
const MONTH_LUNAR_ECLIPSES = <?= $monthLunarEclipsesJson ?: '{}' ?>;
const MONTH_EVENT_LIST = <?= $monthEventListJson ?: '[]' ?>;
const MONTH_CHART_ERROR = <?= $starDataErrorJson ?: 'null' ?>;
const OBSERVATION_TIP_ICAL = <?= $observationTipCalendarIcsJson ?: '""' ?>;
@@ -4355,7 +4381,7 @@ function monthChartCometRaDec(comet, date) {
renderPhaseCanvas(cssWidth, cssHeight, dpr, true);
}
function drawMoonDisc(x, y, radius, phaseInfo) {
function drawMoonDisc(x, y, radius, phaseInfo, eclipseKind) {
const phaseRad = phaseInfo.phaseAngleDeg * Math.PI / 180;
const cosPhase = Math.cos(phaseRad);
@@ -4408,6 +4434,33 @@ function monthChartCometRaDec(comet, date) {
ctx.drawImage(phaseImage, x - radius, y - radius, radius * 2, radius * 2);
}
// Finsternis-Einfärbung als Overlay (analog zu moonyear.php)
if (eclipseKind === 'total') {
ctx.save();
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.clip();
ctx.fillStyle = 'rgba(180, 50, 10, 0.55)';
ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
ctx.restore();
} else if (eclipseKind === 'partial') {
ctx.save();
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.clip();
ctx.fillStyle = 'rgba(160, 60, 10, 0.35)';
ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
ctx.restore();
} else if (eclipseKind === 'penumbral') {
ctx.save();
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.clip();
ctx.fillStyle = 'rgba(80, 80, 100, 0.25)';
ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
ctx.restore();
}
ctx.restore();
ctx.restore();
@@ -4466,7 +4519,8 @@ function monthChartCometRaDec(comet, date) {
const radius = Math.max(23 * layoutScale, Math.min(33 * layoutScale, spacing * 0.52));
const x = leftPad + spacing * (dayInRow - 0.5);
const centerY = rowCenters[row];
drawMoonDisc(x, centerY, radius, phaseInfoForDay(year, month, day));
const eclipseInfo = MONTH_LUNAR_ECLIPSES ? MONTH_LUNAR_ECLIPSES[day] : null;
drawMoonDisc(x, centerY, radius, phaseInfoForDay(year, month, day), eclipseInfo ? eclipseInfo.kind : null);
ctx.fillText(String(day), x, centerY + radius + (12 * layoutScale));
}