Skip to content

Instantly share code, notes, and snippets.

@maberer
Last active September 7, 2019 20:04
Show Gist options
  • Save maberer/9044bcbe79f3982db44391911d5ca884 to your computer and use it in GitHub Desktop.
Save maberer/9044bcbe79f3982db44391911d5ca884 to your computer and use it in GitHub Desktop.
func testRender() {
pdf := gofpdf.New("P", "mm", "A3", "")
pdf.AddPage()
const x = 200.0
const y = 200.0
const gapAngle = 40.00
const segmAngle = 16.00
const lineWidthOuterRing = 0.20
const lineWidthInnerRing = 0.25
drawArcs := func(val int, rx, ry float64) {
for i := 0; i <= 19; i++ {
drawSegm := (val & (0x01 << uint(i))) != 0
if drawSegm {
rotAngle := 90.0 - (gapAngle / 2.0)
rotAngle -= segmAngle
rotAngle -= segmAngle * float64(i)
pdf.Arc(x, y, rx, ry, rotAngle, 0.0, segmAngle, "D")
}
}
}
pdf.SetFillColor(0, 0, 0)
pdf.SetLineWidth(lineWidthOuterRing)
drawArcs(0xFFAAAAB, 1.0, 1.0)
pdf.SetLineWidth(lineWidthInnerRing)
drawArcs(0xFFAAAAB, 0.775, 0.775)
pdf.OutputFileAndClose("arcs.pdf")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment