You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
790 B
TypeScript

import { createCanvas } from "https://deno.land/x/canvas/mod.ts"
const WeatherInfo = [
' \\ / Sunny',
' .-. 17 °C',
'― ( ) ― ↘ 20 km/h',
' `- 10 km',
' / \\ 0.0 mm',
]
async function genImage(width: number, height: number) {
const canvas = createCanvas(width, height)
const ctx = canvas.getContext('2d')
const fontSize = 16
const lineHeight = fontSize * 1.35
ctx.fillStyle = 'white'
ctx.fillRect(0, 0, width, height)
ctx.fillStyle = 'black'
ctx.font = `${fontSize}px mono`
WeatherInfo.forEach((line, i) => {
ctx.fillText(line, 5, fontSize + lineHeight * i)
})
return Deno.writeFile('generated-image.png', canvas.toBuffer())
}
if (import.meta.main) {
await genImage(800, 480)
}
export default genImage