| 1 | #!/usr/bin/env python3 |
| 2 | """Recolour the theme-picker thumbnails. |
| 3 | |
| 4 | These are miniature screenshots rather than widget art, so unlike the rest of |
| 5 | assets/ they draw on the whole Nord palette at once -- including hues that |
| 6 | appear nowhere else in the theme. Every Nord entry is anchored here so none of |
| 7 | them falls through to a neutral. |
| 8 | """ |
| 9 | |
| 10 | import os |
| 11 | import sys |
| 12 | |
| 13 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), "lib")) |
| 14 | |
| 15 | import darkmatter as dm |
| 16 | from png import Png |
| 17 | from remap import Remapper |
| 18 | |
| 19 | NORD = [ |
| 20 | ("#2e3440", dm.DARK), # polar night -> the surface ladder |
| 21 | ("#3b4252", dm.BASE), |
| 22 | ("#434c5e", dm.BG), |
| 23 | ("#4c566a", dm.BORDER), |
| 24 | ("#232831", dm.SHADOW), |
| 25 | ("#d8dee9", dm.FG), # snow storm -> foreground |
| 26 | ("#e5e9f0", dm.FG), |
| 27 | ("#eceff4", dm.FG), |
| 28 | ("#8fbcbb", dm.ORANGE), # frost -> the accent ramp |
| 29 | ("#88c0d0", dm.ORANGE), |
| 30 | ("#81a1c1", dm.ORANGE_L1), |
| 31 | ("#5e81ac", dm.ORANGE_D1), |
| 32 | ("#bf616a", dm.RED), # aurora |
| 33 | ("#d08770", dm.ORANGE), |
| 34 | ("#ebcb8b", dm.CREAM), |
| 35 | ("#a3be8c", dm.TEAL), |
| 36 | ("#b48ead", dm.CREAM), |
| 37 | ("#000000", "#000000"), |
| 38 | ("#ffffff", dm.FG), |
| 39 | ] |
| 40 | |
| 41 | TARGETS = ["gtk-3.0/thumbnail.png", "gtk-4.0/thumbnail.png"] |
| 42 | |
| 43 | |
| 44 | def main(): |
| 45 | remap = Remapper([(dm.rgb(s), dm.rgb(t)) for s, t in NORD]) |
| 46 | for path in TARGETS: |
| 47 | if not os.path.exists(path): |
| 48 | continue |
| 49 | img = Png(path) |
| 50 | if img.color_type == 3: |
| 51 | img.set_palette([remap(c) for c in img.palette()]) |
| 52 | elif img.color_type == 6: |
| 53 | img.set_rgba([remap(p[:3]) + (p[3],) for p in img.rgba()]) |
| 54 | else: |
| 55 | print(" skipped (colour type %d): %s" % (img.color_type, path)) |
| 56 | continue |
| 57 | img.save() |
| 58 | print(" recoloured %s" % path) |
| 59 | |
| 60 | |
| 61 | if __name__ == "__main__": |
| 62 | main() |