From c39c7cf20c2fd9dc30c8909737c9eb21a114000c Mon Sep 17 00:00:00 2001 From: whut Date: Thu, 23 Jun 2022 11:28:22 -0500 Subject: [PATCH] initial (and only? ...nah) commit --- README.md | 3 +++ noble.py | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 README.md create mode 100755 noble.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5e20cf --- /dev/null +++ b/README.md @@ -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. diff --git a/noble.py b/noble.py new file mode 100755 index 0000000..3acec2b --- /dev/null +++ b/noble.py @@ -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': ''} + +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))