scene: brighter, slightly larger terrain stars so they read on a phone
Terrain overlay draws the ridge field at 2.4x alpha (capped at 1) and 1.3x radius; the dark-sky gate is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2299adefb5
commit
d2c2c279e2
2 changed files with 21 additions and 3 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { SKY } from './skyData';
|
||||
import {
|
||||
BRIGHTEN,
|
||||
createTerrainStars,
|
||||
elevationOf,
|
||||
ELEVATION_TOP,
|
||||
|
|
@ -12,7 +13,7 @@ import {
|
|||
skyColoursOf,
|
||||
} from './terrainStars';
|
||||
import { CAMERA, view } from './terrainWorld';
|
||||
import { isNight } from '../ridge/stars';
|
||||
import { isNight, makeStars } from '../ridge/stars';
|
||||
import { skyNameFor } from './terrainSky';
|
||||
|
||||
/** A 2D context that only counts: arcs painted and clears since the last reset. */
|
||||
|
|
@ -168,6 +169,19 @@ describe('turning with the camera', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('brightness', () => {
|
||||
it('draws every star at BRIGHTEN times its ridge-field alpha, capped at 1', () => {
|
||||
createTerrainStars(glCanvas(), SKY.midnight)?.draw(0);
|
||||
const want = makeStars(skyColoursOf(SKY.midnight), 390, 844).map((st) =>
|
||||
Math.min(1, st.alpha * BRIGHTEN)
|
||||
);
|
||||
ctx2d.c.alphas.forEach((a) => expect(want.some((w) => Math.abs(w - a) < 1e-9)).toBe(true));
|
||||
// and it is brighter than the ridge field's own top alpha
|
||||
const top = Math.max(...makeStars(skyColoursOf(SKY.midnight), 390, 844).map((st) => st.alpha));
|
||||
expect(Math.max(...ctx2d.c.alphas)).toBeGreaterThan(top * 1.5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('motion', () => {
|
||||
it('with no clock every star is at base and a repeat draw repaints; no twinkle', () => {
|
||||
const s = createTerrainStars(glCanvas(), SKY.midnight)!;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ export const elevationOf = (y: number): number => ELEVATION_TOP * (1 - y / SKY_S
|
|||
|
||||
const wrap = (a: number): number => a - PERIOD * Math.round(a / PERIOD);
|
||||
|
||||
/** The terrain overlay draws the ridge field's stars brighter and a little larger: a phone's small, hazy sky needs it to read. */
|
||||
export const BRIGHTEN = 2.4;
|
||||
export const GROW = 1.3;
|
||||
|
||||
export interface TerrainStars {
|
||||
/** Paint for the camera `turns` into its turn (0..1). `seconds` is the clock while the terrain moves; absent: every star at base. */
|
||||
draw(turns: number, seconds?: number): void;
|
||||
|
|
@ -126,13 +130,13 @@ export function createTerrainStars(canvas: HTMLCanvasElement, sky: SkyData): Ter
|
|||
lit.forEach(({ star, az, e }, i) => {
|
||||
const da = wrap(az - yaw);
|
||||
const gain = seconds === undefined ? 1 : gains.get(i) ?? 1;
|
||||
ctx.globalAlpha = Math.min(1, star.alpha * gain);
|
||||
ctx.globalAlpha = Math.min(1, star.alpha * gain * BRIGHTEN);
|
||||
ctx.fillStyle = star.fill;
|
||||
[da, da > 0 ? da - PERIOD : da + PERIOD].forEach((d) => {
|
||||
const at = project(d, e, w, h);
|
||||
if (!at || at.y < 0 || at.y > el.height / scale) return;
|
||||
ctx.beginPath();
|
||||
ctx.arc(at.x * scale, at.y * scale, star.r * scale, 0, 2 * Math.PI);
|
||||
ctx.arc(at.x * scale, at.y * scale, star.r * GROW * scale, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue