Files
aego/render/sprite/draw.go
T
sanspie 515f4ca1b3 Stage 11a: animation (D333–D340, D344, D354–D357)
Clips (.aeanim) and controllers (.aectrl) with importers, AnimationPlayer and Animator with crossfades, root motion and events on fixed steps, rewind support. Editor: Animation panel (dope sheet, curves, record, preview, trajectory), Animator panel, sprite sheet slicer and flipbooks, Programming workspace, export panel redesign. Motion 2D ledge climb. 11c: the component and Create palette.
2026-10-25 15:31:22 +03:00

56 lines
918 B
Go

package sprite
import (
"aego/core/mathx"
"aego/gpu"
"aego/render/texture"
)
type BlendMode uint8
const (
BlendPremultiplied BlendMode = iota
BlendOpaque
BlendAdditive
blendCount
)
type Draw struct {
Region texture.Region
Position mathx.Vec2
Size mathx.Vec2
Scale mathx.Vec2
Rotation float32
Origin mathx.Vec2
Z float32
Tint mathx.Color
Layer int16
Order int16
Blend BlendMode
Sampler gpu.SamplerHandle
FlipX bool
FlipY bool
}
func (d *Draw) scale() mathx.Vec2 {
if d.Scale.X == 0 && d.Scale.Y == 0 {
return mathx.Vec2{X: 1, Y: 1}
}
return d.Scale
}
func (d *Draw) WorldSize(pixelsPerUnit float32) mathx.Vec2 {
base := d.Size
if base.X == 0 && base.Y == 0 {
if pixelsPerUnit <= 0 {
pixelsPerUnit = 1
}
base = d.Region.Size().Scale(1 / pixelsPerUnit)
}
return base.Mul(d.scale())
}
func (d *Draw) tint() mathx.Color {
return d.Tint
}