gg/src/gx/camera.go

39 lines
570 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{}
2023-05-30 14:34:10 +03:00
g.Scale(
c.S.X,
c.S.Y,
)
2023-02-18 03:51:43 +03:00
g.Translate(
-c.P.X,
c.P.Y,
2023-02-18 03:51:43 +03:00
)
g.Rotate(-c.R)
g.Translate(
c.RA.X,
-c.RA.Y,
)
2023-02-18 03:51:43 +03:00
return *g
}