Deelife-TPMS/google-play-release/generate_assets.py

320 lines
17 KiB
Python

import os
import sys
from PIL import Image, ImageDraw, ImageFont
def get_font(size, bold=False):
font_names = ["segoeuib.ttf" if bold else "segoeui.ttf",
"arialbd.ttf" if bold else "arial.ttf",
"tahomabd.ttf" if bold else "tahoma.ttf"]
for name in font_names:
try:
return ImageFont.truetype(name, size)
except:
pass
return ImageFont.load_default()
def draw_rounded_rect(draw, bbox, radius, fill, outline=None, width=1):
draw.rounded_rectangle(bbox, radius=radius, fill=fill, outline=outline, width=width)
def generate_app_icon(output_path):
size = 512
img = Image.new('RGBA', (size, size), (0, 0, 0, 0))
draw = ImageDraw.Draw(img)
# Outer dark rounded rectangle with gradient-like look
pad = 16
draw_rounded_rect(draw, (pad, pad, size - pad, size - pad), radius=100, fill=(22, 26, 36, 255), outline=(40, 50, 70, 255), width=4)
# Inner tire ring graphic
center_x, center_y = size // 2, size // 2 - 20
ring_radius = 140
draw.ellipse((center_x - ring_radius, center_y - ring_radius, center_x + ring_radius, center_y + ring_radius),
fill=(30, 35, 48, 255), outline=(74, 144, 255, 255), width=10)
# Inner hub
hub_r = 75
draw.ellipse((center_x - hub_r, center_y - hub_r, center_x + hub_r, center_y + hub_r),
fill=(16, 20, 28, 255), outline=(0, 230, 118, 255), width=6)
# Sensor wave arcs
for r in [170, 195]:
draw.arc((center_x - r, center_y - r, center_x + r, center_y + r), start=210, end=330, fill=(0, 230, 118, 220), width=6)
# Text "TPMS" inside hub
f_hub = get_font(34, bold=True)
draw.text((center_x, center_y), "TPMS", fill=(255, 255, 255, 255), font=f_hub, anchor="mm")
# Bottom brand label
f_bottom = get_font(38, bold=True)
draw.text((size // 2, size - 85), "DEELIFE", fill=(0, 230, 118, 255), font=f_bottom, anchor="mm")
f_sub = get_font(20, bold=False)
draw.text((size // 2, size - 50), "TYRE MONITOR", fill=(160, 175, 200, 255), font=f_sub, anchor="mm")
img.save(output_path, "PNG")
print(f"Generated App Icon: {output_path}")
def generate_feature_graphic(output_path):
w, h = 1024, 500
img = Image.new('RGB', (w, h), (18, 22, 31))
draw = ImageDraw.Draw(img)
# Gradient accent background shapes
for i in range(120):
alpha = int(35 * (1 - i / 120))
draw.ellipse((w - 200 - i*3, -100 - i*2, w + 300 + i*3, 400 + i*2), outline=(74, 144, 255))
# Title & Subtitle on left
f_brand = get_font(24, bold=True)
draw.text((70, 75), "DEELIFE TPMS", fill=(0, 230, 118), font=f_brand)
f_title = get_font(48, bold=True)
draw.text((70, 120), "Real-Time Tyre Pressure\n& Temperature Monitoring", fill=(255, 255, 255), font=f_title)
f_bullets = get_font(22, bold=False)
bullets = [
"• Instant Audible Alerts for Punctures & Leaks",
"• Plug-and-Play USB Hardware Receiver Support",
"• Continuous Background Service for Automotive Head Units",
"• Customizable Bar/PSI and °C/°F Thresholds"
]
y = 250
for b in bullets:
draw.text((70, y), b, fill=(180, 195, 220), font=f_bullets)
y += 42
# Right-side Mini Card representation
card_w, card_h = 280, 360
card_x, card_y = w - card_w - 70, 70
draw_rounded_rect(draw, (card_x, card_y, card_x + card_w, card_y + card_h), radius=20, fill=(26, 32, 46), outline=(45, 55, 75), width=2)
# Header of card
draw.text((card_x + 25, card_y + 25), "ALL TYRES NORMAL", fill=(0, 230, 118), font=get_font(18, bold=True))
# 4 wheels layout
t_data = [
("FL", "2.3 bar", "25°C", card_x + 25, card_y + 70),
("FR", "2.3 bar", "26°C", card_x + 150, card_y + 70),
("RL", "2.4 bar", "24°C", card_x + 25, card_y + 210),
("RR", "2.4 bar", "25°C", card_x + 150, card_y + 210),
]
for pos, pres, temp, tx, ty in t_data:
draw_rounded_rect(draw, (tx, ty, tx + 105, ty + 120), radius=12, fill=(35, 42, 60))
draw.text((tx + 12, ty + 12), pos, fill=(140, 155, 180), font=get_font(16, bold=True))
draw.text((tx + 12, ty + 42), pres, fill=(255, 255, 255), font=get_font(20, bold=True))
draw.text((tx + 12, ty + 80), temp, fill=(0, 230, 118), font=get_font(16, bold=False))
img.save(output_path, "PNG")
print(f"Generated Feature Graphic: {output_path}")
def generate_phone_screenshot(output_path, mode="dashboard"):
w, h = 1080, 1920
img = Image.new('RGB', (w, h), (18, 22, 31))
draw = ImageDraw.Draw(img)
# Header bar
draw_rounded_rect(draw, (40, 60, w - 40, 160), radius=20, fill=(26, 32, 46))
draw.text((70, 95), "Deelife TPMS", fill=(255, 255, 255), font=get_font(38, bold=True))
status_color = (0, 230, 118) if mode != "alarm" else (255, 85, 85)
status_text = "● USB Receiver Connected" if mode != "alarm" else "⚠️ FAST LEAK DETECTED"
draw.text((w - 70, 95), status_text, fill=status_color, font=get_font(26, bold=True), anchor="ra")
if mode == "dashboard" or mode == "alarm":
# Vehicle container
v_box = (40, 190, w - 40, h - 140)
draw_rounded_rect(draw, v_box, radius=24, fill=(22, 26, 36), outline=(35, 42, 58), width=2)
# Vehicle Silhouette in center
cx, cy = w // 2, 850
draw_rounded_rect(draw, (cx - 110, cy - 350, cx + 110, cy + 350), radius=60, fill=(30, 36, 50), outline=(50, 60, 80), width=3)
# Windshield
draw_rounded_rect(draw, (cx - 85, cy - 200, cx + 85, cy - 90), radius=20, fill=(40, 48, 68))
# Rear window
draw_rounded_rect(draw, (cx - 85, cy + 120, cx + 85, cy + 230), radius=20, fill=(40, 48, 68))
# 4 Tyre Cards
fl_is_alarm = (mode == "alarm")
tyres = [
("FRONT LEFT", "1.4 bar" if fl_is_alarm else "2.3 bar", "38°C" if fl_is_alarm else "25°C", "LOW PRESSURE" if fl_is_alarm else "NORMAL", 70, 400, fl_is_alarm),
("FRONT RIGHT", "2.3 bar", "26°C", "NORMAL", w - 490, 400, False),
("REAR LEFT", "2.4 bar", "24°C", "NORMAL", 70, 1050, False),
("REAR RIGHT", "2.4 bar", "25°C", "NORMAL", w - 490, 1050, False),
]
for name, pres, temp, status, tx, ty, is_alarm in tyres:
bg_col = (50, 25, 25) if is_alarm else (28, 34, 48)
border_col = (255, 85, 85) if is_alarm else (45, 55, 75)
draw_rounded_rect(draw, (tx, ty, tx + 420, ty + 280), radius=20, fill=bg_col, outline=border_col, width=3 if is_alarm else 1)
draw.text((tx + 30, ty + 30), name, fill=(255, 120, 120) if is_alarm else (150, 165, 190), font=get_font(22, bold=True))
p_color = (255, 85, 85) if is_alarm else (255, 255, 255)
draw.text((tx + 30, ty + 80), pres, fill=p_color, font=get_font(56, bold=True))
draw.text((tx + 30, ty + 180), f"Temp: {temp}", fill=(200, 210, 230), font=get_font(26, bold=False))
badge_bg = (255, 50, 50) if is_alarm else (0, 180, 90)
draw_rounded_rect(draw, (tx + 30, ty + 225, tx + 240, ty + 265), radius=10, fill=badge_bg)
draw.text((tx + 135, ty + 245), status, fill=(255, 255, 255), font=get_font(18, bold=True), anchor="mm")
if mode == "alarm":
# Alert banner across center
draw_rounded_rect(draw, (60, 220, w - 60, 360), radius=20, fill=(180, 20, 20), outline=(255, 100, 100), width=3)
draw.text((w // 2, 265), "⚠️ CRITICAL TYRE PRESSURE WARNING", fill=(255, 255, 255), font=get_font(30, bold=True), anchor="mm")
draw.text((w // 2, 315), "Front Left Tyre pressure below safe limit (1.4 bar < 1.8 bar)", fill=(255, 220, 220), font=get_font(22, bold=False), anchor="mm")
# Bottom nav/status bar
draw_rounded_rect(draw, (40, h - 110, w - 40, h - 30), radius=16, fill=(26, 32, 46))
draw.text((w // 4, h - 70), "📊 Live Dashboard", fill=(74, 144, 255), font=get_font(24, bold=True), anchor="mm")
draw.text((3 * w // 4, h - 70), "⚙️ Settings", fill=(150, 165, 190), font=get_font(24, bold=False), anchor="mm")
elif mode == "settings":
draw_rounded_rect(draw, (40, 190, w - 40, h - 140), radius=24, fill=(22, 26, 36))
draw.text((70, 240), "Pressure & Temperature Settings", fill=(255, 255, 255), font=get_font(34, bold=True))
cards = [
("Pressure Display Unit", "BAR (Barometric)", "PSI"),
("Temperature Display Unit", "°C (Celsius)", "°F"),
("Low Pressure Alarm Limit", "1.8 bar (26.1 PSI)", "Default: 1.8"),
("High Pressure Alarm Limit", "3.0 bar (43.5 PSI)", "Default: 3.0"),
("High Temperature Alarm Limit", "65 °C (149 °F)", "Default: 65°C"),
("Background Service Monitoring", "Enabled (Continuously active)", "Auto-start on boot"),
("App Updates", "Google Play Store (Official)", "Auto-checks available")
]
sy = 310
for title, val, hint in cards:
draw_rounded_rect(draw, (70, sy, w - 70, sy + 130), radius=16, fill=(28, 34, 48), outline=(40, 50, 70))
draw.text((100, sy + 25), title, fill=(150, 165, 190), font=get_font(22, bold=False))
draw.text((100, sy + 70), val, fill=(255, 255, 255), font=get_font(28, bold=True))
draw.text((w - 100, sy + 70), hint, fill=(0, 230, 118), font=get_font(22, bold=True), anchor="ra")
sy += 155
# Bottom nav
draw_rounded_rect(draw, (40, h - 110, w - 40, h - 30), radius=16, fill=(26, 32, 46))
draw.text((w // 4, h - 70), "📊 Live Dashboard", fill=(150, 165, 190), font=get_font(24, bold=False), anchor="mm")
draw.text((3 * w // 4, h - 70), "⚙️ Settings", fill=(74, 144, 255), font=get_font(24, bold=True), anchor="mm")
elif mode == "pairing":
draw_rounded_rect(draw, (40, 190, w - 40, h - 140), radius=24, fill=(22, 26, 36))
draw.text((70, 240), "Sensor Pairing Wizard", fill=(255, 255, 255), font=get_font(34, bold=True))
draw.text((70, 290), "Pair or replace external tyre pressure sensors wirelessly.", fill=(160, 175, 200), font=get_font(22, bold=False))
# Vehicle wheels selection
wheels = [
("Front Left (FL)", "Sensor ID: 8A4C21", True, 70, 360),
("Front Right (FR)", "Sensor ID: 8A4C22", True, w - 490, 360),
("Rear Left (RL)", "Sensor ID: 8A4C23", True, 70, 680),
("Rear Right (RR)", "Tap to Pair...", False, w - 490, 680),
]
for w_title, w_desc, paired, wx, wy in wheels:
bg_col = (28, 36, 52) if paired else (40, 48, 68)
border_col = (0, 230, 118) if paired else (74, 144, 255)
draw_rounded_rect(draw, (wx, wy, wx + 420, wy + 260), radius=20, fill=bg_col, outline=border_col, width=2)
draw.text((wx + 30, wy + 35), w_title, fill=(255, 255, 255), font=get_font(26, bold=True))
draw.text((wx + 30, wy + 90), w_desc, fill=(0, 230, 118) if paired else (74, 144, 255), font=get_font(24, bold=True))
status_lbl = "✓ PAIRED" if paired else "+ PAIR NOW"
draw_rounded_rect(draw, (wx + 30, wy + 160, wx + 230, wy + 220), radius=10, fill=(0, 180, 90) if paired else (74, 144, 255))
draw.text((wx + 130, wy + 190), status_lbl, fill=(255, 255, 255), font=get_font(20, bold=True), anchor="mm")
# Instruction Box
draw_rounded_rect(draw, (70, 1020, w - 70, 1420), radius=20, fill=(28, 34, 48))
draw.text((100, 1060), "Pairing Instructions:", fill=(255, 255, 255), font=get_font(28, bold=True))
steps = [
"1. Plug the Deelife USB receiver into the car's Android USB port.",
"2. Select the tyre position you wish to pair above.",
"3. Screw the sensor onto the valve stem or deflate slightly.",
"4. The app detects the sensor signal and saves the ID automatically."
]
sy = 1130
for s in steps:
draw.text((100, sy), s, fill=(180, 195, 220), font=get_font(22, bold=False))
sy += 65
# Bottom nav
draw_rounded_rect(draw, (40, h - 110, w - 40, h - 30), radius=16, fill=(26, 32, 46))
draw.text((w // 4, h - 70), "📊 Live Dashboard", fill=(150, 165, 190), font=get_font(24, bold=False), anchor="mm")
draw.text((3 * w // 4, h - 70), "⚙️ Settings", fill=(74, 144, 255), font=get_font(24, bold=True), anchor="mm")
img.save(output_path, "PNG")
print(f"Generated Screenshot: {output_path}")
def generate_landscape_screenshot(output_path, mode="dashboard"):
w, h = 1920, 1080
img = Image.new('RGB', (w, h), (18, 22, 31))
draw = ImageDraw.Draw(img)
# Top bar
draw_rounded_rect(draw, (40, 30, w - 40, 110), radius=16, fill=(26, 32, 46))
draw.text((70, 52), "Deelife TPMS — Android Automotive Head Unit Display", fill=(255, 255, 255), font=get_font(30, bold=True))
st_col = (0, 230, 118) if mode != "alarm" else (255, 85, 85)
st_text = "● USB Receiver Connected · All 4 Sensors Active" if mode != "alarm" else "⚠️ CRITICAL ALERT: FAST TYRE LEAK"
draw.text((w - 70, 52), st_text, fill=st_col, font=get_font(24, bold=True), anchor="ra")
# Center Car Silhouette
cx, cy = w // 2, 580
draw_rounded_rect(draw, (cx - 150, cy - 350, cx + 150, cy + 350), radius=70, fill=(30, 36, 50), outline=(50, 60, 80), width=3)
draw_rounded_rect(draw, (cx - 110, cy - 200, cx + 110, cy - 80), radius=20, fill=(40, 48, 68))
draw_rounded_rect(draw, (cx - 110, cy + 120, cx + 110, cy + 240), radius=20, fill=(40, 48, 68))
is_alarm = (mode == "alarm")
tyres = [
("FRONT LEFT", "1.4 bar" if is_alarm else "2.3 bar", "39°C" if is_alarm else "25°C", "LOW PRESSURE" if is_alarm else "NORMAL", 80, 160, is_alarm),
("FRONT RIGHT", "2.3 bar", "26°C", "NORMAL", w - 580, 160, False),
("REAR LEFT", "2.4 bar", "24°C", "NORMAL", 80, 580, False),
("REAR RIGHT", "2.4 bar", "25°C", "NORMAL", w - 580, 580, False),
]
for name, pres, temp, status, tx, ty, t_alarm in tyres:
bg_col = (50, 25, 25) if t_alarm else (26, 32, 46)
border_col = (255, 85, 85) if t_alarm else (45, 55, 75)
draw_rounded_rect(draw, (tx, ty, tx + 500, ty + 380), radius=24, fill=bg_col, outline=border_col, width=3 if t_alarm else 1)
draw.text((tx + 40, ty + 40), name, fill=(255, 120, 120) if t_alarm else (150, 165, 190), font=get_font(24, bold=True))
p_color = (255, 85, 85) if t_alarm else (255, 255, 255)
draw.text((tx + 40, ty + 100), pres, fill=p_color, font=get_font(72, bold=True))
draw.text((tx + 40, ty + 240), f"Temperature: {temp}", fill=(200, 210, 230), font=get_font(28, bold=False))
badge_bg = (255, 50, 50) if t_alarm else (0, 180, 90)
draw_rounded_rect(draw, (tx + 40, ty + 300, tx + 260, ty + 345), radius=10, fill=badge_bg)
draw.text((tx + 150, ty + 322), status, fill=(255, 255, 255), font=get_font(20, bold=True), anchor="mm")
if mode == "alarm":
# Alert banner
draw_rounded_rect(draw, (cx - 450, 130, cx + 450, 220), radius=16, fill=(200, 30, 30), outline=(255, 100, 100), width=2)
draw.text((cx, 175), "⚠️ AUDIBLE LEAK ALARM SOUNDING", fill=(255, 255, 255), font=get_font(26, bold=True), anchor="mm")
# Bottom info strip
draw_rounded_rect(draw, (40, h - 70, w - 40, h - 20), radius=12, fill=(26, 32, 46))
draw.text((70, h - 45), "Background Monitoring Active · Auto-launches on Ignition / USB attach", fill=(140, 155, 180), font=get_font(18, bold=False), anchor="la")
draw.text((w - 70, h - 45), "Units: BAR / °C · Thresholds: 1.8 - 3.0 BAR", fill=(74, 144, 255), font=get_font(18, bold=True), anchor="ra")
img.save(output_path, "PNG")
print(f"Generated Landscape Screenshot: {output_path}")
def main():
base_dir = os.path.dirname(os.path.abspath(__file__))
graphics_dir = os.path.join(base_dir, "graphics")
screenshots_dir = os.path.join(graphics_dir, "screenshots")
os.makedirs(screenshots_dir, exist_ok=True)
generate_app_icon(os.path.join(graphics_dir, "app_icon_512x512.png"))
generate_feature_graphic(os.path.join(graphics_dir, "feature_graphic_1024x500.png"))
# Phone screenshots
generate_phone_screenshot(os.path.join(screenshots_dir, "phone_1_dashboard.png"), mode="dashboard")
generate_phone_screenshot(os.path.join(screenshots_dir, "phone_2_alarm.png"), mode="alarm")
generate_phone_screenshot(os.path.join(screenshots_dir, "phone_3_settings.png"), mode="settings")
generate_phone_screenshot(os.path.join(screenshots_dir, "phone_4_pairing.png"), mode="pairing")
# Tablet / Automotive landscape screenshots
generate_landscape_screenshot(os.path.join(screenshots_dir, "tablet_landscape_1_dashboard.png"), mode="dashboard")
generate_landscape_screenshot(os.path.join(screenshots_dir, "tablet_landscape_2_alarm.png"), mode="alarm")
if __name__ == "__main__":
main()