ichigo/engine/transform.go

33 lines
945 B
Go
Raw Normal View History

2021-09-03 09:42:50 +10:00
package engine
2021-09-07 13:14:42 +10:00
import "github.com/hajimehoshi/ebiten/v2"
2021-09-03 09:42:50 +10:00
// Transform is a bucket of things that affect drawing.
type Transform struct {
2021-09-07 13:14:42 +10:00
// Projection is used by isometric 3D components to project their
2021-09-03 09:42:50 +10:00
// coordinates into 2D. There's usually only one component in the tree that
// sets this field, but it would apply to all descendants.
2021-09-07 13:14:42 +10:00
Projection IntProjection
2021-09-03 09:42:50 +10:00
// Opts contains the 2D geometry matrix, the colour matrix, filter mode, and
// composition mode.
Opts ebiten.DrawImageOptions
}
// Concat returns the combined transform (a transform equivalent to applying t
// and then u).
func (t Transform) Concat(u Transform) Transform {
2021-09-07 13:14:42 +10:00
if u.Projection != (IntProjection{}) {
t.Projection = u.Projection
2021-09-03 09:42:50 +10:00
}
t.Opts.ColorM.Concat(u.Opts.ColorM)
t.Opts.GeoM.Concat(u.Opts.GeoM)
if u.Opts.CompositeMode != 0 {
t.Opts.CompositeMode = u.Opts.CompositeMode
}
if u.Opts.Filter != 0 {
t.Opts.Filter = u.Opts.Filter
}
return t
}