Made use of a new style name feature and implemented a dark style, and now by default light version is being rendered.

This commit is contained in:
Alexander Andreev 2022-06-27 01:30:28 +04:00
parent 504a8d137f
commit a3faf8b9c9
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -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)