Untitled
unknown
plain_text
a year ago
1.3 kB
4
Indexable
from PIL import Image, ImageDraw, ImageFont # Create a blank image with white background width, height = 400, 400 background_color = (255, 255, 255) image = Image.new("RGB", (width, height), background_color) draw = ImageDraw.Draw(image) # Colors and font setup tube_color = (255, 153, 51) # Orange for the popsicle text_color = (0, 51, 102) # Dark blue for text font_size = 40 # Draw the popsicle tube_width = 60 tube_height = 300 x_center = width // 2 y_center = height // 2 draw.rectangle([ (x_center - tube_width // 2, y_center - tube_height // 2), (x_center + tube_width // 2, y_center + tube_height // 2) ], fill=tube_color) # Draw the break line break_line_height = 10 draw.rectangle([ (x_center - tube_width // 2, y_center - break_line_height // 2), (x_center + tube_width // 2, y_center + break_line_height // 2) ], fill=background_color) # Add text font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", font_size) text = "TubePops" text_width, text_height = draw.textsize(text, font=font) draw.text( (x_center - text_width // 2, y_center + tube_height // 2 + 20), text, fill=text_color, font=font ) # Show the image image.show()
Editor is loading...
Leave a Comment