2019-03-05 20:52:18 +00:00
|
|
|
package allg5ui
|
|
|
|
|
|
|
|
import (
|
2019-03-13 18:49:00 +00:00
|
|
|
"image"
|
|
|
|
|
2019-12-19 06:07:43 +00:00
|
|
|
"opslag.de/schobers/allg5"
|
2019-03-05 20:52:18 +00:00
|
|
|
"opslag.de/schobers/zntg/ui"
|
|
|
|
)
|
|
|
|
|
2020-05-12 21:03:43 +00:00
|
|
|
var _ ui.Texture = &texture{}
|
2020-05-15 07:20:44 +00:00
|
|
|
var _ ui.ImageSource = &texture{}
|
2019-03-05 20:52:18 +00:00
|
|
|
|
2020-05-12 21:03:43 +00:00
|
|
|
type texture struct {
|
2020-05-15 07:20:44 +00:00
|
|
|
bmp *allg5.Bitmap
|
|
|
|
source ui.ImageSource
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 07:20:44 +00:00
|
|
|
func (t *texture) Destroy() error {
|
2020-05-12 21:03:43 +00:00
|
|
|
t.bmp.Destroy()
|
2020-05-15 07:20:44 +00:00
|
|
|
return nil
|
2019-03-13 18:49:00 +00:00
|
|
|
}
|
|
|
|
|
2020-12-12 13:40:50 +00:00
|
|
|
func (t *texture) Height() int {
|
|
|
|
return t.bmp.Height()
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 07:20:44 +00:00
|
|
|
func (t *texture) CreateImage() (image.Image, error) {
|
|
|
|
if t.source == nil {
|
|
|
|
return t.bmp.Image(), nil
|
|
|
|
}
|
|
|
|
return t.source.CreateImage()
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
|
|
|
|
2020-12-12 13:40:50 +00:00
|
|
|
func (t *texture) Width() int {
|
|
|
|
return t.bmp.Width()
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|