gg/ox/tri.go
2024-06-02 00:01:17 +05:00

34 lines
638 B
Go

package ox
import "surdeus.su/core/gg/mx"
import "surdeus.su/core/gg"
//import "github.com/hajimehoshi/ebiten/v2"
type DrawableTriangles struct {
mx.Triangles
Drawity
}
func (r *DrawableTriangles) MakeVertices(
c gg.Context,
) gg.Vertices {
m := c.Camera().GetRealMatrice(c)
vs := make(gg.Vertices, len(r.Triangles) * 3)
var buf gg.Vertice
buf.Color = r.Color
for i := range r.Triangles {
for j := range r.Triangles[i] {
buf.Dst = r.Triangles[i][j].Apply(m)
vs[i*3 + j] = buf
}
}
return vs
}
func (r *DrawableTriangles) Draw(
c gg.Context,
) *gg.Drawing {
return &gg.Drawing{
Vertices: r.MakeVertices(c),
}
}