gg/ax/define.go
2024-05-28 13:24:12 +05:00

52 lines
746 B
Go

package ax
import "surdeus.su/core/gg"
type Animation []*gg.Image
type RectIndex struct {
X, Y int
}
// The type is used
// to structurely define
// animations.
type AnimationDefine struct{
Id AnimationId
Indexes []RectIndex
}
// Animation define shortcut.
func AD(
id AnimationId,
indexes ...RectIndex,
) AnimationDefine {
return AnimationDefine{
Id: id,
Indexes: indexes,
}
}
func (ad AnimationDefine) DefRow(
y int, xs ...int,
) AnimationDefine {
for _, x := range xs {
ad.Indexes = append(
ad.Indexes,
RectIndex{x, y},
)
}
return ad
}
func (ad AnimationDefine) DefCol(
x int, ys ...int,
) AnimationDefine {
for _, y := range ys {
ad.Indexes = append(
ad.Indexes,
RectIndex{x, y},
)
}
return ad
}