From aaa5e07435fb161255f053182aba1ca97cd5ff3f Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sun, 16 Jun 2019 11:48:53 +0200 Subject: ruled paper: print vertical lines --- src/ruled-paper.ps.j2 | 52 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ruled-paper.ps.j2 b/src/ruled-paper.ps.j2 index e13cad3..8e20934 100644 --- a/src/ruled-paper.ps.j2 +++ b/src/ruled-paper.ps.j2 @@ -57,12 +57,23 @@ /PageWidth {{ page_width }} def /PageHeight {{ page_height }} def +{% if hor_distances %} % Horizontal lines /HorLinPat {{ hor_distances | length }} array def {% for d in hor_distances %} HorLinPat {{ loop.revindex0 }} {{ d }} put {% endfor %} /HorLinSpac {{ hor_spacing }} def % spacing between groups +{% endif %} + +{% if ver_distances %} +% Vertical lines +/VerLinPat {{ ver_distances | length }} array def +{% for d in ver_distances %} + VerLinPat {{ loop.revindex0 }} {{ d }} put +{% endfor %} +/VerLinSpac {{ ver_spacing }} def % spacing between groups +{% endif %} % line width and color for thin lines /LineSizeThin {{ thin_line_size }} def @@ -90,8 +101,15 @@ % From here on you shouldn't worry about changing or configuring anything % ------ Variables ------------------------------------------------------------ +{% if hor_distances %} /HorGrouHeig 0 HorLinPat { add } forall def /HorGrouNumb PageHeight BorderBottom sub BorderTop sub HorGrouHeig HorLinSpac add div def +{% endif %} + +{% if ver_distances %} +/VerGrouHeig 0 VerLinPat { add } forall def +/VerGrouNumb PageHeight BorderBottom sub BorderTop sub VerGrouHeig VerLinSpac add div def +{% endif %} % ------ Procedures ----------------------------------------------------------- @@ -105,6 +123,7 @@ closepath } def +{% if hor_distances %} /PrintHorGroup { % stk: y gsave 0 exch translate @@ -117,11 +136,32 @@ dup BorderLeft exch moveto dup PageWidth BorderRight sub exch lineto } forall - LineSizeThin setlinewidth + LineSizeThin setlinewidth + LineColoThin setrgbcolor + stroke + grestore +} def +{% endif %} + +{% if ver_distances %} +/PrintVerGroup { % stk: x + gsave + 0 translate + newpath + 0 BorderRight moveto + 0 PageHeight BorderTop sub lineto + 0 + VerLinPat { % forall + add + dup BorderBottom moveto + dup PageHeight BorderTop sub lineto + } forall + LineSizeThin setlinewidth LineColoThin setrgbcolor stroke grestore } def +{% endif %} %%EndProlog %%Page: 1 @@ -133,11 +173,19 @@ UsedArea clip BackColo setrgbcolor UsedArea fill +{% if hor_distances %} % print horizontal lines - 0 1 HorGrouNumb { % for HorGrouHeig HorLinSpac add mul BorderBottom add PrintHorGroup } for +{% endif %} + +{% if ver_distances %} +% print vertical lines +0 1 VerGrouNumb { % for + VerGrouHeig VerLinSpac add mul BorderBottom add PrintVerGroup +} for +{% endif %} % print border (if WillPrintBorder is not 0 ) WillPrintBorder 0 ne { -- cgit v1.2.3