diff --git a/main.py b/main.py index cd5bd10..be6e6f0 100644 --- a/main.py +++ b/main.py @@ -4,16 +4,16 @@ from PIL import Image, ImageDraw, ImageFont zodiac_signs = [ "Belier", - "Taureau", - "Gemeaux", "Cancer", - "Lion", - "Vierge", "Balance", - "Scorpion", - "Sagittaire", "Capricorne", + "Taureau", + "Lion", + "Scorpion", "Verseau", + "Gemeaux", + "Vierge", + "Sagittaire", "Poissons", ] @@ -21,52 +21,53 @@ zodiac_signs = [ def generate_horoscope(): horoscope = {} for sign in zodiac_signs: - heart = choice(["+", "++", "+++", "-", "--"]) - work = choice(["+", "++", "+++", "-", "--"]) - - if heart.count("+") > 3: - heart = "+++" - elif heart.count("-") > 2: - heart = "--" - - if work.count("+") > 3: - work = "+++" - elif work.count("-") > 2: - work = "--" - + heart = choice(["+++", "++", "+", "-", "- -"]) + work = choice(["+++", "++", "+", "-", "- -"]) horoscope[sign] = {"heart": heart, "work": work} - return horoscope def create_horoscope_image(horoscope): - img_width, img_height = 800, 600 - image = Image.new("RGBA", (img_width, img_height), color="white") - draw = ImageDraw.Draw(image, "RGBA") + img_width, img_height = 1050, 450 + image = Image.new("RGBA", (img_width, img_height), color=(255, 255, 255, 0)) + draw = ImageDraw.Draw(image) - font = ImageFont.load_default() + font = ImageFont.load_default(24) - x, y = 20, 20 + x, y = 10, 10 for sign, prediction in horoscope.items(): - sign_image = Image.open(join("images", f"{sign.lower()}.png")) - image.paste(sign_image, (x, y)) + sign_image = Image.open(join("images", f"{sign.lower()}.png")).convert("RGBA") + sign_image.thumbnail((100, 100)) + image.paste(sign_image, (x, y), sign_image) - draw.text((x, y), sign, fill="black", font=font) - draw.text((x, y + 30), f"♥: {prediction['heart']}", fill="red", font=font) - draw.text((x, y + 60), f"💼: {prediction['work']}", fill="blue", font=font) + draw.text((x + 110, y), sign, fill=(0, 0, 0, 255), font=font) + draw.text( + (x + 110, y + 40), + f"♥: {prediction['heart']}", + fill=(255, 0, 0, 255), + font=font, + ) + draw.text( + (x + 110, y + 80), + f"💼: {prediction['work']}", + fill=(0, 0, 255, 255), + font=font, + ) - x += 200 - if x > 600: - x = 20 + x += 250 + if x > 900: + x = 10 y += 150 return image -new_horoscope = generate_horoscope() +if __name__ == "__main__": + # Generate new horoscope + new_horoscope = generate_horoscope() -horoscope_image = create_horoscope_image(new_horoscope) + # Create and save the image + horoscope_image = create_horoscope_image(new_horoscope) + horoscope_image.save("nouvel_horoscope.png") -horoscope_image.save("nouvel_horoscope.png") - -print("Nouvel horoscope généré et sauvegardé sous 'nouvel_horoscope.png'") + print("Nouvel horoscope généré et sauvegardé sous 'nouvel_horoscope.png'")