mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
c31cc4ecff
commit
a249296723
@ -20,6 +20,7 @@ import (
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
"github.com/hajimehoshi/ebiten/v2/vector"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -59,3 +60,24 @@ func DrawRect(dst *ebiten.Image, x, y, width, height float64, clr color.Color) {
|
||||
// Linear filtering would make edges blurred.
|
||||
dst.DrawImage(emptyImage.SubImage(image.Rect(1, 1, 2, 2)).(*ebiten.Image), op)
|
||||
}
|
||||
|
||||
// DrawCircle draws a circle on given destination dst.
|
||||
//
|
||||
// DrawCircle is intended to be used mainly for debugging or prototyping puropose.
|
||||
func DrawCircle(dst *ebiten.Image, cx, cy, r float64, clr color.Color) {
|
||||
var path vector.Path
|
||||
rd, g, b, a := clr.RGBA()
|
||||
|
||||
path.Arc(float32(cx), float32(cy), float32(r), 0, 2*math.Pi, vector.Clockwise)
|
||||
|
||||
verticles, indices := path.AppendVerticesAndIndicesForFilling(nil, nil)
|
||||
for i := range verticles {
|
||||
verticles[i].SrcX = 1
|
||||
verticles[i].SrcY = 1
|
||||
verticles[i].ColorR = float32(rd) / 0xffff
|
||||
verticles[i].ColorG = float32(g) / 0xffff
|
||||
verticles[i].ColorB = float32(b) / 0xffff
|
||||
verticles[i].ColorA = float32(a) / 0xffff
|
||||
}
|
||||
dst.DrawTriangles(verticles, indices, emptySubImage, nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user