summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2019-03-06 15:18:01 -0500
committerKurt <kurt.w.jung@gmail.com>2019-03-06 15:18:01 -0500
commit6b7c17b5b904039a423e8df6e51875702bae5763 (patch)
tree5202cba8e8b0bb020c3e1440c8ac1c5e6e962ba2 /fpdf_test.go
parenta80b38af5767fdc558bed247f31aa45a0f5150c5 (diff)
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.
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go33
1 files changed, 33 insertions, 0 deletions
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
+}