Exemplo n.º 1
0
// DrawGlyph implements the GlyphDrawer interface.
func (CircleGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point) {
	var p vg.Path
	p.Move(pt.X+sty.Radius, pt.Y)
	p.Arc(pt.X, pt.Y, sty.Radius, 0, 2*math.Pi)
	p.Close()
	c.Fill(p)
}
Exemplo n.º 2
0
// DrawGlyph implements the Glyph interface.
func (RingGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point) {
	c.SetLineStyle(LineStyle{Color: sty.Color, Width: vg.Points(0.5)})
	var p vg.Path
	p.Move(pt.X+sty.Radius, pt.Y)
	p.Arc(pt.X, pt.Y, sty.Radius, 0, 2*math.Pi)
	p.Close()
	c.Stroke(p)
}
Exemplo n.º 3
0
Arquivo: grob.go Projeto: vdobler/plot
func (point GrobPoint) Draw(vp Viewport) {
	vp.Canvas.Push()
	vp.Canvas.SetColor(point.color)
	vp.Canvas.SetLineWidth(1)
	x, y := vp.X(point.x), vp.Y(point.y)
	s := vg.Points(point.size)
	var p vg.Path

	draw := vp.Canvas.Stroke
	if point.shape >= SolidCirclePoint && point.shape <= SolidNablaPoint {
		draw = vp.Canvas.Fill
	}

	switch point.shape {
	case BlankPoint:
		return
	case DotPoint:
		dpi := vp.Canvas.DPI()
		p.Arc(x, y, vg.Inch/vg.Length(dpi), 0, 2*math.Pi)
		p.Close()
		vp.Canvas.Fill(p)
	case CirclePoint, SolidCirclePoint:
		p.Arc(x, y, vg.Points(point.size), 0, 2*math.Pi)
		p.Close()
		draw(p)
	case SquarePoint, SolidSquarePoint:
		p.Move(x-s, y-s)
		p.Line(x+s, y-s)
		p.Line(x+s, y+s)
		p.Line(x-s, y+s)
		p.Close()
		draw(p)
	case DiamondPoint, SolidDiamondPoint:
		p.Move(x, y-s)
		p.Line(x+s, y)
		p.Line(x, y+s)
		p.Line(x-s, y)
		p.Close()
		draw(p)
	case DeltaPoint, SolidDeltaPoint:
		ss := 0.57735 * s
		p.Move(x, y+2*ss)
		p.Line(x-s, y-ss)
		p.Line(x+s, y-ss)
		p.Close()
		draw(p)
	case NablaPoint, SolidNablaPoint:
		ss := 0.57735 * s
		p.Move(x, y-2*ss)
		p.Line(x-s, y+ss)
		p.Line(x+s, y+ss)
		p.Close()
		draw(p)
	case CrossPoint:
		ss := s / 1.3
		p.Move(x-ss, y-ss)
		p.Line(x+ss, y+ss)
		p.Move(x-ss, y+ss)
		p.Line(x+ss, y-ss)
		draw(p)
	case PlusPoint:
		p.Move(x-s, y)
		p.Line(x+s, y)
		p.Move(x, y-s)
		p.Line(x, y+s)
		draw(p)
	case StarPoint:
		ss := s / 1.3
		p.Move(x-ss, y-ss)
		p.Line(x+ss, y+ss)
		p.Move(x-ss, y+ss)
		p.Line(x+ss, y-ss)
		p.Move(x-s, y)
		p.Line(x+s, y)
		p.Move(x, y-s)
		p.Line(x, y+s)
		draw(p)
	default:
		println("Implement Draw for points " + point.shape.String())
	}
	vp.Canvas.Pop()
}