from PIL import Image, ImageDraw, ImageFont
Configurações da imagem
width, height = 800, 800
background_color = (0, 0, 139) # Azul escuro
Cria a imagem e o objeto para desenhar
img = Image.new('RGB', (width, height), color=background_color)
draw = ImageDraw.Draw(img)
Definir as coordenadas da pílula (rounded rectangle)
pill_bbox = (100, 300, 700, 500)
pill_color = (255, 215, 0) # Dourado
draw.rounded_rectangle(pill_bbox, radius=100, fill=pill_color)
Dividir a pílula ao meio com uma linha vertical
draw.line(((400, 300), (400, 500)), fill=(0, 0, 0), width=5)
Desenhar uma cruz no lado esquerdo da pílula
cross_center = (250, 400)
cross_size = 60
Linha horizontal da cruz
draw.line(
[(cross_center[0] - cross_size // 2, cross_center[1]),
(cross_center[0] + cross_size // 2, cross_center[1])],
fill=(255, 255, 255), width=8
)
Linha vertical da cruz
draw.line(
[(cross_center[0], cross_center[1] - cross_size // 2),
(cross_center[0], cross_center[1] + cross_size // 2)],
fill=(255, 255, 255), width=8
)
Inserir o nome do canal abaixo do ícone
text = "Pílulas do Evangelho"
try:
font = ImageFont.truetype("arial.ttf", 40)
except IOError:
font = ImageFont.load_default()
text_width, text_height = draw.textsize(text, font=font)
text_position = ((width - text_width) / 2, 550)
draw.text(text_position, text, fill=(255, 255, 255), font=font)
Salvar e mostrar a imagem
img.save("pilulas_do_evangelho.png")
img.show()