Browse Source

initial (and only? ...nah) commit

master
whut 1 year ago
commit
c39c7cf20c
2 changed files with 24 additions and 0 deletions
  1. +3
    -0
      README.md
  2. +21
    -0
      noble.py

+ 3
- 0
README.md View File

@@ -0,0 +1,3 @@
Pass the name of a template, pipe in your scheme, result will be on stdout. You want to use a scheme from a file, just cat it.

Useful if you have something that generates base16 schemes ([\*cough\*](https://git.lain.church/whut/acid16)) and just want to pipe it into a template without too much trouble. Or if you just want an uncomplicated base16 builder.

+ 21
- 0
noble.py View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python3
import pystache, sys, yaml

inData = yaml.safe_load(sys.stdin.read())
template = open(sys.argv[1], 'r').read()
data = {'scheme-name': inData.get('scheme', 'Untitled'),
'scheme-author': inData.get('author', 'Anonymous'),
'scheme-slug': '<stdin>'}

for i in ["base%02X" % x for x in range(16)]:
colorHex = [inData[i][x*2:x*2+2] for x in range(3)]
color = [int(x, 16) for x in colorHex]
data[i + "-hex"] = inData[i]
data[i + "-hex-bgr"] = "".join(colorHex[::-1])
for c in range(3):
comp = "rgb"[c]
data[i + "-hex-" + comp] = colorHex[c]
data[i + "-rgb-" + comp] = color[c]
data[i + "-dec-" + comp] = color[c] / 255.0

print(pystache.render(template, data))

Loading…
Cancel
Save