Files
hMarket/generate_logo.py

64 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from PIL import Image, ImageDraw, ImageFilter
def create_hmarket_logo(path, size=512):
# Create image with transparent background
img = Image.new('RGBA', (size, size), (255, 255, 255, 0))
draw = ImageDraw.Draw(img)
# Modern Blue/Teal Gradient simulation
# Let's draw a rounded rectangle background for the icon
padding = size // 8
rect_shape = [padding, padding, size - padding, size - padding]
corner_radius = size // 6
# Draw shadow
shadow_offset = size // 40
draw.rounded_rectangle(
[padding + shadow_offset, padding + shadow_offset, size - padding + shadow_offset, size - padding + shadow_offset],
radius=corner_radius,
fill=(0, 0, 0, 40)
)
# Draw main background circle/rounded rect with gradient
for i in range(size - 2*padding):
# Color from #3a7bd5 to #00d2ff
r = int(58 + (0 - 58) * (i / (size - 2*padding)))
g = int(123 + (210 - 123) * (i / (size - 2*padding)))
b = int(213 + (255 - 213) * (i / (size - 2*padding)))
draw.line([padding + i, padding, padding + i, size - padding], fill=(r, g, b, 255))
# Redraw rounded corners mask (to make it look like a rounded rect icon)
mask = Image.new('L', (size, size), 0)
mask_draw = ImageDraw.Draw(mask)
mask_draw.rounded_rectangle(rect_shape, radius=corner_radius, fill=255)
# Apply mask to gradient
output = Image.new('RGBA', (size, size), (255, 255, 255, 0))
output.paste(img, (0, 0), mask=mask)
# Draw Shopping Cart Icon (Simplified white vector style)
draw_icon = ImageDraw.Draw(output)
s = size // 10 # scale factor
# Cart body
cart_color = (255, 255, 255, 255)
# Handle and frame
draw_icon.line([3*s, 3*s, 3.5*s, 3*s, 4*s, 6*s, 7.5*s, 6*s], fill=cart_color, width=s//3)
# Basket
draw_icon.polygon([4*s, 4*s, 7.5*s, 4*s, 7*s, 5.5*s, 4.5*s, 5.5*s], fill=cart_color)
# Wheels
draw_icon.ellipse([4.2*s, 6.2*s, 4.8*s, 6.8*s], fill=cart_color)
draw_icon.ellipse([6.7*s, 6.2*s, 7.3*s, 6.8*s], fill=cart_color)
# Save
output.save(path)
return output
# Generate both sizes
logo512 = create_hmarket_logo("/home/hololu/calismalar/hMarket/frontend/public/logo512.png", 512)
logo192 = logo512.resize((192, 192), Image.LANCZOS)
logo192.save("/home/hololu/calismalar/hMarket/frontend/public/logo192.png")
logo512.save("/home/hololu/calismalar/hmarket-logo.png") # Extra copy for OAuth screen
print("Logolar başarıyla oluşturuldu.")