gg/ax/define.go

53 lines
746 B
Go
Raw Normal View History

2024-05-28 11:24:12 +03:00
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{
2024-06-01 16:07:28 +03:00
Id AnimationID
2024-05-28 11:24:12 +03:00
Indexes []RectIndex
}
// Animation define shortcut.
func AD(
2024-06-01 16:07:28 +03:00
id AnimationID,
2024-05-28 11:24:12 +03:00
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
}