From a3faf8b9c90a91718a94120451d87c4beee43b56 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 27 Jun 2022 01:30:28 +0400 Subject: [PATCH] Made use of a new style name feature and implemented a dark style, and now by default light version is being rendered. --- internal/captcha/dwelling_captcha.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/captcha/dwelling_captcha.go b/internal/captcha/dwelling_captcha.go index 97af92c..82110d5 100644 --- a/internal/captcha/dwelling_captcha.go +++ b/internal/captcha/dwelling_captcha.go @@ -29,11 +29,19 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image { ctx := gg.NewContext(dwImageWidth, dwImageHeight) // fill background - ctx.SetRGB255(0x0a, 0x0a, 0x0a) + if style == "dark" { + ctx.SetRGB255(0x0a, 0x0a, 0x0a) + } else { + ctx.SetRGB255(0xf5, 0xf5, 0xf5) + } ctx.Clear() // draw text - ctx.SetRGB255(0xf5, 0xf5, 0xf5) + if style == "dark" { + ctx.SetRGB255(0xf5, 0xf5, 0xf5) + } else { + ctx.SetRGB255(0x0a, 0x0a, 0x0a) + } ctx.Scale(4.0, 2.7) ctx.DrawStringAnchored(string(c.GetAnswer()), 20, 5, .5, .5)