mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 14:24:27 +01:00
Show cut gradient at the text-image bottom only if necessary
This commit is contained in:
@@ -86,6 +86,7 @@ func drawImage(paragraphs []string, style Style, metadata sdk.ProfileMetadata, d
|
|||||||
height := 525
|
height := 525
|
||||||
paddingLeft := 25
|
paddingLeft := 25
|
||||||
barExtraPadding := 0
|
barExtraPadding := 0
|
||||||
|
gradientRectHeight := 140
|
||||||
switch style {
|
switch style {
|
||||||
case StyleTelegram:
|
case StyleTelegram:
|
||||||
paddingLeft += 10
|
paddingLeft += 10
|
||||||
@@ -120,13 +121,14 @@ func drawImage(paragraphs []string, style Style, metadata sdk.ProfileMetadata, d
|
|||||||
img.Fill()
|
img.Fill()
|
||||||
|
|
||||||
// a rectangle at the bottom with a gradient from black to transparent
|
// a rectangle at the bottom with a gradient from black to transparent
|
||||||
gradientRectHeight := 140
|
if len(strings.Join(paragraphs, "\n")) > 141 {
|
||||||
gradientRectY := height - barHeight - gradientRectHeight
|
gradientRectY := height - barHeight - gradientRectHeight
|
||||||
for y := 0; y < gradientRectHeight; y++ {
|
for y := 0; y < gradientRectHeight; y++ {
|
||||||
alpha := uint8(255 * (math.Pow(float64(y)/float64(gradientRectHeight), 2)))
|
alpha := uint8(255 * (math.Pow(float64(y)/float64(gradientRectHeight), 2)))
|
||||||
img.SetRGBA255(int(BACKGROUND.R), int(BACKGROUND.G), int(BACKGROUND.B), int(alpha))
|
img.SetRGBA255(int(BACKGROUND.R), int(BACKGROUND.G), int(BACKGROUND.B), int(alpha))
|
||||||
img.DrawRectangle(0, float64(gradientRectY+y), float64(width), 1)
|
img.DrawRectangle(0, float64(gradientRectY+y), float64(width), 1)
|
||||||
img.Fill()
|
img.Fill()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw author's name
|
// draw author's name
|
||||||
|
|||||||
Reference in New Issue
Block a user