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) } }
func staves(canvas *pdf.Canvas) { r0 := engraving.NewStaffSpec(engraving.RastralZero) r1 := engraving.NewStaffSpec(engraving.RastralOne) r2 := engraving.NewStaffSpec(engraving.RastralTwo) r3 := engraving.NewStaffSpec(engraving.RastralThree) r4 := engraving.NewStaffSpec(engraving.RastralFour) r5 := engraving.NewStaffSpec(engraving.RastralFive) r6 := engraving.NewStaffSpec(engraving.RastralSix) r7 := engraving.NewStaffSpec(engraving.RastralSeven) r8 := engraving.NewStaffSpec(engraving.RastralEight) origin := pdf.Point{21 * pdf.Cm, 1.5 * pdf.Cm} engraving.EngraveStaff(origin, 6*pdf.Cm, r0.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r0.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r1.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r1.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r2.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r2.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r3.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r3.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r4.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r4.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r5.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r5.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r6.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r6.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r7.Height(), 0.1*pdf.Pt, canvas) origin.Y = origin.Y + r7.Height() + 1*pdf.Cm engraving.EngraveStaff(origin, 6*pdf.Cm, r8.Height(), 0.1*pdf.Pt, canvas) }