habulaj commited on
Commit
33c48a8
·
verified ·
1 Parent(s): 743f0d2

Update routers/news.py

Browse files
Files changed (1) hide show
  1. routers/news.py +21 -21
routers/news.py CHANGED
@@ -62,37 +62,37 @@ def create_gradient_overlay(width: int, height: int, position: str = "bottom") -
62
  draw = ImageDraw.Draw(gradient)
63
 
64
  if position == "top":
65
- # Gradiente para topo: linear-gradient(360deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 55%, rgba(0, 0, 0, 0.5) 100%)
66
- # Posição: left: 0px, top: 0px, width: 1080px, height: 542px
67
  gradient_start = 0
68
- gradient_height = 542
69
 
70
  for y in range(gradient_height):
71
  if y < height:
72
  ratio = y / gradient_height
73
- if ratio <= 0.55: # 0% a 55%: de transparente para rgba(0,0,0,0.4)
74
- opacity_ratio = ratio / 0.55
75
- opacity = int(255 * 0.4 * opacity_ratio)
76
- else: # 55% a 100%: de rgba(0,0,0,0.4) para rgba(0,0,0,0.5)
77
- opacity_ratio = (ratio - 0.55) / (1 - 0.55)
78
- opacity = int(255 * (0.4 + 0.1 * opacity_ratio))
79
 
80
  draw.line([(0, y), (width, y)], fill=(0, 0, 0, opacity))
81
  else:
82
- # Gradiente para baixo (padrão): linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 55%, rgba(0, 0, 0, 0.5) 100%)
83
- # Posição: left: 0px, top: 808px, width: 1080px, height: 542px
84
- gradient_start = 808
85
- gradient_height = 542
86
 
87
  for y in range(gradient_height):
88
  if y + gradient_start < height:
89
  ratio = y / gradient_height
90
- if ratio <= 0.55: # 0% a 55%: de transparente para rgba(0,0,0,0.4)
91
- opacity_ratio = ratio / 0.55
92
- opacity = int(255 * 0.4 * opacity_ratio)
93
- else: # 55% a 100%: de rgba(0,0,0,0.4) para rgba(0,0,0,0.5)
94
- opacity_ratio = (ratio - 0.55) / (1 - 0.55)
95
- opacity = int(255 * (0.4 + 0.1 * opacity_ratio))
96
 
97
  draw.line([(0, y + gradient_start), (width, y + gradient_start)], fill=(0, 0, 0, opacity))
98
 
@@ -218,14 +218,14 @@ def render_responsive_text(draw: ImageDraw.Draw, text: str, x: int, y: int, max_
218
  bbox = draw.textbbox((0, 0), line, font=final_font)
219
  line_height = bbox[3] - bbox[1]
220
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
221
- # Aplicar line height de 115% (adicionar 15% de espaçamento extra)
222
  current_y += int(line_height * 1.20)
223
  else:
224
  # Desenhar texto de baixo para cima (alinhamento à base)
225
  current_y = y
226
  for i, line in enumerate(reversed(lines)):
227
  line_height = line_heights[len(lines) - 1 - i]
228
- # Aplicar line height de 115% (adicionar 15% de espaçamento extra)
229
  current_y -= int(line_height * 1.20)
230
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
231
 
 
62
  draw = ImageDraw.Draw(gradient)
63
 
64
  if position == "top":
65
+ # Gradiente para topo: linear-gradient(360deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.55) 54.94%, rgba(0, 0, 0, 0.7) 100%)
66
+ # Posição: left: 0px, top: 0px, width: 1080px, height: 706px
67
  gradient_start = 0
68
+ gradient_height = 706
69
 
70
  for y in range(gradient_height):
71
  if y < height:
72
  ratio = y / gradient_height
73
+ if ratio <= 0.5494: # 0% a 54.94%: de transparente para rgba(0,0,0,0.55)
74
+ opacity_ratio = ratio / 0.5494
75
+ opacity = int(255 * 0.55 * opacity_ratio)
76
+ else: # 54.94% a 100%: de rgba(0,0,0,0.55) para rgba(0,0,0,0.7)
77
+ opacity_ratio = (ratio - 0.5494) / (1 - 0.5494)
78
+ opacity = int(255 * (0.55 + 0.15 * opacity_ratio))
79
 
80
  draw.line([(0, y), (width, y)], fill=(0, 0, 0, opacity))
81
  else:
82
+ # Gradiente para baixo: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.55) 54.94%, rgba(0, 0, 0, 0.7) 100%)
83
+ # Posição: left: 0px, top: 644px, width: 1080px, height: 706px
84
+ gradient_start = 644
85
+ gradient_height = 706
86
 
87
  for y in range(gradient_height):
88
  if y + gradient_start < height:
89
  ratio = y / gradient_height
90
+ if ratio <= 0.5494: # 0% a 54.94%: de transparente para rgba(0,0,0,0.55)
91
+ opacity_ratio = ratio / 0.5494
92
+ opacity = int(255 * 0.55 * opacity_ratio)
93
+ else: # 54.94% a 100%: de rgba(0,0,0,0.55) para rgba(0,0,0,0.7)
94
+ opacity_ratio = (ratio - 0.5494) / (1 - 0.5494)
95
+ opacity = int(255 * (0.55 + 0.15 * opacity_ratio))
96
 
97
  draw.line([(0, y + gradient_start), (width, y + gradient_start)], fill=(0, 0, 0, opacity))
98
 
 
218
  bbox = draw.textbbox((0, 0), line, font=final_font)
219
  line_height = bbox[3] - bbox[1]
220
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
221
+ # Aplicar line height de 120% (adicionar 20% de espaçamento extra)
222
  current_y += int(line_height * 1.20)
223
  else:
224
  # Desenhar texto de baixo para cima (alinhamento à base)
225
  current_y = y
226
  for i, line in enumerate(reversed(lines)):
227
  line_height = line_heights[len(lines) - 1 - i]
228
+ # Aplicar line height de 120% (adicionar 20% de espaçamento extra)
229
  current_y -= int(line_height * 1.20)
230
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
231