From 6b7c17b5b904039a423e8df6e51875702bae5763 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 6 Mar 2019 15:18:01 -0500 Subject: Unconditionally assign colors (fill, text and draw) and line width, cap style and line join style so that the manipulation of these properties in transformations, which begin with default values, will work as intended. Add example to demonstrate expected results. --- fpdf_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'fpdf_test.go') diff --git a/fpdf_test.go b/fpdf_test.go index 707339f..34b824c 100644 --- a/fpdf_test.go +++ b/fpdf_test.go @@ -2441,3 +2441,36 @@ func ExampleFpdf_SetPage() { // Output: // Successfully generated pdf/Fpdf_SetPage.pdf } + +// ExampleFpdf_SetFillColor demonstrates how graphic attributes are properly +// assigned within multiple transformations. See issue #234. +func ExampleFpdf_SetFillColor() { + pdf := gofpdf.New("P", "mm", "A4", "") + + pdf.AddPage() + pdf.TransformBegin() + pdf.TransformTranslateX(5) + pdf.TransformTranslateY(5) + pdf.SetLineJoinStyle("round") + pdf.SetLineWidth(2) + pdf.SetDrawColor(128, 64, 0) + pdf.SetFillColor(255, 127, 0) + pdf.Rect(0, 0, 20, 20, "FD") + pdf.TransformEnd() + + pdf.TransformBegin() + pdf.TransformTranslateX(35) + pdf.TransformTranslateY(35) + pdf.SetLineJoinStyle("round") + pdf.SetLineWidth(2) + pdf.SetDrawColor(128, 64, 0) + pdf.SetFillColor(255, 127, 0) + pdf.Rect(0, 0, 20, 20, "FD") + pdf.TransformEnd() + + fileStr := example.Filename("Fpdf_SetFillColor") + err := pdf.OutputFileAndClose(fileStr) + example.Summary(err, fileStr) + // Output: + // Successfully generated pdf/Fpdf_SetFillColor.pdf +} -- cgit v1.2.1-24-ge1ad