Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Commit

Permalink
Factored pattern draw for transformation / graphic state test
Browse files Browse the repository at this point in the history
  • Loading branch information
jung-kurt committed Mar 9, 2019
1 parent 028e9cd commit 24315ac
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions fpdf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 24315ac

Please sign in to comment.