mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-28 19:01:34 +00:00
- BG_STOPS: +10deg #e8ddcf (morning light), +30..90deg #ffffff; night half of the scale untouched (-4 #131a28, -12..-90 #070c14) - drawn-plan paper vs white sky: all paper shapes now sit in one .hp-paperg group; in daynight mode the group gets a subtle drop-shadow so the sheet contour stays readable at high sun (static mode and night unaffected) - pinned colors updated: test/sun.test.mjs, demo/smoke_sun.mjs; smoke_bg_color paperUnderneath follows the .hp-paperg wrapper - docs/SUN.md: explicit BG_STOPS table - demo/shot_daynight.mjs: noon/sunset/night stills of the scale
37 lines
1.7 KiB
JavaScript
37 lines
1.7 KiB
JavaScript
// Three stills of the daynight scale (noon/sunset/night) for the white-day review.
|
|
import { launch } from './serve.mjs';
|
|
const outDir = process.argv[2] || '/tmp';
|
|
const { page, browser } = await launch({ width: 700, height: 700 }, 1);
|
|
await page.emulateMedia({ reducedMotion: 'reduce' });
|
|
await page.evaluate(async () => {
|
|
const c = window.__card;
|
|
const sp = c._serverCfg.spaces.find((s) => s.id === 'f1');
|
|
sp.openings = [
|
|
{ id: 'wN', type: 'window', x: 0.30, y: 0.14, angle: 0, length: 0.08 },
|
|
{ id: 'wE', type: 'window', x: 0.96, y: 0.60, angle: 90, length: 0.08 },
|
|
{ id: 'wW', type: 'window', x: 0.04, y: 0.30, angle: 90, length: 0.08 },
|
|
];
|
|
sp.plan_url = ''; // hand-drawn plan: white paper — the risky case for a white day
|
|
sp.settings = { ...(sp.settings || {}), show_borders: true, fill_mode: 'glow' };
|
|
c._serverCfg.settings = { ...(c._serverCfg.settings || {}), north_deg: 0, sun_rays: true, bg_mode: 'daynight' };
|
|
c._cfgRev = (c._cfgRev || 0) + 1;
|
|
});
|
|
const shot = async (az, el, name) => {
|
|
await page.evaluate(async ([az, el]) => {
|
|
const c = window.__card;
|
|
c.hass = { ...c.hass, states: { ...c.hass.states, 'sun.sun': {
|
|
entity_id: 'sun.sun', state: el > 0 ? 'above_horizon' : 'below_horizon',
|
|
attributes: { azimuth: az, elevation: el },
|
|
} } };
|
|
c.requestUpdate(); await c.updateComplete;
|
|
}, [az, el]);
|
|
await page.waitForTimeout(300);
|
|
const stage = await page.evaluateHandle(() => window.__card.shadowRoot.querySelector('.stage'));
|
|
await stage.asElement().screenshot({ path: `${outDir}/${name}.png` });
|
|
};
|
|
await shot(180, 60, 'dn_noon');
|
|
await shot(265, 3, 'dn_sunset');
|
|
await shot(0, -20, 'dn_night');
|
|
await browser.close();
|
|
console.log('shots done');
|