30 lines
597 B
Go
30 lines
597 B
Go
package x
|
|
|
|
import "image"
|
|
import "git.tebibyte.media/tomo/tomo"
|
|
import "git.tebibyte.media/tomo/x/canvas"
|
|
|
|
type texture struct {
|
|
*xcanvas.Texture
|
|
}
|
|
|
|
func (backend Backend) NewTexture (source image.Image) tomo.Texture {
|
|
return texture {
|
|
Texture: xcanvas.NewTextureFrom(source),
|
|
}
|
|
}
|
|
|
|
func (this texture) Clip (bounds image.Rectangle) tomo.Texture {
|
|
return texture {
|
|
Texture: this.Texture.Clip(bounds),
|
|
}
|
|
}
|
|
|
|
func assertTexture (unknown tomo.Texture) *texture {
|
|
if tx, ok := unknown.(*texture); ok {
|
|
return tx
|
|
} else {
|
|
panic("foregin texture implementation, i did not make this!")
|
|
}
|
|
}
|