本文整理匯總了Golang中bitbucket/org/zombiezen/gopdf/pdf.Path.Rectangle方法的典型用法代碼示例。如果您正苦於以下問題:Golang Path.Rectangle方法的具體用法?Golang Path.Rectangle怎麽用?Golang Path.Rectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bitbucket/org/zombiezen/gopdf/pdf.Path
的用法示例。
在下文中一共展示了Path.Rectangle方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Grid
func Grid(canvas *pdf.Canvas, x, y, w, h, step float64) {
canvas.Push()
canvas.SetColor(0.75, 0.75, 0.75)
canvas.Translate(unit(x), unit(y))
rowCount := int(math.Floor(h / step))
for row := 0; row < rowCount; row++ {
bottom := float64(row) * step
top := bottom + step
start := 0.0
if row%2 == 0 {
start += step
}
for left := start; left < w; left += (2 * step) {
right := left + step
bottomLeft := point(left, bottom)
topRight := point(right, top)
path := new(pdf.Path)
path.Rectangle(pdf.Rectangle{bottomLeft, topRight})
canvas.Fill(path)
}
}
canvas.Pop()
}
示例2: main
func main() {
doc := pdf.New()
canvas := doc.NewPage(pdf.A4Width, pdf.A4Height)
path := new(pdf.Path)
bottomLeft := pdf.Point{borderWidth, borderWidth}
topRight := pdf.Point{pdf.A4Width - borderWidth, pdf.A4Height - borderWidth}
path.Rectangle(pdf.Rectangle{bottomLeft, topRight})
canvas.Stroke(path)
staffOrigin := pdf.Point{bottomLeft.X + pdf.Unit(10), bottomLeft.Y + pdf.Unit(500)}
largeStaff := engraving.NewStaffSpec(engraving.RastralZero)
engraving.EngraveStaff(staffOrigin, 12*pdf.Cm, largeStaff.Height(), 0.1*pdf.Pt, canvas)
engraving.EngraveSurrogateNoteHead(staffOrigin, largeStaff.StaffSpace(), canvas)
nextNote := pdf.Point{}
nextNote.X = pdf.Unit(staffOrigin.X + largeStaff.StaffSpace())
nextNote.Y = pdf.Unit(staffOrigin.Y + largeStaff.IndexOffset(0))
engraving.EngraveSurrogateNoteHead(nextNote, largeStaff.StaffSpace(), canvas)
nextNote.X = pdf.Unit(staffOrigin.X + (2 * largeStaff.StaffSpace()))
nextNote.Y = pdf.Unit(staffOrigin.Y + largeStaff.IndexOffset(7))
engraving.EngraveSurrogateNoteHead(nextNote, largeStaff.StaffSpace(), canvas)
nextNote.X = pdf.Unit(staffOrigin.X + (3 * largeStaff.StaffSpace()))
nextNote.Y = pdf.Unit(staffOrigin.Y + largeStaff.IndexOffset(-1))
engraving.EngraveSurrogateNoteHead(nextNote, largeStaff.StaffSpace(), canvas)
nextNote.X = pdf.Unit(staffOrigin.X + (4 * largeStaff.StaffSpace()))
nextNote.Y = pdf.Unit(staffOrigin.Y + largeStaff.IndexOffset(2))
engraving.EngraveSurrogateNoteHead(nextNote, largeStaff.StaffSpace(), canvas)
smallStaff := engraving.NewStaffSpec(engraving.RastralEight)
staffOrigin.Y = staffOrigin.Y + 5*pdf.Cm
engraving.EngraveStaff(staffOrigin, 12*pdf.Cm, smallStaff.Height(), 0.1*pdf.Pt, canvas)
canvas.Close()
err := doc.Encode(os.Stdout)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
示例3: EngraveSurrogateNoteHead
func EngraveSurrogateNoteHead(origin pdf.Point, size pdf.Unit, canvas *pdf.Canvas) {
outline := new(pdf.Path)
topRight := pdf.Point{origin.X + size, origin.Y + size}
outline.Rectangle(pdf.Rectangle{origin, topRight})
mid := pdf.Point{origin.X + pdf.Unit(size/2), origin.Y + pdf.Unit(size/2)}
midPoints := new(pdf.Path)
midPoints.Move(pdf.Point{mid.X, origin.Y})
midPoints.Line(pdf.Point{mid.X, origin.Y + size})
midPoints.Move(pdf.Point{origin.X, mid.Y})
midPoints.Line(pdf.Point{origin.X + size, mid.Y})
canvas.Push()
canvas.SetColor(0.6, 0.6, 0.6)
canvas.Fill(outline)
canvas.SetLineWidth(pdf.Unit(0.1))
canvas.Stroke(midPoints)
canvas.Pop()
}
示例4: main
func main() {
doc := pdf.New()
canvas := doc.NewPage(pdf.A4Width, pdf.A4Height)
path := new(pdf.Path)
bottomLeft := pdf.Point{borderWidth, borderWidth}
topRight := pdf.Point{pdf.A4Width - borderWidth, pdf.A4Height - borderWidth}
path.Rectangle(pdf.Rectangle{bottomLeft, topRight})
canvas.Stroke(path)
left := 5 * pdf.Cm
right := 15 * pdf.Cm
top := 15 * pdf.Cm
bottom := 10 * pdf.Cm
curve := new(pdf.Path)
a := pdf.Point{left, bottom}
b := pdf.Point{left, top}
c := pdf.Point{right, top}
d := pdf.Point{right, bottom}
curve.Move(a)
curve.Curve(b, c, d)
beneath := 5 * pdf.Cm
e := pdf.Point{left, beneath}
f := pdf.Point{right, beneath}
curve.Curve(f, e, a)
left = 6.5 * pdf.Cm
right = 13.5 * pdf.Cm
top = 13.5 * pdf.Cm
bottom = 10 * pdf.Cm
beneath = 6.5 * pdf.Cm
a = pdf.Point{left, 9 * pdf.Cm}
b = pdf.Point{left, top}
c = pdf.Point{right, top}
d = pdf.Point{right, 11 * pdf.Cm}
curve.Move(d)
curve.Curve(c, b, a)
e = pdf.Point{left, beneath}
f = pdf.Point{right, beneath}
curve.Curve(e, f, d)
canvas.FillStroke(curve)
canvas.Close()
file, err := os.Create("curves.pdf")
if err != nil {
log.Fatal(err)
}
err = doc.Encode(file)
if err != nil {
log.Fatal(err)
os.Exit(1)
}
file.Close()
}