Lets reduce string comparisons here.
This commit is contained in:
parent
149675cd86
commit
f2d7271111
@ -26,10 +26,11 @@ func NewDwellingCaptcha(expiry time.Duration) *DwellingCaptcha {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
||||||
|
isDark := style == "dark"
|
||||||
ctx := gg.NewContext(dwImageWidth, dwImageHeight)
|
ctx := gg.NewContext(dwImageWidth, dwImageHeight)
|
||||||
|
|
||||||
// fill background
|
// fill background
|
||||||
if style == "dark" {
|
if isDark {
|
||||||
ctx.SetRGB255(0x0a, 0x0a, 0x0a)
|
ctx.SetRGB255(0x0a, 0x0a, 0x0a)
|
||||||
} else {
|
} else {
|
||||||
ctx.SetRGB255(0xf5, 0xf5, 0xf5)
|
ctx.SetRGB255(0xf5, 0xf5, 0xf5)
|
||||||
@ -37,7 +38,7 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
|||||||
ctx.Clear()
|
ctx.Clear()
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
if style == "dark" {
|
if isDark {
|
||||||
ctx.SetRGB255(0xf5, 0xf5, 0xf5)
|
ctx.SetRGB255(0xf5, 0xf5, 0xf5)
|
||||||
} else {
|
} else {
|
||||||
ctx.SetRGB255(0x0a, 0x0a, 0x0a)
|
ctx.SetRGB255(0x0a, 0x0a, 0x0a)
|
||||||
|
Loading…
Reference in New Issue
Block a user