diff --git a/backend.go b/backend.go index 6f4aaab..e4850d2 100644 --- a/backend.go +++ b/backend.go @@ -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 diff --git a/object.go b/object.go index 96e06b2..5e1c585 100644 --- a/object.go +++ b/object.go @@ -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. diff --git a/texture.go b/texture.go new file mode 100644 index 0000000..2e8485c --- /dev/null +++ b/texture.go @@ -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 +} diff --git a/tomo.go b/tomo.go index 3bfc5ca..1b512ca 100644 --- a/tomo.go +++ b/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) +}