|
| 1 | +import matplotlib.pyplot as plt |
| 2 | +from PIL import Image, ImageDraw, ImageFont |
| 3 | +import numpy as np |
| 4 | + |
| 5 | +# Initialize a transparent canvas |
| 6 | +width, height = 900, 900 |
| 7 | +image = Image.new("RGBA", (width, height), (255, 255, 255, 255)) |
| 8 | +draw = ImageDraw.Draw(image) |
| 9 | + |
| 10 | +# Define the text and font sizes |
| 11 | +text = "Qlibs" |
| 12 | +font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" |
| 13 | +font_size = 120 |
| 14 | +font = ImageFont.truetype(font_path, font_size) |
| 15 | +font_small = ImageFont.truetype(font_path, 60) |
| 16 | + |
| 17 | +# Define colors |
| 18 | +text_color = "darkslategray" |
| 19 | +icon_color = "royalblue" |
| 20 | + |
| 21 | +# Calculate text size and position |
| 22 | +text_width, text_height = draw.textsize(text, font=font) |
| 23 | +text_x = (width - text_width) // 2 + 70 |
| 24 | +text_y = (height - text_height) // 2 + 10 |
| 25 | + |
| 26 | +# Draw the text |
| 27 | +draw.text((text_x, text_y), text, fill=text_color, font=font) |
| 28 | +draw.text((text_x+350, text_y+40), "++", fill="black", font=font_small) |
| 29 | + |
| 30 | +# Draw curly braces icon |
| 31 | +brace_font_size = 160 |
| 32 | +brace_font = ImageFont.truetype(font_path, brace_font_size) |
| 33 | +brace_text = "{}" |
| 34 | +brace_width, brace_height = draw.textsize(brace_text, font=brace_font) |
| 35 | +brace_x = text_x - brace_width - 20 # Position to the left of the text |
| 36 | +brace_y = (height - brace_height) // 2 - 10 |
| 37 | + |
| 38 | +draw.text((brace_x, brace_y), brace_text, fill=icon_color, font=brace_font) |
| 39 | + |
| 40 | +# Convert to array and plot using matplotlib for better visualization |
| 41 | +image_array = np.array(image) |
| 42 | + |
| 43 | +#plt.figure(figsize=(10, 5)) |
| 44 | +#plt.imshow(image_array) |
| 45 | +#plt.axis('off') |
| 46 | +#plt.show() |
| 47 | + |
| 48 | +# Save the image with a transparent background |
| 49 | +image.save("qlibs_logo_v2.png", "PNG") |
0 commit comments