backend/internal/system/system.go

33 lines
838 B
Go

package system
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 backend implementation
// which contains it in order to do things such as create new textures.
type BackendLink interface {
NewTexture (image.Image) canvas.TextureCloser
NewCanvas (image.Rectangle) canvas.Canvas
NewSurface (image.Rectangle) SurfaceLink
}
// SurfaceLink wraps a Surface created by the backend implementation, allowing
// the System a higher level of control over it.
type SurfaceLink interface {
GetSurface () any
SetSize (image.Rectangle)
}
// New creates a new System.
func New (link BackendLink) *System {
return &System {
link: link,
}
}