gg/ox/tri.go

35 lines
638 B
Go
Raw Permalink Normal View History

2024-05-28 11:24:12 +03:00
package ox
2024-06-01 16:07:28 +03:00
import "surdeus.su/core/gg/mx"
import "surdeus.su/core/gg"
//import "github.com/hajimehoshi/ebiten/v2"
2024-05-28 11:24:12 +03:00
type DrawableTriangles struct {
2024-06-01 16:07:28 +03:00
mx.Triangles
Drawity
2024-05-28 11:24:12 +03:00
}
2024-06-01 16:07:28 +03:00
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
2024-05-28 11:24:12 +03:00
buf.Color = r.Color
for i := range r.Triangles {
for j := range r.Triangles[i] {
buf.Dst = r.Triangles[i][j].Apply(m)
2024-06-01 16:07:28 +03:00
vs[i*3 + j] = buf
2024-05-28 11:24:12 +03:00
}
}
return vs
}
2024-06-01 16:07:28 +03:00
func (r *DrawableTriangles) Draw(
c gg.Context,
) *gg.Drawing {
return &gg.Drawing{
Vertices: r.MakeVertices(c),
}
}