This repository has been archived on 2024-06-02. You can view files and clone it, but cannot push or open issues or pull requests.
x/texture.go

30 lines
597 B
Go
Raw Normal View History

2023-08-20 22:35:55 -06:00
package x
import "image"
import "git.tebibyte.media/tomo/tomo"
2023-08-22 19:24:38 -06:00
import "git.tebibyte.media/tomo/x/canvas"
2023-08-20 22:35:55 -06:00
type texture struct {
2023-08-22 19:24:38 -06:00
*xcanvas.Texture
2023-08-20 22:35:55 -06:00
}
2023-08-22 19:24:38 -06:00
func (backend Backend) NewTexture (source image.Image) tomo.Texture {
return texture {
Texture: xcanvas.NewTextureFrom(source),
2023-08-20 22:35:55 -06:00
}
}
2023-08-22 19:24:38 -06:00
func (this texture) Clip (bounds image.Rectangle) tomo.Texture {
return texture {
Texture: this.Texture.Clip(bounds),
}
2023-08-20 22:35:55 -06:00
}
func assertTexture (unknown tomo.Texture) *texture {
if tx, ok := unknown.(*texture); ok {
return tx
} else {
panic("foregin texture implementation, i did not make this!")
}
}