File: palette.py

package info (click to toggle)
schism 2%3A20250313-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,948 kB
  • sloc: ansic: 77,328; makefile: 545; objc: 365; python: 321; perl: 75; sh: 41; xml: 10
file content (16 lines) | stat: -rwxr-xr-x 547 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python
# This converts a palette string from the packed ASCII format used
# in the runtime config into a C structure suitable for inclusion
# in palettes.h.

import sys
table = '.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'
if len(sys.argv) != 2:
        print("usage: %s <encoded palette string>" % sys.argv[0])
        sys.exit(1)
for n in range(16):
        print("/* %2d */ {%s}," % (n, ', '.join([
                "%2d" % table.index(c)
                for c in sys.argv[1][3 * n : 3 * n + 3]
        ])))