ass

package
v0.0.0-...-de5b88e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Manages graphics and sound assets.

Manages graphics and sound assets.

Manages graphics and sound assets.

Index

Constants

This section is empty.

Variables

View Source
var ErrAssetType = errors.New("incorrect asset type")

The requested asset exists but does not support the requested operation.

View Source
var ErrIllDimensions = errors.New("illegal image dimensions")

The provided width/height are illegal.

View Source
var ErrUnknown = errors.New("unknown error")

An error for which no more specific information is available.

View Source
var ShitLog []string

All errors encountered while adding assets will be appended here.

Functions

func Add

func Add(pth string) error

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

func Image(asset_path string, width, height int) ([]uint32, error)

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

func List(path_prefix string) []string

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.

func Meta

func Meta(asset_path string, target interface{}) error

Unmarshal's the JSON metadata of the asset with the given asset_path into target.

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.

func (*SVGAsset) Meta

func (a *SVGAsset) Meta(target interface{}) error

func (*SVGAsset) Render

func (a *SVGAsset) Render(width, height int) ([]uint32, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL