feat: added the way to draw filled circles.

This commit is contained in:
Andrey Parhomenko 2024-01-11 07:05:27 +03:00
parent 0f6732bcf9
commit 733c10f6fd
3 changed files with 42 additions and 0 deletions

28
circle.go Normal file
View 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
}

View file

@ -52,6 +52,16 @@ func main() {
e.Spawn(player) e.Spawn(player)
e.Spawn(rect) e.Spawn(rect)
e.Spawn(tri) 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()) fmt.Println(rect.GetLayer(), player.GetLayer())
err = e.Run() err = e.Run()

View file

@ -23,6 +23,10 @@ type Deleter interface {
Delete(*Context) Delete(*Context)
} }
type Antialiasity struct {
Antialias bool
}
// Feat to embed for turning visibility on and off. // Feat to embed for turning visibility on and off.
type Visibility struct { type Visibility struct {
Visible bool Visible bool