Spaces:
Running
Running
332a94e: The patch and the key glow in the dark
Browse filesPublished from cloudronin/astara@332a94e388d8ba6821a2939a755a2c70ec5cb215
- src/render.js +47 -1
src/render.js
CHANGED
|
@@ -282,7 +282,10 @@ export function createRenderer(ctx) {
|
|
| 282 |
c.drawImage(clip.frames[h.variant].lit, x, y);
|
| 283 |
drawNail(c, s, clip, h, x, y, s.clock ?? 0);
|
| 284 |
drawRoomKey(c, s, clip, h, x, y, s.clock ?? 0);
|
| 285 |
-
} else
|
|
|
|
|
|
|
|
|
|
| 286 |
}
|
| 287 |
} else {
|
| 288 |
// Before the art exists: boxes, which is enough to judge the size of the
|
|
@@ -514,6 +517,49 @@ export function createRenderer(ctx) {
|
|
| 514 |
c.imageSmoothingEnabled = was;
|
| 515 |
}
|
| 516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
function drawFlash(c, v) {
|
| 518 |
if (!(v > 0.004)) return;
|
| 519 |
c.fillStyle = `rgba(${FLASH.RGB},${v.toFixed(3)})`;
|
|
|
|
| 282 |
c.drawImage(clip.frames[h.variant].lit, x, y);
|
| 283 |
drawNail(c, s, clip, h, x, y, s.clock ?? 0);
|
| 284 |
drawRoomKey(c, s, clip, h, x, y, s.clock ?? 0);
|
| 285 |
+
} else {
|
| 286 |
+
c.drawImage(s.houseArt[h.variant], x, y);
|
| 287 |
+
drawDoorGlow(c, s, clip, h, x, y, s.clock ?? 0);
|
| 288 |
+
}
|
| 289 |
}
|
| 290 |
} else {
|
| 291 |
// Before the art exists: boxes, which is enough to judge the size of the
|
|
|
|
| 517 |
c.imageSmoothingEnabled = was;
|
| 518 |
}
|
| 519 |
|
| 520 |
+
/**
|
| 521 |
+
* A warm pulse at a door, OUT IN THE DARK, with the torch down.
|
| 522 |
+
*
|
| 523 |
+
* The patch and the key only ever existed inside the torchlight, because
|
| 524 |
+
* everything in a doorway is drawn in the lit pass. So the street said
|
| 525 |
+
* nothing: you had to already be holding the light on a door to learn there
|
| 526 |
+
* was anything at it, which is the wrong way round — the light is what you
|
| 527 |
+
* spend, and something has to be worth spending it on.
|
| 528 |
+
*
|
| 529 |
+
* THE DROPPED SCRAPS HAVE ALWAYS DONE THIS. "A warm pulse out there is a
|
| 530 |
+
* thing you notice from across the screen, and it is the only reason to walk
|
| 531 |
+
* over; the torch is what turns the glowing dot into a page with writing on
|
| 532 |
+
* it." Same tuning value, same rhythm, same bargain — the glow says HERE and
|
| 533 |
+
* only the torch says WHAT.
|
| 534 |
+
*
|
| 535 |
+
* Glow only, no art. In the dark a black key on a wall at luminance 26 is
|
| 536 |
+
* nothing; the pool is the whole signal.
|
| 537 |
+
*/
|
| 538 |
+
function drawDoorGlow(c, s, clip, house, x, y, clock) {
|
| 539 |
+
const pulse = 1 - TORCH.KEPT_PULSE_DEPTH *
|
| 540 |
+
(0.5 - 0.5 * Math.cos(clock * Math.PI * 2 * TORCH.KEPT_PULSE_HZ));
|
| 541 |
+
const pool = (rect, strength) => {
|
| 542 |
+
if (!rect) return;
|
| 543 |
+
const [rx, ry, rw, rh] = rect;
|
| 544 |
+
const cx = x + rx + rw / 2;
|
| 545 |
+
const cy = y + ry + rh / 2;
|
| 546 |
+
const r = Math.max(rw, rh) * TORCH.KEPT_GLOW_R * 1.6;
|
| 547 |
+
const g = c.createRadialGradient(cx, cy, 0, cx, cy, r);
|
| 548 |
+
const a = TORCH.KEPT_GLOW * TORCH.KEPT_GLOW_DARK * pulse * strength;
|
| 549 |
+
g.addColorStop(0, `rgba(${TORCH.KEPT_RGB},${a.toFixed(3)})`);
|
| 550 |
+
g.addColorStop(1, `rgba(${TORCH.KEPT_RGB},0)`);
|
| 551 |
+
const was = c.globalCompositeOperation;
|
| 552 |
+
c.globalCompositeOperation = 'lighter';
|
| 553 |
+
c.fillStyle = g;
|
| 554 |
+
c.fillRect(cx - r, cy - r, r * 2, r * 2);
|
| 555 |
+
c.globalCompositeOperation = was;
|
| 556 |
+
};
|
| 557 |
+
// An empty patch, once the letter is off it and there is somewhere to pin.
|
| 558 |
+
if (house.letterTaken && house.filed == null) pool(clip.nailAt?.[house.variant], 1);
|
| 559 |
+
// And a key whose door somebody opened.
|
| 560 |
+
if (house.open && !house.keyTaken) pool(clip.keyAt?.[house.variant], 1);
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
function drawFlash(c, v) {
|
| 564 |
if (!(v > 0.004)) return;
|
| 565 |
c.fillStyle = `rgba(${FLASH.RGB},${v.toFixed(3)})`;
|