37 lines
988 B
Go
37 lines
988 B
Go
package canvas
|
|
|
|
import "io"
|
|
import "image"
|
|
|
|
// Texture is a handle that points to a 2D raster image managed by the backend.
|
|
type Texture interface {
|
|
image.Image
|
|
|
|
// Clip returns a smaller section of this texture, pointing to the same
|
|
// internal data.
|
|
Clip (image.Rectangle) Texture
|
|
}
|
|
|
|
// TextureCloser is a texture that can be closed. Anything that receives a
|
|
// TextureCloser must close it after use.
|
|
type TextureCloser interface {
|
|
Texture
|
|
io.Closer
|
|
}
|
|
|
|
// TileArea represents a tiled area of a texture.
|
|
type TileArea struct {
|
|
// Source specifies an area of the texture to sample.
|
|
Source image.Rectangle
|
|
|
|
// Destination specifies an area of the destination to draw the texture
|
|
// onto. If Destination is bigger than Source, the empty space will be
|
|
// filled by tiling the texture (clipped to source) normally.
|
|
Destination image.Rectangle
|
|
}
|
|
|
|
// Tiler is a type that changes the way a texture is drawn.
|
|
type Tiler interface {
|
|
Tile (image.Rectangle, Texture) []TileArea
|
|
}
|