diff options
Diffstat (limited to 'macros/luatex/generic/barracuda/src/lib-driver/brcd-drv-pdfliteral.lua')
-rw-r--r-- | macros/luatex/generic/barracuda/src/lib-driver/brcd-drv-pdfliteral.lua | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/macros/luatex/generic/barracuda/src/lib-driver/brcd-drv-pdfliteral.lua b/macros/luatex/generic/barracuda/src/lib-driver/brcd-drv-pdfliteral.lua index b36021f9b6..a5cfccf4cb 100644 --- a/macros/luatex/generic/barracuda/src/lib-driver/brcd-drv-pdfliteral.lua +++ b/macros/luatex/generic/barracuda/src/lib-driver/brcd-drv-pdfliteral.lua @@ -1,22 +1,17 @@ -- -- ga graphic assembler or -- Intermediate Graphic Language for barcode drawing --- Copyright (C) 2020 Roberto Giacomelli +-- Copyright (C) 2019-2022 Roberto Giacomelli -- -- All dimensions are in scaled point (sp) -- ga LuaTeX Driver (native implementation node+pdfliteral) --- class for drawing elementary geometric elements -local PDFnative = { - _VERSION = "PDFnative v0.0.4", - _NAME = "PDFnative", - _DESCRIPTION = "A LuaTeX native pdfliteral driver for ga graphic stream", -} - local tex = assert(tex, "This require a Lua powered TeX engine") local node = assert(node, "This require a Lua powered TeX engine") local font = assert(font, "This require a Lua powered TeX engine") +-- class for drawing elementary geometric elements +local PDFnative = {_drvname = "PDFnative"} PDFnative.ext = "txt" -- file extension PDFnative.buf_sep = "\n" -- separation string for buffer concat @@ -24,6 +19,7 @@ function PDFnative.init_buffer(st) --> buffer, text buffer st.head = nil -- addition for text processing (to remember purpose) st.last = nil st.hbox = nil + st.dash_array = nil st.cw = nil st.x_hbox = nil st.char_counter = nil @@ -126,12 +122,27 @@ function PDFnative.append_003(st, bf, xt, j) bf[#bf + 1] = string.format("%d j", j) end +-- 5 dash_pattern +function PDFnative.append_005(st, bf, xt, phase, dash_array) + local bp = st.bp -- conversion factor bp -> sp + local t = {} + for _, d in ipairs(dash_array) do + t[#t + 1] = string.format("%0.6f", d/bp) + end + bf[#bf + 1] = string.format("[%s] %0.6f d",table.concat(t, " "), phase/bp) +end + +-- 6 reset_pattern +function PDFnative.append_006(st, bf, xt) + bf[#bf + 1] = string.format("[] 0 d") +end + -- draw an horizontal line -- 33 <x1: DIM> <x2: DIM> <y: DIM> function PDFnative.append_033(st, bf, xt, x1, x2, y) local bp = st.bp -- conversion factor bp -> sp - bf[#bf + 1] = string.format("% 0.6f %0.6f m", x1/bp, y/bp) - bf[#bf + 1] = string.format("% 0.6f %0.6f l", x2/bp, y/bp) + bf[#bf + 1] = string.format("%0.6f %0.6f m", x1/bp, y/bp) + bf[#bf + 1] = string.format("%0.6f %0.6f l", x2/bp, y/bp) bf[#bf + 1] = "S" -- stroke end @@ -140,8 +151,8 @@ end -- 34 <y1: DIM> <y2: DIM> <x: DIM> function PDFnative.append_034(st, bf, xt, y1, y2, x) local bp = st.bp -- conversion factor bp -> sp - bf[#bf + 1] = string.format("% 0.6f %0.6f m", x/bp, y1/bp) - bf[#bf + 1] = string.format("% 0.6f %0.6f l", x/bp, y2/bp) + bf[#bf + 1] = string.format("%0.6f %0.6f m", x/bp, y1/bp) + bf[#bf + 1] = string.format("%0.6f %0.6f l", x/bp, y2/bp) bf[#bf + 1] = "S" -- stroke end @@ -161,6 +172,21 @@ function PDFnative.append_036_stop(st, bf, xt, nbar, y1, y2) bf[#bf + 1] = "S" -- stroke end +-- Polyline +-- draw a polyline +-- 38 <n> <x1: DIM> <y1: DIM> ... <xn: DIM> <yn: DIM> +function PDFnative.append_038_start(st, bf, xt, n, x1, y1) + local bp = st.bp -- conversion factor bp -> sp + bf[#bf + 1] = string.format("%0.6f %0.6f m", x1/bp, y1/bp) +end +function PDFnative.append_038_point(st, bf, xt, x, y) + local bp = st.bp -- conversion factor bp -> sp + bf[#bf + 1] = string.format("%0.6f %0.6f l", x/bp, y/bp) +end +function PDFnative.append_038_stop(st, bf, xt) + bf[#bf + 1] = "S" -- stroke +end + -- draw a rectangle -- 48 <x1: DIM> <y1: DIM> <x2: DIM> <y2: DIM> function PDFnative.append_048(st, bf, xt, x1, y1, x2, y2) |