Skip to content

Commit 5033137

Browse files
author
Olivier Bonnaure
committed
feat: add styles & cap to lines
1 parent cc9e8ab commit 5033137

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

.lua/pdfgenerator.lua

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ function PDFGenerator:drawLine(x1, y1, x2, y2, width, options)
741741
options.color = options.color or "000000"
742742
options.style = options.style or "solid" -- "solid", "dashed", "dotted"
743743
options.cap = options.cap or "butt" -- "butt", "round", "square"
744-
options.opacity = options.opacity or 1.0 -- 0.0 to 1.0
745744

746745
width = width or 1
747746
local rgb = PDFGenerator:hexToRGB(options.color)
@@ -774,24 +773,6 @@ function PDFGenerator:drawLine(x1, y1, x2, y2, width, options)
774773
table.insert(content.streams, "0 J\n")
775774
end
776775

777-
-- Set opacity (only if < 1.0)
778-
if options.opacity < 1.0 then
779-
local gsName = "GS" .. tostring(math.floor(options.opacity * 100))
780-
if not self.extGStates then self.extGStates = {} end
781-
if not self.extGStates[gsName] then
782-
-- Create ExtGState object
783-
local objNum = getNewObjNum()
784-
self.extGStates[gsName] = objNum
785-
table.insert(self.objects, {
786-
num = objNum,
787-
data = string.format("<< /Type /ExtGState /CA %s /ca %s >>",
788-
numberToString(options.opacity),
789-
numberToString(options.opacity))
790-
})
791-
end
792-
table.insert(content.streams, string.format("/%s gs\n", gsName))
793-
end
794-
795776
-- Draw the line
796777
table.insert(content.streams, string.format(
797778
"%s %s m\n%s %s l\nS\n",

app/controllers/welcome_controller.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ local app = {
149149
pdf:moveY(10)
150150
pdf:drawLine(55, pdf:currentYPos(), 545, pdf:currentYPos(), 1, { color = "00aa00", style = "dotted" }) -- green dotted
151151
pdf:moveY(10)
152-
pdf:drawLine(55, pdf:currentYPos(), 545, pdf:currentYPos(), 1, { color = "00aa00", style = "dotted", opacity = 0.5 })
153-
pdf:moveY(10)
154152
pdf:drawLine(55, pdf:currentYPos(), 545, pdf:currentYPos(), 1, { color = "00aa00", style = "dotted", cap = "round" }) -- green dotted
155153
pdf:moveY(10)
156154
pdf:drawLine(55, pdf:currentYPos(), 545, pdf:currentYPos(), 1, { color = "00aa00", style = "dashed", cap = "round" }) -- green dotted

0 commit comments

Comments
 (0)