Improved 'Sow' and 'Harvest' calcs
Better background on the event banners
This commit is contained in:
fraxle
2026-08-02 16:22:58 +01:00
parent e55e0df86f
commit 566d8d36e2
8 changed files with 291 additions and 71 deletions
+26 -4
View File
@@ -56,6 +56,31 @@ export function utciCategory(u) {
}
}
// -------------------------------------------------------------------
// WEATHER TINT PALETTE - single source of truth for "what colour is
// this weather", shared by the day tabs (components/DayTabs.js) and the
// warning event banner (events/weather-checks.js + app.js).
// -------------------------------------------------------------------
// The day tabs pick ONE dimension by priority (heat -> snow -> rain ->
// cloud -> sun) and only vary its shade; these helpers are the shade
// ramps for the non-temperature dimensions. Temperature-driven tints
// come from utciCategory().bg / petCategory().bg instead.
// -------------------------------------------------------------------
export const hexToRgb = (hx) => {
const n = parseInt(hx.replace('#', ''), 16);
return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
};
export const mixRgb = (a, b, t) =>
a.map((v, i) => Math.round(v + (b[i] - v) * Math.max(0, Math.min(1, t))));
// Rain: light -> deep blue with amount (mm over the period).
export const rainTint = (mm) => mixRgb([150, 176, 212], [44, 84, 150], mm / 8);
// Cloud: light -> dark grey with cover (%).
export const cloudTint = (pct) => mixRgb([205, 206, 208], [110, 115, 122], (pct - 30) / 70);
// Snow: pale -> icy blue with depth (cm).
export const snowTint = (cm) => mixRgb([226, 234, 244], [176, 202, 232], cm / 1.5);
// -------------------------------------------------------------------
// PET_BANDS - same shape as UTCI_BANDS, recalibrated for pet skin/fur
// instead of bare human skin.
@@ -437,10 +462,7 @@ const SKY_KEYS_SETTING = [
[ 90, '#1a7abf', '#60b8e8'],
];
function hexToRgb(hex) {
const n = parseInt(hex.slice(1), 16);
return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
}
/* hexToRgb is the exported one from the weather tint palette above. */
function rgbToHex([r, g, b]) {
return '#' + [r, g, b].map(v => Math.round(v).toString(16).padStart(2, '0')).join('');
}