"""HatchLing-TuneBox's patriotic themes: colours, background picture, banner and mottoes for the Preset dropdown. The Preset dropdown picks the sheet preset (ling_tiles.PRESETS) and, here, the look of the whole app. """ import base64 import random from functools import lru_cache from pathlib import Path ASSETS = Path(__file__).parent / 'assets' NAME = 'HatchLing-TuneBox' # (label, value): the values are the keys of ling_tiles.PRESETS, plus 'none' LOOKS = [('none – ROYGBIV', 'none'), ('patriotic America', 'patriotic'), ('patriotic Korea – 대한민국', 'korea'), ('patriotic 灵 Ling Country – 天圆,地方', 'ling'), ('patriotic Reitenland', 'reitenland')] INTRO = ('Pictures and Ling programs in, outline-and-crosshatch sheets, globes and music boxes out. ' 'Everything is drawn in the seven Ling hues and hatched with torus, Möbius and tetrahedral line ' 'families set by an ML-DSA-87 signature of the source.') THEMES = { 'none': dict( title='', mottoes=[], bg=None, # ROYGBIV: one dark ground for page and panels, light text, the seven hues as accents flat=True, # LingStationX's palette: primary #005c80, accent #3baaeb, controls #3c3c3c, warning #ff5a40, text #cdd0d8, ground #1b1b1b c=dict(primary='#005c80', primary_hover='#00709c', accent='#3baaeb', text='#cdd0d8', page='#1b1b1b', panel='#1b1b1b', line='#3c3c3c', on_primary='#ffffff', field='#2a2a2a', field_text='#e6e8ee', chip='#3c3c3c', chip_hover='#4a4a4a', scheme='dark', label='#2a2a2a')), 'patriotic': dict( title='E Pluribus Unum', mottoes=['E Pluribus Unum – out of many, one', 'We the People', 'Liberty and Justice for All', 'Putting People First', 'A Bridge to the 21st Century', 'Land of the Free, Home of the Brave'], bg='bg_america.jpg', pos='center top', veil='rgba(10,49,97,.55)', c=dict(primary='#b31942', primary_hover='#8f1434', accent='#0a3161', text='#0a1f3d', page='#0a3161', panel='rgba(255,255,255,.90)', line='#9fb2cf', on_primary='#ffffff')), 'korea': dict( title='대한민국 만세', mottoes=['대한민국 만세! – Long live Korea!', '홍익인간 弘益人間 – Benefit broadly the human world', '무궁화 삼천리 화려강산 – Mugunghwa, three thousand ri of splendid rivers and mountains', '하나된 대한민국 – One Korea, together', '파이팅! – Fighting!', '다이나믹 코리아 – Dynamic Korea', '광복 – Restoration of light'], bg='bg_korea.jpg', pos='center center', veil='rgba(255,255,255,.35)', c=dict(primary='#cd2e3a', primary_hover='#a82430', accent='#0047a0', text='#111111', page='#ffffff', panel='rgba(255,255,255,.92)', line='#0047a0', on_primary='#ffffff')), 'ling': dict( title='灵 天圆,地方 – Heaven is a Circle, Ground is a Square', mottoes=['Heaven is a Circle, Ground is a Square – 天圆,地方', 'Balance · Harmony · Reciprocity', 'Mandate of Balance – nothing carried to excess', 'Mandate of Harmony – many hues, one sheet', 'Mandate of Reciprocity – what is drawn is given back', '和 – Harmony, as in 和をもって貴しとなす', '天下為公 – All under heaven is for all', '为人民服务 – Serve the People', 'ชาติ ศาสนา พระมหากษัตริย์ – Nation, Religion, King', '홍익인간 – Benefit broadly all people'], bg='bg_ling.jpg', pos='center center', veil='rgba(10,17,112,.62)', c=dict(primary='#d4a006', primary_hover='#b58700', accent='#e62b2b', text='#0a1170', page='#0a1170', panel='rgba(255,252,238,.92)', line='#d4a006', on_primary='#0a1170')), # the flag's orange, red and white: three horizontal stripes 'reitenland': dict( title='Reitenland', mottoes=['Orange, Red and White'], bg='bg_reitenland.jpg', pos='center center', veil='rgba(255,255,255,.12)', c=dict(primary='#cc0000', primary_hover='#a30000', accent='#ff8c00', text='#3a0d05', page='#cc0000', panel='rgba(255,255,255,.93)', line='#ff8c00', on_primary='#ffffff')), } @lru_cache(maxsize=None) def _data_uri(name: str) -> str: return 'data:image/jpeg;base64,' + base64.b64encode((ASSETS / name).read_bytes()).decode() def banner(look: str, rng=random) -> str: """Markdown for the top of the app: the name, then the theme's title and a motto.""" th = THEMES.get(look, THEMES['none']) head = '# %s' % NAME + (' \n### %s' % th['title'] if th['title'] else '') if th['mottoes']: head += ' \n*%s*' % rng.choice(th['mottoes']) return head + '\n\n' + INTRO NEUTRALS = {'light': ('#f7f7fa', '#eceef4', '#dde0ea', '#c6cad8', '#8d93a8', '#5a6076', '#424860', '#2e3347', '#1d2133', '#111423'), 'dark': ('#14141f', '#1b1830', '#26233f', '#3a3658', '#6b678f', '#9a97b8', '#bcbad2', '#d6d5e6', '#e9e8f3', '#f4f4ff')} def css(look: str) -> str: """A ' % out