JA
apps/winzik / tools / skins / themes.py · commit 6576d6f
"""The glass skins of WinZik made from one drawing with a theme each (the way of "Givre": a case with a fine grain and adecoration of its own, glossy buttons, dark windows with lit digits): Aurore, Corail, Menthe, Ambre and Sakura.Drawn from scratch, pixel by pixel (no picture copied, no logo).Run (from the winzik-jumphp folder): python3 -I apps/winzik/tools/skins/themes.py <theme> apps/winzik/assets/skins/<theme>"""import mathimport osimport randomimport sysfrom PIL import Image, ImageDraw, ImageFontsys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))import badges  # noqa: E402import pixelfont  # noqa: E402THEMES = {    # the northern lights: a night-blue case, green and violet veils, violet glass    'aurore': dict(title='Aurore', case_top=(40, 46, 78), case_bottom=(22, 24, 48), silver=(96, 104, 150), silver_dark=(70, 76, 120),                   hi=(150, 160, 210), lcd_top=(10, 14, 30), lcd_bottom=(4, 6, 16), lcd_grid=(18, 26, 48), lit=(120, 255, 190),                   dim=(80, 170, 140), ink=(28, 20, 60), glass_top=(214, 200, 255), glass_bottom=(140, 116, 220),                   on_top=(200, 255, 230), on_bottom=(80, 220, 160), grain=4, sparkle=(200, 230, 255), decor='aurora',                   rows=((120, 255, 190), (190, 150, 255)), bars=((80, 230, 170), (170, 130, 255), (255, 110, 170)), playing=(255, 255, 255)),    # warm coral and sand: a sunny beach    'corail': dict(title='Corail', case_top=(255, 238, 222), case_bottom=(246, 206, 180), silver=(206, 150, 128), silver_dark=(172, 112, 96),                   hi=(255, 255, 255), lcd_top=(70, 30, 34), lcd_bottom=(40, 14, 20), lcd_grid=(84, 40, 44), lit=(255, 190, 150),                   dim=(220, 130, 110), ink=(110, 40, 40), glass_top=(255, 226, 214), glass_bottom=(250, 150, 130),                   on_top=(255, 244, 200), on_bottom=(255, 196, 90), grain=3, sparkle=(255, 250, 240), decor='waves',                   rows=((255, 200, 160), (255, 160, 150)), bars=((255, 170, 120), (255, 230, 170), (255, 90, 90)), playing=(255, 255, 255)),    # mint and fresh leaves    'menthe': dict(title='Menthe', case_top=(232, 250, 240), case_bottom=(186, 230, 208), silver=(120, 176, 150), silver_dark=(84, 140, 116),                   hi=(255, 255, 255), lcd_top=(14, 52, 42), lcd_bottom=(6, 30, 24), lcd_grid=(20, 66, 52), lit=(170, 255, 210),                   dim=(110, 200, 160), ink=(20, 80, 60), glass_top=(222, 252, 236), glass_bottom=(130, 214, 172),                   on_top=(250, 255, 210), on_bottom=(190, 236, 90), grain=3, sparkle=(255, 255, 255), decor='leaves',                   rows=((170, 255, 210), (200, 240, 160)), bars=((110, 230, 170), (220, 255, 200), (255, 120, 120)), playing=(255, 255, 255)),    # dark amber, a valve amplifier at night    'ambre': dict(title='Ambre', case_top=(58, 42, 30), case_bottom=(30, 20, 14), silver=(140, 104, 70), silver_dark=(104, 74, 48),                  hi=(190, 150, 100), lcd_top=(26, 14, 4), lcd_bottom=(12, 6, 2), lcd_grid=(40, 22, 8), lit=(255, 176, 60),                  dim=(200, 120, 40), ink=(60, 30, 6), glass_top=(255, 220, 160), glass_bottom=(214, 140, 50),                  on_top=(255, 244, 200), on_bottom=(255, 200, 80), grain=4, sparkle=(255, 210, 140), decor='glow',                  rows=((255, 186, 90), (240, 150, 70)), bars=((255, 160, 40), (255, 220, 120), (255, 80, 40)), playing=(255, 240, 200)),    # cherry blossom: pale pink, petals falling    'sakura': dict(title='Sakura', case_top=(255, 240, 246), case_bottom=(246, 210, 226), silver=(206, 150, 176), silver_dark=(170, 110, 140),                   hi=(255, 255, 255), lcd_top=(60, 24, 48), lcd_bottom=(34, 10, 28), lcd_grid=(76, 34, 60), lit=(255, 190, 220),                   dim=(220, 130, 170), ink=(110, 40, 80), glass_top=(255, 232, 244), glass_bottom=(240, 160, 200),                   on_top=(255, 250, 230), on_bottom=(255, 160, 200), grain=3, sparkle=(255, 255, 255), decor='petals',                   rows=((255, 200, 226), (230, 180, 255)), bars=((255, 150, 200), (255, 230, 240), (200, 60, 120)), playing=(255, 255, 255)),}NAME = sys.argv[1] if len(sys.argv) > 1 else 'aurore'T = THEMES[NAME]OUT = sys.argv[2] if len(sys.argv) > 2 else 'assets/skins/' + NAMEos.makedirs(OUT, exist_ok=True)CASE_TOP = T['case_top']CASE_BOTTOM = T['case_bottom']SILVER = T['silver']SILVER_DARK = T['silver_dark']WHITE = (255, 255, 255)HI = T['hi']NAVY_TOP = T['lcd_top']NAVY_BOTTOM = T['lcd_bottom']NAVY_GRID = T['lcd_grid']ICE = T['lit']ICE_DIM = T['dim']INK = T['ink']GLASS_TOP = T['glass_top']GLASS_BOTTOM = T['glass_bottom']S = 4                                                   # supersampling of the glass piecesFONTS = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'assets', 'fonts')def font(size, bold=True):    """The app's own font (ui-bold.ttf / ui.ttf), else Pillow's."""    try:        return ImageFont.truetype(os.path.join(FONTS, 'ui-bold.ttf' if bold else 'ui.ttf'), size)    except OSError:        try:            return ImageFont.load_default(size=size)        except TypeError:            return ImageFont.load_default()def new(w, h, color=(0, 0, 0, 0)):    return Image.new('RGBA', (w, h), color)def save(im, name):    im.save(os.path.join(OUT, name + '.png'))def mix(a, b, t):    return tuple(int(round(a[i] * (1 - t) + b[i] * t)) for i in range(len(a)))def text(d, xy, s, size=8, fill=INK, anchor='la', bold=True):    if size <= 8:        # small texts: a pixel font (whole pixels, sharp: an anti-aliased TTF blurs at this size)        pixelfont.draw(d._image, (int(xy[0]), int(xy[1])), s.upper(), fill, pixelfont.F5 if size >= 7 else pixelfont.F3, anchor)        return    d.fontmode = 'L'    d.text(xy, s, font=font(size, bold), fill=fill, anchor=anchor)# --- the case: a vertical gradient, a frost grain, sparkles, frost ferns ----------------------------------------------def case(w, h, seed, calm=None):    """calm = (y0, y1): rows left without grain (the band of the play list that is stretched)."""    rnd = random.Random(seed)    im = new(w, h, CASE_TOP + (255,))    g = T['grain']    px = im.load()    for y in range(h):        base = mix(CASE_TOP, CASE_BOTTOM, y / max(1, h - 1))        quiet = calm is not None and calm[0] <= y < calm[1]        for x in range(w):            if quiet:                px[x, y] = base + (255,)                continue            n = rnd.randint(-g, g)            c = tuple(max(0, min(255, base[i] + n + (1 if i == 2 else 0))) for i in range(3))            if rnd.random() < 0.012:                c = mix(c, T['sparkle'], 0.6)            # a sparkle            px[x, y] = c + (255,)    return imdef fern(im, x, y, angle, length, depth, seed, alpha=110):    """A frost fern: a stem with short side branches, each branching again (drawn in white, translucent)."""    rnd = random.Random(seed)    layer = new(im.width, im.height)    d = ImageDraw.Draw(layer)    def branch(x0, y0, a, l, n):        if l < 2 or n < 0:            return        x1 = x0 + math.cos(a) * l        y1 = y0 + math.sin(a) * l        d.line([(x0, y0), (x1, y1)], fill=(255, 255, 255, alpha))        steps = max(2, int(l / 4))        for i in range(1, steps):            t = i / steps            bx, by = x0 + (x1 - x0) * t, y0 + (y1 - y0) * t            side = l * (1 - t) * 0.45 * (0.8 + rnd.random() * 0.4)            branch(bx, by, a - 1.0, side, n - 1)            branch(bx, by, a + 1.0, side, n - 1)    branch(x, y, angle, length, depth)    im.alpha_composite(layer)def decor(im, spots, seed):    """The theme's own decoration at a few spots [(x, y, size)] of a case."""    rnd = random.Random(seed)    layer = new(im.width, im.height)    d = ImageDraw.Draw(layer)    kind = T['decor']    for (x, y, size) in spots:        if kind == 'aurora':            # veils of light: soft vertical streaks, green to violet            for i in range(int(size * 2)):                xx = x + i - size                h = size * (0.6 + 0.4 * math.sin(i * 0.35 + seed))                col = mix((80, 255, 170), (170, 110, 255), i / max(1, size * 2))                for yy in range(int(h)):                    a = int(70 * (1 - yy / max(1, h)))                    d.point((xx, y - yy + 6 * math.sin((xx + seed) * 0.08)), fill=col + (a,))        elif kind == 'waves':            for k in range(3):                pts = [(x + i - size, y - k * 4 + 2 * math.sin((i + k * 7) * 0.4)) for i in range(int(size * 2))]                d.line(pts, fill=(255, 255, 255, 120 - k * 30))        elif kind == 'leaves':            for k in range(3):                a = rnd.uniform(0, math.pi * 2)                lx, ly = x + rnd.uniform(-size, size) * 0.6, y + rnd.uniform(-size, size) * 0.4                l = size * 0.5                tip = (lx + math.cos(a) * l, ly + math.sin(a) * l)                n = (math.cos(a + math.pi / 2) * l * 0.3, math.sin(a + math.pi / 2) * l * 0.3)                mid = ((lx + tip[0]) / 2, (ly + tip[1]) / 2)                d.polygon([(lx, ly), (mid[0] + n[0], mid[1] + n[1]), tip, (mid[0] - n[0], mid[1] - n[1])], fill=(90, 190, 130, 70))                d.line([(lx, ly), tip], fill=(255, 255, 255, 90))        elif kind == 'glow':            # the warm glow of a valve under the case            for r in range(int(size), 0, -1):                a = int(36 * (1 - r / size))                d.ellipse([x - r * 1.6, y - r, x + r * 1.6, y + r], fill=(255, 150, 40, a))        elif kind == 'petals':            for k in range(4):                px_, py_ = x + rnd.uniform(-size, size), y + rnd.uniform(-size, size) * 0.5                a = rnd.uniform(0, math.pi)                for p in range(5):                    b = a + p * 2 * math.pi / 5                    cx_, cy_ = px_ + math.cos(b) * 2.2, py_ + math.sin(b) * 2.2                    d.ellipse([cx_ - 1.8, cy_ - 1.8, cx_ + 1.8, cy_ + 1.8], fill=(255, 170, 200, 120))                d.point((px_, py_), fill=(255, 230, 120, 200))    im.alpha_composite(layer)def outline(d, x0, y0, x1, y1):    """The case's thin silver edge, a white light inside it."""    d.rectangle([x0, y0, x1, y1], outline=SILVER)    d.line([(x0 + 1, y0 + 1), (x1 - 1, y0 + 1)], fill=HI)    d.line([(x0 + 1, y0 + 1), (x0 + 1, y1 - 1)], fill=mix(HI, CASE_TOP, 0.3))    d.line([(x0 + 1, y1 - 1), (x1 - 1, y1 - 1)], fill=mix(SILVER, CASE_BOTTOM, 0.4))    d.line([(x1 - 1, y0 + 1), (x1 - 1, y1 - 1)], fill=mix(SILVER, CASE_BOTTOM, 0.3))def lcd(im, x, y, w, h, grid=False, fade=None):    """A navy window: silver ring around it, a navy gradient, a faint glass reflection on its top."""    d = ImageDraw.Draw(im)    d.rectangle([x - 1, y - 1, x + w, y + h], outline=SILVER_DARK)    d.line([(x - 1, y + h), (x + w, y + h)], fill=HI)    d.line([(x + w, y - 1), (x + w, y + h)], fill=mix(HI, CASE_BOTTOM, 0.3))    for yy in range(y, y + h):        d.line([(x, yy), (x + w - 1, yy)], fill=mix(NAVY_TOP, NAVY_BOTTOM, min(1, (yy - y) / max(1, (fade or h) - 1))))    d.line([(x, y), (x + w - 1, y)], fill=mix(NAVY_TOP, ICE_DIM, 0.3))    if grid:        for gy in range(y + 1, y + h, 2):            for gx in range(x + 1, x + w, 2):                d.point((gx, gy), fill=NAVY_GRID)def groove(d, x0, y0, x1):    """Two fine silver lines carved in the case (a decoration)."""    d.line([(x0, y0), (x1, y0)], fill=mix(SILVER, CASE_TOP, 0.4))    d.line([(x0, y0 + 1), (x1, y0 + 1)], fill=HI)# --- glass: glossy pieces drawn 4 times bigger then reduced (smooth edges) ----------------------------------------def gradient(w, h, top, bottom):    g = new(w, h)    d = ImageDraw.Draw(g)    for y in range(h):        d.line([(0, y), (w - 1, y)], fill=mix(top, bottom, y / max(1, h - 1)))    return gdef glass(w, h, radius=3, top=GLASS_TOP, bottom=GLASS_BOTTOM, edge=SILVER_DARK, draw=None):    """A candy-glass piece: a cool gradient, a bright sheen on the top half (sharp lower edge), a glow at the bottom.    draw(d, k) draws the symbol on the big picture (k = the scale)."""    W, H, R = w * S, h * S, radius * S    mask = Image.new('L', (W, H), 0)    ImageDraw.Draw(mask).rounded_rectangle([0, 0, W - 1, H - 1], R, fill=255)    body = gradient(W, H, top + (255,), bottom + (255,))    # the sheen: the top half, white fading downwards, its lower edge straight    sheen = new(W, H)    sd = ImageDraw.Draw(sheen)    half = int(H * 0.5)    for y in range(S, half):        t = (y - S) / max(1, half - S)        sd.line([(S, y), (W - 1 - S, y)], fill=(255, 255, 255, int(190 - 110 * t)))    smask = Image.new('L', (W, H), 0)    ImageDraw.Draw(smask).rounded_rectangle([S + S // 2, S, W - 1 - S - S // 2, half + R], max(S, R - S), fill=255)    ImageDraw.Draw(smask).rectangle([0, half, W, H], fill=0)    sheen.putalpha(Image.composite(sheen.getchannel('A'), Image.new('L', (W, H), 0), smask))    body.alpha_composite(sheen)    # the glow at the bottom: light passing through the glass    glow = new(W, H)    gd = ImageDraw.Draw(glow)    for i in range(H - half):        y = H - 1 - S - i        if y < half:            break        a = int(110 * max(0.0, 1 - i / ((H - half) * 0.8)))        gd.line([(2 * S, y), (W - 1 - 2 * S, y)], fill=(236, 248, 255, a))    body.alpha_composite(glow)    d = ImageDraw.Draw(body, 'RGBA')    d.rounded_rectangle([0, 0, W - 1, H - 1], R, outline=edge + (255,), width=S)    d.rounded_rectangle([S, S, W - 1 - S, H - 1 - S], max(S, R - S), outline=(255, 255, 255, 120), width=max(1, S // 2))    if draw:        draw(d, S)    body.putalpha(Image.composite(body.getchannel('A'), Image.new('L', (W, H), 0), mask))    return body.resize((w, h), Image.LANCZOS)def glyph(d, kind, cx, cy, color, k):    """The transport symbols, at the scale k."""    def P(pts):        d.polygon([(cx + px * k, cy + py * k) for px, py in pts], fill=color)    def R(x0, y0, x1, y1):        d.rectangle([cx + x0 * k, cy + y0 * k, cx + x1 * k - 1, cy + y1 * k - 1], fill=color)    if kind == 'prev':        R(-6, -4, -4, 4)        P([(1, -4), (1, 4), (-4, 0)])        P([(6, -4), (6, 4), (1, 0)])    elif kind == 'next':        P([(-6, -4), (-6, 4), (-1, 0)])        P([(-1, -4), (-1, 4), (4, 0)])        R(4, -4, 6, 4)    elif kind == 'play':        P([(-3, -5), (-3, 5), (5, 0)])    elif kind == 'pause':        R(-4, -4, -1, 4)        R(1, -4, 4, 4)    elif kind == 'stop':        R(-4, -4, 4, 4)    elif kind == 'eject':        P([(-5, 1), (5, 1), (0, -5)])        R(-5, 3, 5, 5)    elif kind == 'down':        P([(-4, -2), (4, -2), (0, 3)])    elif kind == 'chevron':        P([(-5, -3), (-3, -3), (0, 1), (3, -3), (5, -3), (0, 3)])def symbol(kind=None, label=None, size=8, color=INK, dy=0):    """The draw() of glass(): the symbol with a white light under it (engraved in the glass)."""    def draw(d, k):        w, h = d.im.size        cx, cy = w / 2, h / 2 + dy * k        for off, col in [(k, (255, 255, 255, 170)), (0, color + (255,))]:            if kind:                glyph(d, kind, cx, cy + off, col, k)            if label:                d.text((cx, cy + off), label, font=font(size * k), fill=col, anchor='mm')    return drawdef button(w, h, kind=None, label=None, size=8, top=GLASS_TOP, bottom=GLASS_BOTTOM, color=INK, radius=3, dy=0):    return glass(w, h, radius, top, bottom, draw=symbol(kind, label, size, color, dy))AQUA_TOP = T['on_top']AQUA_BOTTOM = T['on_bottom']                          # a lit button (Hasard on, the list mode)# --- the player (main.png, 258 x 128: 99 shown, 128 opened) -------------------------------------------------------main = case(258, 128, 1)decor(main, [(22, 118, 18), (236, 92, 14), (110, 124, 12)], 11)d = ImageDraw.Draw(main)outline(d, 0, 0, 257, 127)groove(d, 28, 4, 43)groove(d, 28, 8, 43)groove(d, 213, 4, 221)groove(d, 213, 8, 221)lcd(main, 47, 1, 163, 12)                         # the scrolling titlelcd(main, 27, 17, 197, 12, grid=True)             # the bargraphlcd(main, 0, 31, 70, 13)                          # "Volume : xx %"lcd(main, 112, 31, 32, 13)                        # kbpslcd(main, 186, 31, 70, 13)                        # "Balance : x %"lcd(main, 0, 81, 56, 17, grid=True)               # the counterd = ImageDraw.Draw(main)text(d, (148, 37), 'kbps', 6, mix(INK, SILVER_DARK, 0.3) if sum(CASE_TOP) > 380 else ICE_DIM, 'lm')    # dark on a light case: it reads# the socket of the light between the two slidersd.ellipse([121, 46, 133, 58], fill=SILVER)d.ellipse([122, 47, 132, 57], fill=NAVY_BOTTOM)d.arc([121, 46, 133, 58], 20, 200, fill=WHITE)# the hidden button that opens the bottom: a small glass key with a chevronmain.alpha_composite(glass(25, 18, 3, draw=symbol('chevron', color=INK)), (232, 76))# the bottom part: a frost plate with an ice crystal, a small LCDgroove(d, 4, 100, 253)lcd(main, 126, 106, 126, 17)d = ImageDraw.Draw(main)crystal = new(258 * S, 128 * S)cd = ImageDraw.Draw(crystal)cx, cy = 22 * S, 114 * Scd.ellipse([cx - 9 * S, cy - 9 * S, cx + 9 * S, cy + 9 * S], fill=ICE_DIM + (255,), outline=SILVER_DARK + (255,), width=S)cd.ellipse([cx - 3 * S, cy - 3 * S, cx + 3 * S, cy + 3 * S], fill=NAVY_BOTTOM + (255,))cd.arc([cx - 7 * S, cy - 7 * S, cx + 7 * S, cy + 7 * S], 200, 300, fill=(255, 255, 255, 200), width=S)crystal = crystal.resize((258, 128), Image.LANCZOS)main.alpha_composite(crystal)d = ImageDraw.Draw(main)text(d, (40, 110), 'WINZIK', 9, mix(INK, CASE_TOP, 0.15) if sum(CASE_TOP) > 380 else ICE, 'lm')text(d, (41, 120), T['title'], 8, SILVER_DARK if sum(CASE_TOP) > 380 else ICE_DIM, 'lm')save(main, 'main')# the buttons of the playersave(button(25, 17, label='H'), 'hd')save(button(25, 17, label='H', top=AQUA_TOP, bottom=AQUA_BOTTOM), 'he')save(button(25, 17, label='?'), 'info')save(button(15, 15, label='_', dy=-2), 'petit')save(button(17, 15, label='x', dy=-1), 'close')save(button(17, 15, kind='down'), 'tray')save(button(17, 15, label='L'), 'lyr')for name, kind in [('barr', 'prev'), ('bpause', 'pause'), ('bplay', 'play'), ('bstop', 'stop'), ('bav', 'next')]:    save(button(25, 18, kind), name)save(button(25, 18, label='PL', size=8), 'bpl')# the sliders: a navy groove, a frosted light that growsdef track(w, h, light):    im = new(w, h)    dd = ImageDraw.Draw(im)    dd.rounded_rectangle([0, 1, w - 1, h - 2], 3, fill=SILVER_DARK)    dd.rounded_rectangle([1, 2, w - 2, h - 3], 2, fill=NAVY_BOTTOM)    for x in range(3, w - 3):        t = (x - 3) / (w - 7)        c = light(t)        dd.line([(x, 4), (x, h - 5)], fill=c)    dd.line([(2, h - 2), (w - 3, h - 2)], fill=WHITE)    return imsave(track(116, 10, lambda t: mix(NAVY_TOP, ICE, t)), 'fbson')save(track(116, 10, lambda t: mix(NAVY_TOP, ICE, 1 - abs(t - .5) * 2)), 'fbbal')pos = track(255, 10, lambda t: mix(NAVY_BOTTOM, ICE_DIM, 0.2))pd = ImageDraw.Draw(pos)for x in range(8, 250, 12):    pd.point((x, 4), fill=ICE_DIM)save(pos, 'fpos')for name, top, bottom in [('bson', GLASS_TOP, GLASS_BOTTOM), ('bbal', GLASS_TOP, GLASS_BOTTOM), ('bpos', AQUA_TOP, AQUA_BOTTOM)]:    def notch(d, k):        w, h = d.im.size        d.line([(w / 2, 2 * k), (w / 2, h - 2 * k)], fill=INK + (255,), width=k)    save(glass(17, 9, 4, top, bottom, draw=notch), name)# --- the play list (mainpl.png, 258 x 362; the 40 rows above the last 26 are stretched) ------------------------------BAND = (296, 336)pl = case(258, 362, 2, calm=(BAND[0] - 6, BAND[1]))decor(pl, [(16, 30, 12), (240, 30, 12)], 21)d = ImageDraw.Draw(pl)outline(d, 0, 0, 257, 361)groove(d, 28, 5, 84)groove(d, 28, 10, 84)groove(d, 174, 5, 228)groove(d, 174, 10, 228)groove(d, 28, 22, 116)groove(d, 149, 22, 228)# the title platelcd(pl, 60, 35, 138, 10)d = ImageDraw.Draw(pl)text(d, (129, 40), 'LISTE DE LECTURE', 7, ICE, 'mm')# the list and its scroll track; the status tab (the number of files) hangs under the listlcd(pl, 1, 48, 246, 302, fade=60)            # flat below its top: it is stretched or cutlcd(pl, 249, 48, 8, 297)d = ImageDraw.Draw(pl)# the status tab under the list (WinZik writes the number of files there): the list's own navy, opened into itd.rectangle([45, 347, 212, 360], fill=SILVER_DARK)d.rectangle([46, 347, 211, 359], fill=NAVY_BOTTOM)d.line([(46, 360), (212, 360)], fill=HI)d.line([(212, 351), (212, 360)], fill=HI)# the resize grips: a triangle of frost beads in each bottom corner (the grips are 16 x 12)for right in (False, True):    for dx, dy in [(0, 0), (4, 0), (8, 0), (4, -4), (8, -4), (8, -8)]:        x = 244 + dx if right else 11 - dx        y = 358 + dy        d.rectangle([x, y, x + 1, y + 1], fill=SILVER_DARK)        d.point((x, y), fill=HI)        d.point((x + 2, y + 2), fill=mix(SILVER, CASE_BOTTOM, 0.4))save(pl, 'mainpl')for name, label in [('plp', '+'), ('plm', '-'), ('plload', 'L'), ('plsave', 'S')]:    save(button(25, 17, label=label, size=10), name)def bin_icon(d, k):    w, h = d.im.size    cx, cy = w / 2, h / 2    for off, col in [(k, (255, 255, 255, 170)), (0, INK + (255,))]:        d.rectangle([cx - 3 * k, cy - 2 * k + off, cx + 3 * k, cy + 4 * k + off], outline=col, width=k)        d.line([(cx - 4 * k, cy - 3 * k + off), (cx + 4 * k, cy - 3 * k + off)], fill=col, width=k)        d.line([(cx - 1 * k, cy - 4 * k + off), (cx + 1 * k, cy - 4 * k + off)], fill=col, width=k)        d.line([(cx, cy - 1 * k + off), (cx, cy + 3 * k + off)], fill=col, width=k)save(glass(25, 17, 3, draw=bin_icon), 'plrem')save(button(82, 16, label='MODE ÉDITION', size=8), 'pledit')save(button(82, 16, label='MODE LISTE', size=8, top=AQUA_TOP, bottom=AQUA_BOTTOM), 'pledit2')# the scroll bar: its track and its thumbtrk = new(8, 296, NAVY_BOTTOM + (255,))td = ImageDraw.Draw(trk)td.line([(3, 2), (3, 293)], fill=mix(NAVY_BOTTOM, ICE_DIM, 0.3))td.line([(4, 2), (4, 293)], fill=mix(NAVY_BOTTOM, ICE_DIM, 0.15))save(trk, 'posplay')save(glass(8, 17, 3, AQUA_TOP, AQUA_BOTTOM), 'btnplay')# the icons of the lines: the kind of file, the lyrics# (the 3x5 font of badges.py: the 5-pixel one is too wide for 17 pixels, its letters ran into the frame)for name, label, color in [('infomp3', 'MP3', ICE), ('infowav', 'WAV', mix(ICE, (160, 240, 220), 0.5)),                           ('infomid', 'MID', mix(ICE, (200, 180, 255), 0.5)), ('infocd', 'CD', mix(ICE, (230, 230, 230), 0.6)),                           ('infovid', 'VID', ICE)]:    save(badges.badge(label, color), name)for name, fill, rim in [('lyrok', ICE, WHITE), ('lyrno', mix(NAVY_TOP, ICE_DIM, 0.3), mix(NAVY_TOP, ICE_DIM, 0.6))]:    im = new(17 * S, 9 * S)    dd = ImageDraw.Draw(im)    dd.ellipse([4 * S, 1 * S, 12 * S, 8 * S], fill=fill + (255,), outline=rim + (255,), width=S // 2)    if name == 'lyrok':        dd.ellipse([6 * S, 2 * S, 9 * S, 4 * S], fill=(255, 255, 255, 220))    save(im.resize((17, 9), Image.LANCZOS), name)# --- the compact bar (mainp.png, 112 x 12) and its buttons ------------------------------------------------------mp = case(112, 12, 3)outline(ImageDraw.Draw(mp), 0, 0, 111, 11)save(mp, 'mainp')for name, kind, label in [('arrp', 'prev', None), ('pausep', 'pause', None), ('playp', 'play', None), ('avp', 'next', None),                          ('petitp', None, '_'), ('helpp', None, '?'), ('lyrp', None, 'L')]:    def small(d, k, kind=kind, label=label):        w, h = d.im.size        cx, cy = w / 2, h / 2        for off, col in [(k, (255, 255, 255, 170)), (0, INK + (255,))]:            if kind:                glyph(d, kind, cx, cy + off, col, k * 0.7)            if label:                d.text((cx, cy + off - (2 * k if label == '_' else 0)), label, font=font(8 * k), fill=col, anchor='mm')    save(glass(17, 13, 3, draw=small), name)# --- the icon -----------------------------------------------------------------------------------------------------ico = glass(32, 32, 7)dd = ImageDraw.Draw(ico)dd.rectangle([5, 7, 26, 16], fill=NAVY_BOTTOM, outline=SILVER_DARK)text(dd, (16, 12), 'WZ', 8, ICE, 'mm')big = new(32 * S, 32 * S)glyph(ImageDraw.Draw(big), 'play', 16 * S, 23 * S, INK + (255,), S)ico.alpha_composite(big.resize((32, 32), Image.LANCZOS))save(ico, 'ico')# --- INFO.txt: the colours, as VB wrote them (&H00BBGGRR&) -------------------------------------------------------def vb(rgb):    r, g, b = rgb    return '&H00%02X%02X%02X&' % (b, g, r)L1, L2, L3 = T['bars']colors = [ICE,                                                       # title          ICE_DIM, ICE_DIM, ICE_DIM,                                 # volume, balance, kbps          mix(ICE, WHITE, 0.4), mix(ICE, WHITE, 0.4), mix(ICE, WHITE, 0.4),          L1, L1, L2, L2, L3, L3,                                    # the bargraph          T['playing']]                                              # the line playingrows = [mix(T['rows'][0], T['rows'][1], i / 22) for i in range(23)]lines = ['[INF]', T['title']] + [vb(c) for c in colors] + [vb(c) for c in rows]with open(os.path.join(OUT, 'INFO.txt'), 'w', encoding='utf-8') as f:    f.write('\n'.join(lines) + '\n')print('skin written in', OUT)# VIS.txt: where WinZik draws its visualizer (the spectrum of the sound), in the opened part of the playerwith open(os.path.join(OUT, 'VIS.txt'), 'w') as f:    f.write('127 107 124 15\n')