github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/contentstream/draw/utils.go (about) 1 package draw 2 3 import ( 4 pdfcontent "github.com/unidoc/unidoc/pdf/contentstream" 5 ) 6 7 // Make the path with the content creator. 8 // Adds the PDF commands to draw the path to the creator instance. 9 func DrawPathWithCreator(path Path, creator *pdfcontent.ContentCreator) { 10 for idx, p := range path.Points { 11 if idx == 0 { 12 creator.Add_m(p.X, p.Y) 13 } else { 14 creator.Add_l(p.X, p.Y) 15 } 16 } 17 } 18 19 // Make the bezier path with the content creator. 20 // Adds the PDF commands to draw the path to the creator instance. 21 func DrawBezierPathWithCreator(bpath CubicBezierPath, creator *pdfcontent.ContentCreator) { 22 for idx, c := range bpath.Curves { 23 if idx == 0 { 24 creator.Add_m(c.P0.X, c.P0.Y) 25 } 26 creator.Add_c(c.P1.X, c.P1.Y, c.P2.X, c.P2.Y, c.P3.X, c.P3.Y) 27 } 28 }