#!/usr/bin/env python3
"""
BTX-Style Boot Logo Generator
Erstellt ein professionelles Boot-Logo im BTX/Bildschirmtext Terminal-Stil
"""

from PIL import Image, ImageDraw, ImageFont
import os

# BTX-typische Farbpalette
BTX_BLACK = (0, 0, 0)
BTX_CYAN = (0, 255, 255)
BTX_MAGENTA = (255, 0, 255)
BTX_YELLOW = (255, 255, 0)
BTX_WHITE = (255, 255, 255)
BTX_GREEN = (0, 255, 0)
BTX_BLUE = (0, 100, 200)
BTX_DARK_CYAN = (0, 180, 180)

# Bildgröße
WIDTH = 800
HEIGHT = 600

# Erstelle Bild
img = Image.new('RGB', (WIDTH, HEIGHT), BTX_BLACK)
draw = ImageDraw.Draw(img)

# Versuche Monospace-Font zu laden (BTX-Style)
try:
    # Verschiedene Monospace-Fonts ausprobieren
    font_paths = [
        '/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf',
        '/usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf',
        '/usr/share/fonts/truetype/liberation2/LiberationMono-Bold.ttf',
        '/System/Library/Fonts/Monaco.ttf',
    ]

    font_large = None
    font_medium = None
    font_small = None

    for font_path in font_paths:
        if os.path.exists(font_path):
            font_large = ImageFont.truetype(font_path, 72)
            font_medium = ImageFont.truetype(font_path, 42)
            font_small = ImageFont.truetype(font_path, 28)
            break

    if not font_large:
        raise Exception("No font found")

except:
    print("Monospace font nicht gefunden, nutze Default-Font")
    font_large = ImageFont.load_default()
    font_medium = ImageFont.load_default()
    font_small = ImageFont.load_default()

# BTX-Style Border (charakteristischer Block-Rahmen)
border_width = 3
for i in range(border_width):
    draw.rectangle([i, i, WIDTH-1-i, HEIGHT-1-i], outline=BTX_CYAN)

# Terminal/Computer ASCII-Art Symbol (oben)
terminal_y = 80
terminal_lines = [
    "╔════════════════╗",
    "║  ▓▓▓▓▓▓▓▓▓▓▓▓  ║",
    "║  ▓░░░░░░░░░░▓  ║",
    "║  ▓░░░░░░░░░░▓  ║",
    "║  ▓▓▓▓▓▓▓▓▓▓▓▓  ║",
    "╚═══════╦╦═══════╝",
    "        ║║        "
]

# Zeichne Terminal-Symbol zentriert
for i, line in enumerate(terminal_lines):
    bbox = draw.textbbox((0, 0), line, font=font_medium)
    text_width = bbox[2] - bbox[0]
    x = (WIDTH - text_width) // 2
    y = terminal_y + (i * 35)
    # Doppelte Zeichen für BTX-Block-Effekt
    draw.text((x+2, y+2), line, font=font_medium, fill=BTX_BLUE)  # Schatten
    draw.text((x, y), line, font=font_medium, fill=BTX_CYAN)

# Haupttext "RDP THIN CLIENT"
main_text = "RDP THIN CLIENT"
bbox = draw.textbbox((0, 0), main_text, font=font_large)
text_width = bbox[2] - bbox[0]
text_x = (WIDTH - text_width) // 2
text_y = 330

# BTX-Style Doppel-Rendering für Glow-Effekt
draw.text((text_x+3, text_y+3), main_text, font=font_large, fill=BTX_BLUE)  # Schatten
draw.text((text_x, text_y), main_text, font=font_large, fill=BTX_YELLOW)

# Scanline-Effekt (BTX/CRT-Monitor-Look)
for y in range(0, HEIGHT, 4):
    draw.line([(border_width+5, y), (WIDTH-border_width-5, y)], fill=(10, 10, 10), width=1)

# Firmen-Branding unten
company_text = "HackerSoft™"
bbox = draw.textbbox((0, 0), company_text, font=font_medium)
text_width = bbox[2] - bbox[0]
company_x = (WIDTH - text_width) // 2
company_y = 470

draw.text((company_x+2, company_y+2), company_text, font=font_medium, fill=BTX_BLUE)
draw.text((company_x, company_y), company_text, font=font_medium, fill=BTX_MAGENTA)

# "Hacker-Net Telekommunikation" Subtext
subtext = "Hacker-Net Telekommunikation"
bbox = draw.textbbox((0, 0), subtext, font=font_small)
text_width = bbox[2] - bbox[0]
sub_x = (WIDTH - text_width) // 2
sub_y = 520

draw.text((sub_x+1, sub_y+1), subtext, font=font_small, fill=BTX_BLUE)
draw.text((sub_x, sub_y), subtext, font=font_small, fill=BTX_DARK_CYAN)

# Dekorative Ecken (BTX-Style Blocks)
block_size = 20
positions = [
    (border_width+10, border_width+10),  # Oben links
    (WIDTH-border_width-30, border_width+10),  # Oben rechts
    (border_width+10, HEIGHT-border_width-30),  # Unten links
    (WIDTH-border_width-30, HEIGHT-border_width-30)  # Unten rechts
]

for x, y in positions:
    draw.rectangle([x, y, x+block_size, y+block_size], fill=BTX_MAGENTA, outline=BTX_YELLOW, width=2)

# Status-Indicator (BTX-typisch)
status_text = "● SYSTEM READY"
bbox = draw.textbbox((0, 0), status_text, font=font_small)
text_width = bbox[2] - bbox[0]
status_x = (WIDTH - text_width) // 2
status_y = HEIGHT - 60

draw.text((status_x+1, status_y+1), status_text, font=font_small, fill=BTX_BLUE)
draw.text((status_x, status_y), status_text, font=font_small, fill=BTX_GREEN)

# Speichern
output_path = os.path.join(os.path.dirname(__file__), 'boot-logo.png')
img.save(output_path, 'PNG')
print(f"BTX-Style Boot-Logo erstellt: {output_path}")
print(f"Größe: {WIDTH}x{HEIGHT}")
