Skip to content

Commit 18a2aa7

Browse files
committed
Update
1 parent 061873c commit 18a2aa7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

generate_showcase.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
1+
"""
2+
This module provides a function to create and save an image with custom text,
3+
and background colors using the Pillow library.
4+
"""
15
from PIL import Image, ImageDraw, ImageFont
26

3-
text = """ABCDEFGHIJKLMNOPQRSTUVWXYZ
7+
TEXT = """ABCDEFGHIJKLMNOPQRSTUVWXYZ
48
abcdefghijklmnopqrstuvwxyz
59
0123456789
610
_-~=+*&#$@%^
711
/<[{(|)}]>\
812
`'".,:;!?"""
913

10-
width, height = 3840, 1350
11-
font_path = "NeoSpleen.ttf"
12-
font_size = 294
13-
font = ImageFont.truetype(font_path, font_size)
14+
WIDTH, HEIGHT = 3840, 1350
15+
FONT_PATH = "NeoSpleen.ttf"
16+
FONT_SIZE = 294
17+
FONT = ImageFont.truetype(FONT_PATH, FONT_SIZE)
1418

1519

16-
def create_image(background_color, text_color, file_name):
17-
image = Image.new("RGB", (width, height), background_color)
20+
def create_image(text_color, background_color, file_path):
21+
"""
22+
Create an save an image with specified text color and background color.
23+
24+
Args:
25+
text_color (str): The color of the text in the image.
26+
background_color (str): The background color of the image.
27+
file_path (str): The filename to save the image under.
28+
"""
29+
image = Image.new("RGB", (WIDTH, HEIGHT), background_color)
1830
draw = ImageDraw.Draw(image)
19-
draw.text((0, 0), text, fill=text_color, font=font)
20-
image.save("Showcase-" + file_name)
31+
draw.text((0, 0), TEXT, fill=text_color, font=FONT)
32+
image.save("Showcase-" + file_path)
2133

2234

23-
create_image("black", "white", "WoB.png")
24-
create_image("white", "black", "BoW.png")
35+
create_image("white", "black", "WoB.png")
36+
create_image("black", "white", "BoW.png")

0 commit comments

Comments
 (0)