summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdf_test.go48
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)