-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurve.go
More file actions
25 lines (19 loc) · 728 Bytes
/
curve.go
File metadata and controls
25 lines (19 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package davepdf
import (
"fmt"
)
func (pdf *Pdf) NewPath(x, y float64) {
pdf.page.instructions.add(fmt.Sprintf("%.2F %.2F m", x*pdf.k, (pdf.h-y)*pdf.k), "begin a new subpath at (x, y)")
}
func (pdf *Pdf) StrokePath() {
pdf.page.instructions.add("S", "stroke the path")
}
func (pdf *Pdf) FillPath() {
pdf.page.instructions.add("f", "fill the path")
}
func (pdf *Pdf) StrokeAndFillPath() {
pdf.page.instructions.add("B", "stroke AND fill the path")
}
func (pdf *Pdf) AppendCurve(x1, y1, x2, y2, x3, y3 float64) {
pdf.page.instructions.add(fmt.Sprintf("%.2F %.2F %.2F %.2F %.2F %.2F c", x1*pdf.k, (pdf.h-y1)*pdf.k, x2*pdf.k, (pdf.h-y2)*pdf.k, x3*pdf.k, (pdf.h-y3)*pdf.k), "draw a Bézier curve from last draw point")
}