package ui import ( "image" "image/color" "math" "github.com/llgcode/draw2d/draw2dimg" "opslag.de/schobers/galleg/allegro5" ) func drawBitmap(w, h int, draw func(*draw2dimg.GraphicContext)) *allegro5.Bitmap { dest := image.NewRGBA(image.Rect(0, 0, w, h)) gc := draw2dimg.NewGraphicContext(dest) gc.SetFillColor(color.Transparent) gc.Clear() draw(gc) bmp, err := allegro5.NewBitmapFromImage(dest, false) if nil != err { return nil } return bmp } func drawCircle(r, w int, startAngle, a float64, c color.Color) *allegro5.Bitmap { var width = 2*r + w return drawBitmap(width, width, func(gc *draw2dimg.GraphicContext) { gc.SetFillColor(c) gc.SetStrokeColor(c) gc.SetLineWidth(float64(w)) var rad = float64(r) var cnt = float64(width) * .5 var dx1, dy1 = cnt + math.Cos(startAngle)*rad, cnt + math.Sin(startAngle)*rad gc.MoveTo(dx1, dy1) gc.ArcTo(cnt, cnt, rad, rad, startAngle, a) gc.Stroke() }) }