From 56ecb2da47c9086aebdd4ea84a3e7dfa297fa07f Mon Sep 17 00:00:00 2001 From: Stani Date: Mon, 6 Jul 2015 12:11:38 +0200 Subject: added tutorial 31: line cap join style --- fpdf_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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 +} -- cgit v1.2.1-24-ge1ad