2024-01-16 01:08:21 +03:00
|
|
|
package gg
|
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
import "github.com/hajimehoshi/ebiten/v2"
|
|
|
|
import "surdeus.su/core/gg/mx"
|
2024-01-16 01:08:21 +03:00
|
|
|
|
2024-05-28 11:24:12 +03:00
|
|
|
type EVertice = ebiten.Vertex
|
|
|
|
|
|
|
|
// Ebitens vector in better abstractions like Vectors.
|
|
|
|
type Vertice struct {
|
|
|
|
Dst mx.Vector
|
|
|
|
Src mx.Vector
|
|
|
|
Color
|
|
|
|
}
|
|
|
|
|
2024-06-01 16:07:28 +03:00
|
|
|
// Convert the vertice into the Ebiten's type.
|
2024-05-28 11:24:12 +03:00
|
|
|
func (v Vertice) ToAPI() EVertice {
|
2024-06-01 16:07:28 +03:00
|
|
|
r, g, b, a := v.RGBA()
|
2024-05-28 11:24:12 +03:00
|
|
|
return EVertice {
|
|
|
|
DstX: float32(v.Dst.X),
|
|
|
|
DstY: float32(v.Dst.Y),
|
|
|
|
SrcX: float32(v.Src.X),
|
|
|
|
SrcY: float32(v.Src.Y),
|
2024-06-01 16:07:28 +03:00
|
|
|
ColorR: float32(r)/(float32(MaxColorValue)),
|
|
|
|
ColorG: float32(g)/(float32(MaxColorValue)),
|
|
|
|
ColorB: float32(b)/(float32(MaxColorValue)),
|
|
|
|
ColorA: float32(a)/(float32(MaxColorValue)),
|
2024-05-28 11:24:12 +03:00
|
|
|
}
|
|
|
|
}
|
2024-06-01 16:07:28 +03:00
|
|
|
|
|
|
|
type Vertices []Vertice
|
|
|
|
func (vs Vertices) ToAPI() []EVertice {
|
|
|
|
ret := make([]EVertice, len(vs))
|
|
|
|
for i, v := range vs {
|
|
|
|
ret[i] = v.ToAPI()
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|