diff options
author | Kurt <kurt.w.jung@gmail.com> | 2019-03-09 07:58:59 -0500 |
---|---|---|
committer | Kurt <kurt.w.jung@gmail.com> | 2019-03-09 07:58:59 -0500 |
commit | 24315acbbda57c4f6b80c8441fd108087dd7e305 (patch) | |
tree | a8db9034601b9c73d02fc872d628252b02802919 | |
parent | 028e9cd207bf37e1d0e2b72f37b5e3bd6abf86a2 (diff) |
Factored pattern draw for transformation / graphic state test
-rw-r--r-- | fpdf_test.go | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/fpdf_test.go b/fpdf_test.go index 92ac3d9..53609bf 100644 --- a/fpdf_test.go +++ b/fpdf_test.go @@ -2448,35 +2448,27 @@ func ExampleFpdf_SetFillColor() { pdf := gofpdf.New("P", "mm", "A4", "") pdf.AddPage() - pdf.SetFont("Arial", "", 12) - - 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.SetAlpha(0.5, "Normal") - pdf.SetDashPattern([]float64{5, 10}, 0) - pdf.Rect(0, 0, 20, 20, "FD") - pdf.SetFontSize(8) - pdf.Write(10, "Test") - pdf.TransformEnd() + pdf.SetFont("Arial", "", 8) - 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.SetAlpha(0.5, "Normal") - pdf.SetDashPattern([]float64{5, 10}, 0) - pdf.Rect(0, 0, 20, 20, "FD") - pdf.SetFontSize(8) - pdf.Write(10, "Test") - pdf.TransformEnd() + draw := func(trX, trY float64) { + pdf.TransformBegin() + pdf.TransformTranslateX(trX) + pdf.TransformTranslateY(trY) + pdf.SetLineJoinStyle("round") + pdf.SetLineWidth(0.5) + pdf.SetDrawColor(128, 64, 0) + pdf.SetFillColor(255, 127, 0) + pdf.SetAlpha(0.5, "Normal") + pdf.SetDashPattern([]float64{5, 10}, 0) + pdf.Rect(0, 0, 40, 40, "FD") + pdf.SetFontSize(12) + pdf.SetXY(5, 5) + pdf.Write(0, "Test") + pdf.TransformEnd() + } + + draw(5, 5) + draw(50, 50) fileStr := example.Filename("Fpdf_SetFillColor") err := pdf.OutputFileAndClose(fileStr) |