draw2d/draw2dkit/droid.go

52 lines
1 KiB
Go
Raw Normal View History

2015-04-29 15:32:28 +00:00
package draw2dkit
import (
"github.com/llgcode/draw2d"
"math"
)
2015-04-29 15:52:43 +00:00
// Droid draws a droid at specified position
2015-04-29 15:32:28 +00:00
func Droid(gc draw2d.GraphicContext, x, y float64) {
gc.SetLineCap(draw2d.RoundCap)
gc.SetLineWidth(5)
// head
gc.ArcTo(x+80, y+70, 50, 50, 180*(math.Pi/180), 360*(math.Pi/180))
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()
// left eye
2015-04-29 15:49:18 +00:00
Circle(gc, x+60, y+45, 5)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
// right eye
2015-04-29 15:49:18 +00:00
Circle(gc, x+100, y+45, 5)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
// body
2015-04-29 15:49:18 +00:00
RoundedRectangle(gc, x+30, y+75, x+30+100, y+75+90, 10, 10)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
2015-04-29 15:49:18 +00:00
Rectangle(gc, x+30, y+75, x+30+100, y+75+80)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
// left arm
2015-04-29 15:49:18 +00:00
RoundedRectangle(gc, x+5, y+80, x+5+20, y+80+70, 10, 10)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
// right arm
2015-04-29 15:49:18 +00:00
RoundedRectangle(gc, x+135, y+80, x+135+20, y+80+70, 10, 10)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
// left leg
2015-04-29 15:49:18 +00:00
RoundedRectangle(gc, x+50, y+150, x+50+20, y+150+50, 10, 10)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
// right leg
2015-04-29 15:49:18 +00:00
RoundedRectangle(gc, x+90, y+150, x+90+20, y+150+50, 10, 10)
2015-04-29 15:32:28 +00:00
gc.FillStroke()
}