38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package system
|
|
|
|
import "io"
|
|
import "image"
|
|
import "git.tebibyte.media/tomo/tomo/canvas"
|
|
|
|
// System is coupled to a tomo.Backend implementation, and manages Hierarchies
|
|
// and Boxes.
|
|
type System struct {
|
|
link BackendLink
|
|
}
|
|
|
|
// BackendLink allows the System to call up into the tomo.Backend implementation
|
|
// which contains it in order to do things such as create new textures.
|
|
type BackendLink interface {
|
|
// NewTexture creates a new texture from an image.
|
|
NewTexture (image.Image) canvas.TextureCloser
|
|
// NewCanvas creates a new blank canvas with the specified bounds.
|
|
NewCanvas (image.Rectangle) canvas.Canvas
|
|
// NewSurface creates a new surface with the specified bounds.
|
|
NewSurface (image.Rectangle) (SurfaceLink, error)
|
|
}
|
|
|
|
// SurfaceLink wraps a Surface created by the backend implementation, allowing
|
|
// the System a higher level of control over it.
|
|
type SurfaceLink interface {
|
|
io.Closer
|
|
GetSurface () any
|
|
SetSize (image.Rectangle)
|
|
}
|
|
|
|
// New creates a new System.
|
|
func New (link BackendLink) *System {
|
|
return &System {
|
|
link: link,
|
|
}
|
|
}
|