From f0690e7eabd6a1dc812923ce417ebdb7da490f14 Mon Sep 17 00:00:00 2001 From: Kurt Jung Date: Sat, 4 Jul 2015 13:14:40 -0400 Subject: Dashed lines: tutorial example and tip of hat to Claudio Felber --- .gitignore | 1 + doc.go | 3 ++- fpdf.go | 12 ++++++++---- fpdf_test.go | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index cde0305..78d0dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pdf.txt *.sublime* font/Ubuntu-* *.0 +*.swp diff --git a/doc.go b/doc.go index 55ff390..8e3c0e1 100644 --- a/doc.go +++ b/doc.go @@ -71,7 +71,8 @@ Schroeder. Ivan Daniluk generalized the font and image loading code to use the Reader interface while maintaining backward compatibility. Anthony Starks provided code for the Polygon function. Robert Lillack provided the Beziergon function and corrected some naming issues with the internal curve function. -Bruno Michel has provided valuable assistance with the code. +Claudio Felber provided implementations for dashed line drawing and generalized +font loading. Bruno Michel has provided valuable assistance with the code. The FPDF website is http://www.fpdf.org/. diff --git a/fpdf.go b/fpdf.go index b2872e6..e516931 100644 --- a/fpdf.go +++ b/fpdf.go @@ -788,10 +788,14 @@ func (f *Fpdf) SetLineCapStyle(styleStr string) { } } -// SetDashPattern sets the dash pattern that is used to draw lines. -// The dashArray elements are numbers that specify the lengths of alternating -// dashes and gaps. The dash phase specifies the distance into the dash pattern -// at which to start the dash. The dash pattern is retained from page to page. +// SetDashPattern sets the dash pattern that is used to draw lines. The +// dashArray elements are numbers, in units established in New(), that specify +// the lengths of alternating dashes and gaps. The dash phase specifies the +// distance into the dash pattern at which to start the dash. The dash pattern +// is retained from page to page. Call this method with an empty array to +// restore solid line drawing. +// +// See tutorial 28 for an example of this function. func (f *Fpdf) SetDashPattern(dashArray []float64, dashPhase float64) { scaled := make([]float64, len(dashArray)) for i, value := range dashArray { diff --git a/fpdf_test.go b/fpdf_test.go index f8df0c3..bb69569 100644 --- a/fpdf_test.go +++ b/fpdf_test.go @@ -1415,8 +1415,10 @@ func ExampleFpdf_tutorial28() { srcPrev = src } pdf.MultiCell(wd-margin-margin, ln, msgStr, "", "C", false) - pdf.SetDrawColor(224, 224, 224) + pdf.SetDashPattern([]float64{0.8, 0.8}, 0) + pdf.SetDrawColor(160, 160, 160) pdf.Polygon(srcList, "D") + pdf.SetDashPattern([]float64{}, 0) pdf.SetDrawColor(64, 64, 128) pdf.SetLineWidth(pdf.GetLineWidth() * 3) pdf.Beziergon(curveList, "D") -- cgit v1.2.1-24-ge1ad