This repository has been archived on 2026-08-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
drizzli/src/routes/weather/canvas/daylight.ts
T

23 lines
599 B
TypeScript

import type { ConfigInterface } from '../config';
export default (
ctx: CanvasRenderingContext2D | null | undefined,
config: ConfigInterface,
series: Date[]
): void => {
if (ctx) {
for (const [index, value] of series.entries()) {
if (value.getHours() > 6 && value.getHours() < 21) {
ctx.beginPath();
ctx.moveTo(index * config.deltaX, config.maxY);
ctx.lineTo(index * config.deltaX, 0);
ctx.lineTo((index + 1) * config.deltaX, 0);
ctx.lineTo((index + 1) * config.deltaX, config.maxY);
ctx.closePath();
ctx.fillStyle = '#f4ff0014';
ctx.fill();
}
}
}
};