Files
hMarket/generate_logo_orange.py

61 lines
2.3 KiB
Python

from PIL import Image, ImageDraw
def create_orange_logo(path, size=512):
# Base image
img = Image.new('RGBA', (size, size), (255, 255, 255, 0))
draw = ImageDraw.Draw(img)
# Background color #FF5722
bg_color = (255, 87, 34, 255)
padding = size // 10
corner_radius = size // 6
draw.rounded_rectangle(
[padding, padding, size - padding, size - padding],
radius=corner_radius,
fill=bg_color
)
# Scale for the 24x24 SVG path
# We want the icon to fit in the center, say 60% of the box
icon_size = size * 0.55
offset = (size - icon_size) / 2
scale = icon_size / 24
def scale_pt(x, y):
return (offset + x * scale, offset + y * scale)
# Drawing the cart manually based on the SVG path logic
# Wheels
r_wheel = 1 * scale
w1_c = scale_pt(7, 20)
draw.ellipse([w1_c[0]-r_wheel, w1_c[1]-r_wheel, w1_c[0]+r_wheel, w1_c[1]+r_wheel], fill="white")
w2_c = scale_pt(17, 20)
draw.ellipse([w2_c[0]-r_wheel, w2_c[1]-r_wheel, w2_c[0]+r_wheel, w2_c[1]+r_wheel], fill="white")
# The main body path
# M1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2z
# Simplified polygon for the cart body
points = [
scale_pt(1, 2), scale_pt(1, 4), scale_pt(3, 4),
scale_pt(6.6, 11.59), scale_pt(5.25, 14.04),
scale_pt(5.25, 15), scale_pt(7, 17), scale_pt(19, 17),
scale_pt(19, 15), scale_pt(7.42, 15), scale_pt(8.35, 13.37),
scale_pt(15.8, 13.37), scale_pt(17.55, 12.34), scale_pt(21.13, 5.85),
scale_pt(21.25, 5.37), scale_pt(20.25, 4.37), scale_pt(5.21, 4.37),
scale_pt(4.27, 2.37)
]
draw.polygon(points, fill="white")
# Save
img.save(path)
create_orange_logo("/home/hololu/calismalar/hMarket/frontend/public/logo512.png", 512)
create_orange_logo("/home/hololu/calismalar/hmarket-logo.png", 512)
img_512 = Image.open("/home/hololu/calismalar/hMarket/frontend/public/logo512.png")
img_192 = img_512.resize((192, 192), Image.LANCZOS)
img_192.save("/home/hololu/calismalar/hMarket/frontend/public/logo192.png")
print("Yeni turuncu logolar oluşturuldu.")