Documentation ¶
Index ¶
- Constants
- func Wait(rc <-chan Result) error
- type Asset
- type FileSystem
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Discard(a Asset) (err error)
- func (m *Manager) File(name string) ([]byte, error)
- func (m *Manager) Font(name string) (*truetype.Font, error)
- func (m *Manager) Preload(assets []Asset, flush bool) (rc <-chan Result, n int)
- func (m *Manager) TextDrawer(name string, size float64, hinting grog.Hinting, magFilter grog.TextureFilter) (*grog.TextDrawer, error)
- func (m *Manager) Texture(name string, params ...grog.TextureParameter) (*grog.Texture, error)
- type Option
- type Result
- type Type
Constants ¶
const ( TypeFont = iota TypeTexture TypeFile )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileSystem ¶
A FileSystem implements access to named resources. Names are file paths using '/' as a path separator.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
A Manager manages asynchronous (pre)loading and caching of textures, fonts an raw files.
func NewManager ¶
func NewManager(fs FileSystem, options ...Option) *Manager
NewManager returns a new asset Manager.
func (*Manager) Preload ¶
Preload bulk preloads assets. If the flush argument is true, cached assets not present in the asset list will be removed from the cache. It returns a channel to read preload results from as well as the number of items that will actually be preloaded. This item count is informational only and callers should rely on the rc channel being closed to ensure that the operation is complete.
While preload starts immediately, it will stall after a few assets have been preloaded until the rc channel is read from (or Wait is called).
Calling Preload concurrently may result in unexpected side effects, like flushing assets that should not be. An alternative is to build the assets slice concurrently and have a single goroutine call Preload and Wait.
func (*Manager) TextDrawer ¶
func (m *Manager) TextDrawer(name string, size float64, hinting grog.Hinting, magFilter grog.TextureFilter) (*grog.TextDrawer, error)
TextDrawer returns a new grog.TextDrawer configured for the given font face (with a default DPI of 72).
Note that this function caches any grog.TextDrawer created. The only way to clean the cache is to Dispose() the corresponding font asset. If an application needs to be able to discard drawers, it should use Font() instead and manage font.Face and grog.Drawer creation and caching manually.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is implemented by option functions passed as arguments to NewManager.
func TexturePath ¶
TexturePath returns an Option that sets the default texture path.