#!/usr/bin/env python3 """Recolours a Lottie's near-black strokes and fills to the Doormile crimson. The splash animation is line art drawn in #000000. Black is not in this app's palette — the darkest thing in it is `DmColors.ink`, and the splash is the one screen that is nothing but brand — so a black truck reads as clip art dropped onto a brand screen, which is what it is until this runs. Idempotent: colours that are already crimson are left alone, so re-running it on an already-converted file changes nothing. Re-run it after replacing `assets/animations/splash.json` with a fresh download. tool/lottie_brand.py assets/animations/splash.json """ import json import sys BRAND = [143 / 255, 15 / 255, 6 / 255] # #8F0F06 NEAR_BLACK = 0.12 # everything darker than this moves def recolour(node, hits): if isinstance(node, dict): colour = node.get('c') if isinstance(colour, dict): k = colour.get('k') if ( isinstance(k, list) and len(k) >= 3 and all(isinstance(x, (int, float)) for x in k[:3]) and all(x <= NEAR_BLACK for x in k[:3]) ): k[0:3] = BRAND hits[0] += 1 for value in node.values(): recolour(value, hits) elif isinstance(node, list): for value in node: recolour(value, hits) def main(path): with open(path) as f: data = json.load(f) hits = [0] recolour(data, hits) with open(path, 'w') as f: json.dump(data, f, separators=(',', ':')) print(f'{hits[0]} colours -> #8F0F06 in {path}') if __name__ == '__main__': main(sys.argv[1] if len(sys.argv) > 1 else 'assets/animations/splash.json')