nordic-skating / commit
style(ice): impossible ice is hot pink, at midnight as at noon
index.html | 4 ++-- src/render/ice.ts | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index ffface0..70cee1d 100644 --- a/index.html +++ b/index.html @@ -55,7 +55,7 @@ <dd>Thinner ice, near its limit. This is the ice that sings.</dd> <dt>Nearly black</dt> <dd>Thin ice. A high note, and it cracks around you.</dd> - <dt class="impossible-only">Black with a green glow</dt> + <dt class="impossible-only">Bright pink</dt> <dd class="impossible-only">Impossibly thin ice. A very high note, and no cracks at all.</dd> </dl> <p>Nobody falls through. How thick the ice is decides only how it sounds.</p> @@ -91,7 +91,7 @@ <fieldset> <legend>Ice</legend> - <label><input type="checkbox" id="impossible" /> Impossible ice <small>patches thinner than any ice could be: a very high note, a green glow, no cracks</small></label> + <label><input type="checkbox" id="impossible" /> Impossible ice <small>patches thinner than any ice could be: a very high note, bright pink, no cracks</small></label> </fieldset> <fieldset> diff --git a/src/render/ice.ts b/src/render/ice.ts index c6e4bac..ca69085 100644 --- a/src/render/ice.ts +++ b/src/render/ice.ts @@ -28,11 +28,11 @@ const MAP_REDRAW = 32 /** Thick ice is milky with frost and trapped air; this is the colour that adds. */ const MILK = [0x7d, 0x93, 0xa6] as const /** - * Ice too thin to be real (world/lake.ts) is lit from within, faintly, in a colour no ice - * is: the thinner, the more. It is the one thing on the lake that is not physics, and it - * should look it. + * Ice too thin to be real (world/lake.ts) is lit from within in a colour nothing on a + * lake is, a hot pink: the thinner, the more. It is the one thing here that is not + * physics, and it should look it. */ -const GLOW = [0x1c, 0x8e, 0x8a] as const +const GLOW = [0xff, 0x1a, 0xb8] as const /** Draw `paint` nine times, shifted by a tile each way, so that it wraps at every edge. */ function wrapped(g: CanvasRenderingContext2D, paint: () => void): void { @@ -117,6 +117,7 @@ export class Ice { /** Where the map of thickness was last drawn from: its middle across, its start along. */ private mapX = 0 private mapS = NaN + private milkiness = 1 constructor(renderer: THREE.WebGLRenderer, private lake: Lake) { this.texture = new THREE.CanvasTexture(paintIce()) @@ -156,9 +157,15 @@ export class Ice { this.redraw() } - /** How strongly the milkiness of thick ice shows: 1 by day, less by the light of a night. */ + /** + * How strongly the milkiness of thick ice shows: 1 by day, less by the light of a + * night. Impossible ice is lit from within and takes no notice: it is as pink at + * midnight as at noon, which is the more unnatural of the two. + */ set light(strength: number) { - ;(this.mesh.material as THREE.MeshLambertMaterial).emissiveIntensity = strength + // As a share of a colour's value as it is stored, which is not in proportion to its light. + this.milkiness = strength ** (1 / 2.2) + this.redraw() } /** @@ -197,7 +204,7 @@ export class Ice { ) const milk = Math.max(0, (h - BREAKING_THICKNESS) / (MAX_THICKNESS - BREAKING_THICKNESS)) const glow = Math.max(0, (BREAKING_THICKNESS - h) / (BREAKING_THICKNESS - MIN_THICKNESS)) - for (let c = 0; c < 3; c++) data[p++] = Math.round(MILK[c]! * milk + GLOW[c]! * glow) + for (let c = 0; c < 3; c++) data[p++] = Math.min(255, Math.round(MILK[c]! * milk * this.milkiness + GLOW[c]! * glow)) data[p++] = 255 } }