voice-dictation/scripts/make_app_icon.py
Claude Zhenya b96b49f1d5 v0.2.0: режимы обработки, кастомные стили, новая иконка, прослушка звуков
- Реестр режимов постобработки вместо бинарного summary_mode:
  Чистая диктовка, Чистовик (без паразитов), Summary, Переводчик RU→EN,
  Промпт для LLM, Буллеты, Деловое письмо
- Кастомные стили: свои промпты в настройках (таб «Стили»)
- Новая иконка приложения (микрофон + VД)
- Прослушка звуков в настройках (кнопки ▶)
- ffmpeg как опциональная докачка (кнопка в настройках), WAV-fallback без него
- Версия 0.2.0 + changelog в «О программе»
- Фикс: сохранение настроек через dataclasses.replace (не теряет поля)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 22:48:38 +03:00

111 lines
4.1 KiB
Python
Raw Permalink 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.

"""Генератор иконки приложения Voice Dictator.
Микрофон-талисман с усами + монограмма V/Д (Voice Дictator).
Рисуется на скруглённом фоне-градиенте, экспортируется в PNG и .ico.
Запуск:
python scripts/make_app_icon.py
"""
from __future__ import annotations
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
S = 512 # рабочий размер
OUT_DIR = Path(__file__).resolve().parent.parent / "assets"
def _font(size: int) -> ImageFont.FreeTypeFont:
"""Жирный шрифт с поддержкой кириллицы (Segoe UI / Arial)."""
for name in ("segoeuib.ttf", "arialbd.ttf", "ariblk.ttf"):
try:
return ImageFont.truetype(name, size)
except OSError:
continue
return ImageFont.load_default()
def _rounded_gradient(size: int, radius: int) -> Image.Image:
"""Скруглённый квадрат с вертикальным градиентом (брендовый сине-фиолетовый)."""
top = (88, 80, 236) # индиго
bottom = (150, 70, 220) # фиолетовый
grad = Image.new("RGB", (size, size))
px = grad.load()
for y in range(size):
t = y / (size - 1)
px_row = tuple(int(top[i] + (bottom[i] - top[i]) * t) for i in range(3))
for x in range(size):
px[x, y] = px_row
# маска со скруглением
mask = Image.new("L", (size, size), 0)
ImageDraw.Draw(mask).rounded_rectangle((0, 0, size - 1, size - 1), radius=radius, fill=255)
out = Image.new("RGBA", (size, size), (0, 0, 0, 0))
out.paste(grad, (0, 0), mask)
return out
def make_app_icon() -> Image.Image:
img = _rounded_gradient(S, radius=int(S * 0.22))
d = ImageDraw.Draw(img)
white = (255, 255, 255, 255)
dark = (40, 30, 70, 255)
cx = S // 2
# --- Микрофон ---
body_w = int(S * 0.30)
body_h = int(S * 0.40)
body_top = int(S * 0.16)
body_left = cx - body_w // 2
body_right = cx + body_w // 2
body_bottom = body_top + body_h
d.rounded_rectangle(
(body_left, body_top, body_right, body_bottom),
radius=body_w // 2,
fill=white,
)
# решётка микрофона (горизонтальные линии в верхней части капсулы)
for i in range(3):
gy = body_top + int(body_h * 0.18) + i * int(body_h * 0.12)
d.line((body_left + 14, gy, body_right - 14, gy), fill=dark, width=6)
# ножка + основание
d.line((cx, body_bottom, cx, body_bottom + int(S * 0.12)), fill=white, width=14)
base_y = body_bottom + int(S * 0.12)
d.line((cx - int(S * 0.10), base_y, cx + int(S * 0.10), base_y), fill=white, width=14)
# --- Усы (талисман) под решёткой, на капсуле ---
mu_cy = body_top + int(body_h * 0.66)
mu_w = int(body_w * 0.46)
# левый ус — дуга, правый — зеркально
d.arc((cx - mu_w, mu_cy - 22, cx, mu_cy + 30), start=20, end=160, fill=dark, width=14)
d.arc((cx, mu_cy - 22, cx + mu_w, mu_cy + 30), start=20, end=160, fill=dark, width=14)
# закрученные кончики усов
d.ellipse((cx - mu_w - 6, mu_cy - 6, cx - mu_w + 16, mu_cy + 16), fill=dark)
d.ellipse((cx + mu_w - 16, mu_cy - 6, cx + mu_w + 6, mu_cy + 16), fill=dark)
# --- Монограмма V / Д в нижних углах ---
f = _font(int(S * 0.20))
d.text((int(S * 0.10), int(S * 0.70)), "V", font=f, fill=white)
dw = d.textlength("Д", font=f)
d.text((S - int(S * 0.10) - dw, int(S * 0.70)), "Д", font=f, fill=white)
return img
def main() -> None:
OUT_DIR.mkdir(parents=True, exist_ok=True)
icon = make_app_icon()
png_path = OUT_DIR / "app_icon.png"
icon.save(png_path)
# .ico с набором размеров для Windows
ico_path = OUT_DIR / "app_icon.ico"
icon.save(ico_path, sizes=[(256, 256), (128, 128), (64, 64), (48, 48), (32, 32), (16, 16)])
print(f"saved: {png_path}")
print(f"saved: {ico_path}")
if __name__ == "__main__":
main()