summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
Diffstat (limited to 'forms')
-rwxr-xr-xforms/colour_chart.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/forms/colour_chart.py b/forms/colour_chart.py
index efcd7d0..bbdf021 100755
--- a/forms/colour_chart.py
+++ b/forms/colour_chart.py
@@ -2,6 +2,7 @@
import argparse
import math
+import operator
import fpdf
import strictyaml
@@ -10,6 +11,7 @@ import strictyaml
class Chart:
COLUMNS=4
ROWS=16
+ INDEX_COLS=6
def __init__(self):
self.parser = self.get_parser()
@@ -42,6 +44,14 @@ class Chart:
]
return(cells)
+ def get_index(self):
+ index = [
+ (c["label"], i // self.ROWS)
+ for i, c in enumerate(self.data["colours"])
+ ]
+ index.sort(key=operator.itemgetter(0))
+ return index
+
def write_pdf(self, fname):
pdf = fpdf.FPDF(format="A5")
pdf.add_font(
@@ -78,6 +88,21 @@ class Chart:
pdf.cell(16, 8, cell["label"], )
pdf.ln(10)
+ pdf.set_font("FreeSerif", size=10)
+ with pdf.text_columns(
+ ncols=self.INDEX_COLS,
+ balance=True,
+ gutter=4,
+ text_align="RIGHT",
+ ) as cols:
+ for c in self.get_index():
+ pdf.set_font("FreeSerif", size=10)
+ cols.write(str(c[0]))
+ cols.write(" ")
+ pdf.set_font("FreeSans", "B", size=10)
+ cols.write(str(c[1]))
+ cols.ln()
+
pdf.output(fname)