Added a texture interface
This commit is contained in:
parent
dc377c36a5
commit
35c6e167be
@ -16,6 +16,10 @@ type Backend interface {
|
||||
NewCanvasBox () CanvasBox
|
||||
NewContainerBox () ContainerBox
|
||||
|
||||
// NewTexture creates a new texture from an image. The backend must
|
||||
// reject any texture that was not made by it.
|
||||
NewTexture (image.Image) Texture
|
||||
|
||||
// Run runs the event loop until Stop() is called, or the backend
|
||||
// experiences a fatal error.
|
||||
Run () error
|
||||
|
@ -238,6 +238,8 @@ type TextBox interface {
|
||||
// SetSelectable sets whether or not the text content can be
|
||||
// highlighted/selected.
|
||||
SetSelectable (bool)
|
||||
// SetDotColor sets the highlight color of the text selection.
|
||||
SetDotColor (color.Color)
|
||||
// Select sets the text cursor or selection.
|
||||
Select (text.Dot)
|
||||
// Dot returns the text cursor or selection.
|
||||
|
14
texture.go
Normal file
14
texture.go
Normal file
@ -0,0 +1,14 @@
|
||||
package tomo
|
||||
|
||||
import "io"
|
||||
import "image"
|
||||
|
||||
// Texture is a handle that points to a 2D raster image managed by the backend.
|
||||
type Texture interface {
|
||||
io.Closer
|
||||
|
||||
// Clip returns a smaller section of this texture, pointing to the same
|
||||
// internal data. Becaue of this, closing a clipped section will close
|
||||
// the original texture as well.
|
||||
Clip (image.Rectangle) Texture
|
||||
}
|
7
tomo.go
7
tomo.go
@ -79,3 +79,10 @@ func NewContainerBox () ContainerBox {
|
||||
assertBackend()
|
||||
return backend.NewContainerBox()
|
||||
}
|
||||
|
||||
// NewTexture creates a new texture from an image. When no longer in use, it
|
||||
// must be freed using Close().
|
||||
func NewTexture (source image.Image) Texture {
|
||||
assertBackend()
|
||||
return backend.NewTexture(source)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user