feat: added the way to draw filled circles.
This commit is contained in:
parent
0f6732bcf9
commit
733c10f6fd
3 changed files with 42 additions and 0 deletions
28
circle.go
Normal file
28
circle.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package gg
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/vector"
|
||||
)
|
||||
|
||||
type Circle struct {
|
||||
Object
|
||||
Transform
|
||||
Visibility
|
||||
Colority
|
||||
Antialiasity
|
||||
Layer
|
||||
}
|
||||
|
||||
func (circle *Circle) Draw(c *Context) []EVertex {
|
||||
rPos := circle.Position.Apply(c.Camera.RealMatrix())
|
||||
vector.DrawFilledCircle(
|
||||
c.Image,
|
||||
float32(rPos.X), float32(rPos.Y),
|
||||
float32(circle.Rotation),
|
||||
circle.Color,
|
||||
circle.Antialias,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +52,16 @@ func main() {
|
|||
e.Spawn(player)
|
||||
e.Spawn(rect)
|
||||
e.Spawn(tri)
|
||||
|
||||
circle := &gg.Circle{}
|
||||
circle.Transform = gg.T()
|
||||
circle.Rotation = 300
|
||||
circle.Color = gg.Rgba(1, 1, 1, 1)
|
||||
circle.Antialias = true
|
||||
circle.Layer = HighestL
|
||||
circle.Visible = true
|
||||
e.Spawn(circle)
|
||||
|
||||
fmt.Println(rect.GetLayer(), player.GetLayer())
|
||||
|
||||
err = e.Run()
|
||||
|
|
|
@ -23,6 +23,10 @@ type Deleter interface {
|
|||
Delete(*Context)
|
||||
}
|
||||
|
||||
type Antialiasity struct {
|
||||
Antialias bool
|
||||
}
|
||||
|
||||
// Feat to embed for turning visibility on and off.
|
||||
type Visibility struct {
|
||||
Visible bool
|
||||
|
|
Loading…
Reference in a new issue