Example #1
0
// DrawArcs draws some arcs to the canvas.
// The canvas is assumed to be 4 inches square.
func DrawArcs(c vg.Canvas) {
	green := color.RGBA{G: 255, A: 255}

	var p vg.Path
	p.Move(vg.Inches(3), vg.Inches(2))
	p.Arc(vg.Inches(2), vg.Inches(2), vg.Inches(1), 0, 2*math.Pi)
	c.SetColor(color.RGBA{B: 255, A: 255})
	c.Fill(p)

	p = vg.Path{}
	p.Move(vg.Inches(4), vg.Inches(2))
	p.Line(vg.Inches(3), vg.Inches(2))
	p.Arc(vg.Inches(2), vg.Inches(2), vg.Inches(1), 0, 5*math.Pi/2)
	p.Line(vg.Inches(2), vg.Inches(4))
	c.SetColor(color.RGBA{R: 255, A: 255})
	c.SetLineWidth(vg.Points(3))
	c.Stroke(p)

	p = vg.Path{}
	p.Move(vg.Inches(0), vg.Inches(2))
	p.Line(vg.Inches(1), vg.Inches(2))
	p.Arc(vg.Inches(2), vg.Inches(2), vg.Inches(1), math.Pi, -7*math.Pi/2)
	p.Line(vg.Inches(2), vg.Inches(0))
	c.SetColor(color.Black)
	c.SetLineWidth(vg.Points(1))
	c.Stroke(p)

	p = vg.Path{}
	p.Move(vg.Inches(0), vg.Inches(1))
	p.Arc(vg.Inches(1), vg.Inches(1), vg.Inches(1), math.Pi, math.Pi/2)
	c.SetLineWidth(vg.Points(3))
	c.SetColor(green)
	c.Stroke(p)

	p = vg.Path{}
	p.Move(vg.Inches(1), vg.Inches(0))
	p.Arc(vg.Inches(1), vg.Inches(1), vg.Inches(1), 3*math.Pi/2, -math.Pi/2)
	c.SetLineWidth(vg.Points(1))
	c.SetColor(color.Black)
	c.Stroke(p)

	p = vg.Path{}
	p.Move(vg.Inches(3), vg.Inches(2))
	p.Arc(vg.Inches(3), vg.Inches(3), vg.Inches(1), 3*math.Pi/2, 3*math.Pi/2)
	c.SetLineWidth(vg.Points(3))
	c.SetColor(green)
	c.Stroke(p)

	p = vg.Path{}
	p.Move(vg.Inches(2), vg.Inches(3))
	p.Arc(vg.Inches(3), vg.Inches(3), vg.Inches(1), math.Pi, -3*math.Pi/2)
	c.SetLineWidth(vg.Points(1))
	c.SetColor(color.Black)
	c.Stroke(p)
}