From 3565a9d228ab2c898cde48f2922ea7a16bff8d92 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 19 Nov 2023 18:31:59 -0300 Subject: [PATCH] background and foreground colors. --- render_image.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/render_image.go b/render_image.go index 80cdb8c..14904af 100644 --- a/render_image.go +++ b/render_image.go @@ -23,10 +23,16 @@ const ( MAX_CHARS_PER_LINE = 52 MAX_CHARS_PER_QUOTE_LINE = 48 FONT_SIZE = 7 + FONT_DPI = 300 BLOCK = "|" ) +var ( + BACKGROUND = color.RGBA{20, 29, 39, 255} + FOREGROUND = color.RGBA{142, 212, 249, 255} +) + //go:embed fonts/* var fonts embed.FS @@ -164,17 +170,19 @@ func drawImage(lines []string, ttf *truetype.Font, style Style) (image.Image, er } img := gg.NewContext(width, height) - img.SetColor(color.Black) + img.SetColor(BACKGROUND) + img.Clear() + img.SetColor(FOREGROUND) img.SetFontFace(truetype.NewFace(ttf, &truetype.Options{ Size: FONT_SIZE, - DPI: 300, + DPI: FONT_DPI, Hinting: font.HintingFull, })) for i, line := range lines { img.DrawStringWrapped(line, float64(10+paddingLeft), - float64(10+(i*FONT_SIZE*300*256.0/72.0)>>8), + float64(10+(i*FONT_SIZE*FONT_DPI*256.0/72.0)>>8), 0, 0, float64(width-10-paddingLeft), float64(height-10), gg.AlignLeft,