gg/src/gx/camera.go

27 lines
542 B
Go
Raw Normal View History

2023-02-18 03:51:43 +03:00
package gx
// Implements the camera component
// for the main window.
type Camera struct {
Transform
2023-02-18 03:51:43 +03:00
}
// Returns the matrix satysfying camera
// position, scale and rotation to apply
// it to the objects to get the real
// transform to display on the screen.
// (Should implement buffering it so we do not
// need to calculate it each time for each object. )
func (c *Camera)RealMatrix(
e *Engine,
) Matrix {
2023-02-18 03:51:43 +03:00
g := &Matrix{}
g.Scale(c.S.X, c.S.Y)
g.Translate(-c.P.X, -c.P.Y)
g.Rotate(c.R)
g.Translate(c.RA.X, c.RA.Y)
2023-02-18 03:51:43 +03:00
return *g
}