миграция на pixi

This commit is contained in:
azykov@mail.ru
2026-09-09 13:45:30 +03:00
parent a3f2f4eeef
commit 4e30c585d1
41 changed files with 1303 additions and 899 deletions
+4 -8
View File
@@ -61,9 +61,9 @@ const OVERLAY_KEYFRAMES: OverlayKeyframe[] = [
{ hour: 24, r: 10, g: 10, b: 35, a: 0.55 },
];
/** The ambient darkness/tint overlay for the given time of day, as a CSS rgba() string —
* interpolated piecewise-linearly between OVERLAY_KEYFRAMES. */
export function overlayColorForHour(hour: number): string {
/** The ambient darkness/tint overlay for the given time of day, as {r,g,b,a} (0-255 channels,
* 0-1 alpha) — interpolated piecewise-linearly between OVERLAY_KEYFRAMES. */
export function overlayColorComponentsForHour(hour: number): { r: number; g: number; b: number; a: number } {
const h = ((hour % 24) + 24) % 24;
let prev = OVERLAY_KEYFRAMES[0];
let next = OVERLAY_KEYFRAMES[OVERLAY_KEYFRAMES.length - 1];
@@ -78,9 +78,5 @@ export function overlayColorForHour(hour: number): string {
const span = next.hour - prev.hour;
const t = span === 0 ? 0 : (h - prev.hour) / span;
const lerp = (a: number, b: number) => a + (b - a) * t;
const r = lerp(prev.r, next.r);
const g = lerp(prev.g, next.g);
const b = lerp(prev.b, next.b);
const a = lerp(prev.a, next.a);
return `rgba(${r.toFixed(0)}, ${g.toFixed(0)}, ${b.toFixed(0)}, ${a.toFixed(3)})`;
return { r: lerp(prev.r, next.r), g: lerp(prev.g, next.g), b: lerp(prev.b, next.b), a: lerp(prev.a, next.a) };
}