Skip to content

Commit 5b9f90a

Browse files
committed
Add an 'inv-watermark' field; defaulting to "- Sample -" across invoice
1 parent 0da923e commit 5b9f90a

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

slip39/invoice/artifact.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from ..util import commas, is_listlike, is_mapping
3737
from ..defaults import (
3838
INVOICE_CURRENCY, INVOICE_ROWS, INVOICE_STRFTIME, INVOICE_DUE, INVOICE_DESCRIPTION_MAX,
39-
INVOICE_FORMAT, MM_IN, FILENAME_FORMAT,
39+
INVOICE_FORMAT, MM_IN, FILENAME_FORMAT, COLOR,
4040
)
4141
from ..layout import Region, Text, Image, Box, Coordinate, layout_pdf
4242
from .ethereum import tokeninfo, tokenprices, tokenknown
@@ -165,7 +165,6 @@ def fmt( v, d ):
165165
# conversions (so each column is a row), and elide any w/ empty conversions rows. Finally,
166166
# re-transpose back to columns.
167167
convers_txp = list( zip( *convers_raw ))
168-
import json
169168
headers_use,convers_use_txp = zip( *sorted(
170169
[
171170
(hdr,col)
@@ -945,9 +944,9 @@ def layout_invoice(
945944

946945
a = inv_int.h
947946
b = inv_int.w
948-
c = math.sqrt( a * a + b * b ) # noqa: F841
949-
β = math.atan( b / a ) # noqa: F841
950-
rotate = 90 - math.degrees( β ) # noqa: F841
947+
c = math.sqrt( a * a + b * b )
948+
β = math.atan( b / a )
949+
rotate = 90 - math.degrees( β )
951950

952951
# Header: Vendor name & contact on left, Invoice/Quote/Receipt and logo on right
953952
# 8"
@@ -1064,14 +1063,16 @@ def layout_invoice(
10641063

10651064
# inv-body, ...: Image for Body of Invoice;
10661065
# inv-table: Main Invoice text area
1067-
inv_int.add_region_proportional(
1066+
inv_body = inv_int.add_region_proportional(
10681067
Image(
10691068
'inv-body',
10701069
y1 = head,
10711070
y2 = foot,
10721071
priority = prio_normal,
10731072
)
1074-
).add_region_proportional(
1073+
)
1074+
1075+
inv_body.add_region_proportional(
10751076
Image(
10761077
'inv-table-bg',
10771078
priority = prio_contrast,
@@ -1096,6 +1097,24 @@ def layout_invoice(
10961097
),
10971098
)
10981099

1100+
# Finally, in front of all other "contrast" images, put the watermark
1101+
inv_int.add_region_proportional(
1102+
Text(
1103+
'inv-watermark',
1104+
x1 = c/b * 10/100,
1105+
y1 = +0/32,
1106+
x2 = c/b * 90/100,
1107+
y2 = +8/32,
1108+
foreground = int( COLOR[-2], 16 ), # med grey
1109+
rotate = -rotate,
1110+
bold = True,
1111+
italic = True,
1112+
align = 'C',
1113+
priority = prio_contrast,
1114+
text = "- Sample -",
1115+
)
1116+
)
1117+
10991118
return inv
11001119

11011120

0 commit comments

Comments
 (0)