Documentation ¶
Overview ¶
Manages graphics and sound assets.
Manages graphics and sound assets.
Manages graphics and sound assets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAssetType = errors.New("incorrect asset type")
The requested asset exists but does not support the requested operation.
var ErrIllDimensions = errors.New("illegal image dimensions")
The provided width/height are illegal.
var ErrUnknown = errors.New("unknown error")
An error for which no more specific information is available.
var ShitLog []string
All errors encountered while adding assets will be appended here.
Functions ¶
func Add ¶
If pth is a directory, recursively scans it and subdirectories and collects assets found. If pth refers to an asset file, only that one is added.
func Image ¶
Renders the image asset with the given asset_path into an RGBA array with the given width*height. each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then red, then green, then blue. The 32-bit quantities are stored native-endian. Pre-multiplied alpha is used. (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)
func List ¶
Returns a list (unsorted) of the full paths of all assets with the given path_prefix. If prefix does not end in "/" it is nevertheless assumed. IOW, a path_prefix cannot be a partial name. The returned paths DO NOT start with "/" (and path_prefix may but need not start with a "/", either). If no assets are found, the return value is nil.
Types ¶
type Asset ¶
type Asset interface { // Unmarshal's the JSON metadata of the asset into target. Meta(target interface{}) error }
Superinterface of all assets (graphics, sound,...).
type ImageAsset ¶
type ImageAsset interface { Asset // Renders the image with the given width*height into an RGBA array. Render(width, height int) ([]uint32, error) }
Superinterface of all graphics assets.
type SVGAsset ¶
type SVGAsset struct { // XML source code up to the location where viewBox and/or width/height // attributes for the svg element need to be inserted. Never includes // viewBox/width/height. Always ends in whitespace, so no additional // whitespace needs to be inserted before viewBox. Head []byte // viewBox="..." attribute to be inserted between Head and Body. ViewBox []byte // XML source code following the location where viewBox attribute for // svg element needs to be inserted. Body []byte // Metadata in JSON format. Always includes "x","y","width","height","centerx" // and "centery". MetaJSON []byte }
A rectangular part of an SVG image.