Exemple #1
0
func android(gc draw2d.GraphicContext, x, y float64) {
	gc.SetLineCap(draw2d.RoundCap)
	gc.SetLineWidth(5)
	gc.ArcTo(x+80, y+70, 50, 50, 180*(math.Pi/180), 360*(math.Pi/180)) // head
	gc.FillStroke()
	gc.MoveTo(x+60, y+25)
	gc.LineTo(x+50, y+10)
	gc.MoveTo(x+100, y+25)
	gc.LineTo(x+110, y+10)
	gc.Stroke()
	draw2d.Circle(gc, x+60, y+45, 5) // left eye
	gc.FillStroke()
	draw2d.Circle(gc, x+100, y+45, 5) // right eye
	gc.FillStroke()
	draw2d.RoundRect(gc, x+30, y+75, x+30+100, y+75+90, 10, 10) // body
	gc.FillStroke()
	draw2d.Rect(gc, x+30, y+75, x+30+100, y+75+80)
	gc.FillStroke()
	draw2d.RoundRect(gc, x+5, y+80, x+5+20, y+80+70, 10, 10) // left arm
	gc.FillStroke()
	draw2d.RoundRect(gc, x+135, y+80, x+135+20, y+80+70, 10, 10) // right arm
	gc.FillStroke()
	draw2d.RoundRect(gc, x+50, y+150, x+50+20, y+150+50, 10, 10) // left leg
	gc.FillStroke()
	draw2d.RoundRect(gc, x+90, y+150, x+90+20, y+150+50, 10, 10) // right leg
	gc.FillStroke()
}
Exemple #2
0
func drawPolygon(ctxt draw2d.GraphicContext, g *geos.Geometry, fillColor color.Color, strokeColor color.Color, width float64, scale func(x, y float64) (float64, float64)) {
	ctxt.SetFillColor(fillColor)
	ctxt.SetStrokeColor(strokeColor)
	ctxt.SetLineWidth(width)
	// exterior ring
	ring := geos.Must(g.ExteriorRing())
	cs, err := ring.coordSeq()
	if err != nil {
		log.Fatal(err)
	}
	lineCoordSeq(ctxt, cs, scale)
	ctxt.FillStroke()
	// interior rings...
}
Exemple #3
0
func drawLine(ctxt draw2d.GraphicContext, g *geos.Geometry, c color.Color, width float64, scale func(x, y float64) (float64, float64)) {
	if c != nil {
		ctxt.SetStrokeColor(c)
	}
	if width != 0.0 {
		ctxt.SetLineWidth(width)
	}
	// XXX: should get a [] of points
	cs, err := g.coordSeq()
	if err != nil {
		log.Fatal(err)
	}
	lineCoordSeq(ctxt, cs, scale)
	ctxt.Stroke()
}
Exemple #4
0
func TestDrawCubicCurve(gc draw2d.GraphicContext) {
	// draw a cubic curve
	x, y := 25.6, 128.0
	x1, y1 := 102.4, 230.4
	x2, y2 := 153.6, 25.6
	x3, y3 := 230.4, 128.0

	gc.SetStrokeColor(color.NRGBA{0, 0, 0, 0xFF})
	gc.SetLineWidth(10)
	gc.MoveTo(x, y)
	gc.CubicCurveTo(x1, y1, x2, y2, x3, y3)
	gc.Stroke()

	gc.SetStrokeColor(color.NRGBA{0xFF, 0, 0, 0xFF})

	gc.SetLineWidth(6)
	// draw segment of curve
	gc.MoveTo(x, y)
	gc.LineTo(x1, y1)
	gc.LineTo(x2, y2)
	gc.LineTo(x3, y3)
	gc.Stroke()
}