37 lines
818 B
Go
37 lines
818 B
Go
package gg
|
|
|
|
import "github.com/hajimehoshi/ebiten/v2"
|
|
import "surdeus.su/core/gg/mx"
|
|
|
|
type EVertice = ebiten.Vertex
|
|
|
|
// Ebitens vector in better abstractions like Vectors.
|
|
type Vertice struct {
|
|
Dst mx.Vector
|
|
Src mx.Vector
|
|
Color
|
|
}
|
|
|
|
// Convert the vertice into the Ebiten's type.
|
|
func (v Vertice) ToAPI() EVertice {
|
|
r, g, b, a := v.RGBA()
|
|
return EVertice {
|
|
DstX: float32(v.Dst.X),
|
|
DstY: float32(v.Dst.Y),
|
|
SrcX: float32(v.Src.X),
|
|
SrcY: float32(v.Src.Y),
|
|
ColorR: float32(r)/(float32(MaxColorValue)),
|
|
ColorG: float32(g)/(float32(MaxColorValue)),
|
|
ColorB: float32(b)/(float32(MaxColorValue)),
|
|
ColorA: float32(a)/(float32(MaxColorValue)),
|
|
}
|
|
}
|
|
|
|
type Vertices []Vertice
|
|
func (vs Vertices) ToAPI() []EVertice {
|
|
ret := make([]EVertice, len(vs))
|
|
for i, v := range vs {
|
|
ret[i] = v.ToAPI()
|
|
}
|
|
return ret
|
|
}
|