summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorStani <spe.stani.be@gmail.com>2015-07-06 12:11:38 +0200
committerStani <spe.stani.be@gmail.com>2015-07-06 12:11:38 +0200
commit56ecb2da47c9086aebdd4ea84a3e7dfa297fa07f (patch)
tree4ec66012de06bf55d18c0a2598626d8ef0f6c1e5 /fpdf_test.go
parentc027db5a6b8a5b3fcd3a0462ae627acc329c07e0 (diff)
added tutorial 31: line cap join style
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 8959ece..31faa6f 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -1476,3 +1476,41 @@ func ExampleFpdf_tutorial30() {
// Output:
// Successfully generated pdf/tutorial30.pdf
}
+
+func ExampleFpdf_tutorial31() {
+ const offset = 75.0
+ pdf := gofpdf.New("L", "mm", "A4", "")
+ pdf.AddPage()
+ var draw = func(cap, join string, x0, y0, x1, y1 float64) {
+ // transform begin & end needed to isolate caps and joins
+ pdf.SetLineCapStyle(cap)
+ pdf.SetLineJoinStyle(join)
+
+ // Draw thick line
+ pdf.SetDrawColor(0x33, 0x33, 0x33)
+ pdf.SetLineWidth(30.0)
+ pdf.MoveTo(x0, y0)
+ pdf.LineTo((x0+x1)/2+offset, (y0+y1)/2)
+ pdf.LineTo(x1, y1)
+ pdf.DrawPath("D")
+
+ // Draw thin helping line
+ pdf.SetDrawColor(0xFF, 0x33, 0x33)
+ pdf.SetLineWidth(2.56)
+ pdf.MoveTo(x0, y0)
+ pdf.LineTo((x0+x1)/2+offset, (y0+y1)/2)
+ pdf.LineTo(x1, y1)
+ pdf.DrawPath("D")
+
+ }
+ x := 35.0
+ caps := []string{"butt", "square", "round"}
+ joins := []string{"bevel", "miter", "round"}
+ for i := range caps {
+ draw(caps[i], joins[i], x, 50, x, 160)
+ x += offset
+ }
+ pdf.OutputAndClose(docWriter(pdf, 31))
+ // Output:
+ // Successfully generated pdf/tutorial31.pdf
+}