zntg/allg5ui/texture.go

37 lines
557 B
Go
Raw Normal View History

package allg5ui
import (
"image"
"opslag.de/schobers/allg5"
"opslag.de/schobers/zntg/ui"
)
2020-05-12 21:03:43 +00:00
var _ ui.Texture = &texture{}
var _ ui.ImageSource = &texture{}
2020-05-12 21:03:43 +00:00
type texture struct {
bmp *allg5.Bitmap
source ui.ImageSource
}
func (t *texture) Destroy() error {
2020-05-12 21:03:43 +00:00
t.bmp.Destroy()
return nil
}
func (t *texture) Height() int {
return t.bmp.Height()
}
func (t *texture) CreateImage() (image.Image, error) {
if t.source == nil {
return t.bmp.Image(), nil
}
return t.source.CreateImage()
}
func (t *texture) Width() int {
return t.bmp.Width()
}