1.9.3.2
Moon phase fix 2
This commit is contained in:
@@ -192,9 +192,8 @@ export function SkyScope({ elev, dt, glob = 0, size = 26 }) {
|
||||
|
||||
const phase = moonPhaseFraction(dt);
|
||||
const moonR = innerR * 0.55;
|
||||
const phaseOffset = Math.cos(Math.PI * phase) * moonR;
|
||||
const moonLitFromRight = phase < 0.5;
|
||||
const shadowCx = r + phaseOffset;
|
||||
const shadowOffset = (1 - Math.abs(2 * phase - 1)) * 2 * moonR;
|
||||
const shadowCx = r + (phase < 0.5 ? -shadowOffset : shadowOffset);
|
||||
const grass = grassFillForElev(elev);
|
||||
|
||||
const uid = `ss-${size}-${Math.round(elev * 10)}-${Math.round(phase * 1000)}-${isRising ? 'r' : 's'}`;
|
||||
@@ -437,9 +436,8 @@ export function ScopeReticle({ value, cat, loading, elev = 0, dt = new Date(), g
|
||||
const sunGlowPeak = 0.30 + radFrac * 0.45 + horizFrac * 0.15; // centre opacity
|
||||
const moonDrawR = 15;
|
||||
const moonY = cy - 45;
|
||||
const phaseOffset = Math.cos(Math.PI * phase) * moonDrawR;
|
||||
const moonLitFromRight = phase < 0.5;
|
||||
const moonShadowCx = cx + phaseOffset;
|
||||
const shadowOffset = (1 - Math.abs(2 * phase - 1)) * 2 * moonDrawR;
|
||||
const moonShadowCx = cx + (phase < 0.5 ? -shadowOffset : shadowOffset);
|
||||
// Readout text colours flip with day/night for legibility against the sky.
|
||||
const readoutColor = isDay ? '#1e1208' : '#f5edd6';
|
||||
const readoutMutedColor = isDay ? '#9a7d5a' : '#d4c5a8';
|
||||
|
||||
+1
-1
@@ -294,7 +294,7 @@ export function confidenceBand(i) {
|
||||
export function moonPhaseFraction(date) {
|
||||
const JD = date.getTime() / 86400000 + 2440587.5;
|
||||
const syn = 29.530588;
|
||||
const ref = 2451550.2597;
|
||||
const ref = 2451560.2054;
|
||||
let p = ((JD - ref) % syn) / syn;
|
||||
if (p < 0) p += 1;
|
||||
return p;
|
||||
|
||||
Reference in New Issue
Block a user