load

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Fill float64 = 100000.767898765556788777667787666

Fill is constant important to ui, it is also redeclare here so check it out

Variables

View Source
var (
	ErrNotOnDisc = sterr.New("%s file not found on disc")
)

errors

View Source
var OS = Util{Loader: OSFS{}}

OS is default os loader

Functions

func AppDataDir added in v0.4.3

func AppDataDir() (string, error)

AppDataDir returns directory where the app data is located

func CollectFloats

func CollectFloats(values []interface{}, buff []float64) int

CollectFloats collects consecutive floating point numbers and returns how match was collected

func ParseRGBA

func ParseRGBA(values []interface{}) (c mat.RGBA, ln int)

ParseRGBA parses slice if interfaces into color and returns how big the color was

syntax:

	name - simple name of color can be enough if its contained in map in mlok/mat/rgba package
 a - specify only one float/int channel and mat.Alpha(alpha) will be returned
 r, g, b - specify threes floats/ints and mat.RGB(r, g, b) will be returned
 r, g, b, a - specify four floats/ints and mat.RGBA{r, g, b, a} will be returned
 hex - hex color notation

Types

type Loader added in v0.2.14

type Loader interface {
	fs.ReadDirFS
	ReadFile(name string) ([]byte, error)
}

Loader can be a OSFS or embed.FS, so writing generic asset loading where it does not matter where you load from

type OSFS added in v0.2.14

type OSFS struct{}

OSFS uses os as source of data

func (OSFS) Open added in v0.2.14

func (o OSFS) Open(path string) (fs.File, error)

Open implements fs.FS interface

func (OSFS) ReadDir added in v0.2.14

func (o OSFS) ReadDir(path string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS interface

func (OSFS) ReadFile added in v0.2.14

func (o OSFS) ReadFile(path string) ([]byte, error)

ReadFile implements AssetLoader interface

type RawStyle

type RawStyle struct {
	goss.Style
}

RawStyle is wrapper of goss.RawStyle and adds extra functionality

func (RawStyle) AABB

func (r RawStyle) AABB(key string, def mat.AABB) (m mat.AABB)

AABB parser margin under the key, if parsing fails or margin is not present, default is returned

func (RawStyle) Bool

func (r RawStyle) Bool(key string, def bool) (v bool)

Bool returns boolean value under the key, or def if retrieval fails

func (RawStyle) Float

func (r RawStyle) Float(key string, def float64) (v float64)

Float returns float under the key of default value if obtaining failed

func (RawStyle) Ident

func (r RawStyle) Ident(key, def string) string

Ident returns string from RawStyle or def if not present

func (RawStyle) Int

func (r RawStyle) Int(key string, def int) (v int)

func (RawStyle) RGBA

func (r RawStyle) RGBA(key string, def mat.RGBA) (c mat.RGBA)

RGBA returns a color under the key, if color parsing fails or color is not present, def is returned this also accepts names mapped in mlok/mat/rgba.Colors

func (RawStyle) Region

func (r RawStyle) Region(key string, regions map[string]mat.AABB, def mat.AABB) mat.AABB

Region returns a texture region, it can be hardcoded aabb or region name.

func (RawStyle) Sub

func (r RawStyle) Sub(key string, def RawStyle) (v RawStyle)

Sub retrieves Substyle under the key, or returns def

func (RawStyle) Vec

func (r RawStyle) Vec(key string, def mat.Vec) (u mat.Vec)

Vec returns vector under tha key, if parsing fails or vec is not present def is returned

type Util added in v0.2.14

type Util struct {
	Loader
	Root string
}

Util brings some utility for Loader, if you specify root it will be prepended to path you input

func AppData added in v0.4.3

func AppData(root string) (Util, error)

AppData returns AppData access, the root is usually the name of your app

func (Util) Json added in v0.3.1

func (l Util) Json(p string, dest interface{}) error

Json unmarshal-s json from given path to dest

func (Util) List added in v0.2.14

func (l Util) List(root string, buff []string, rec bool, ext string) (r []string, err error)

List lists all paths in given directory. If rec == true, function will go recursively. If ext == "" they any extencion is valid, ext does not include dot ("go" not ".go")

func (Util) LoadImage added in v0.3.1

func (l Util) LoadImage(p string) (*image.NRGBA, error)

LoadImage loads image from disk

func (Util) LoadTTF added in v0.3.1

func (l Util) LoadTTF(p string, size float64) (font.Face, error)

LoadTTF loads TTF file into font.Face

func (Util) SaveJson added in v0.4.4

func (l Util) SaveJson(p string, value interface{}) error

Save json saves the json representation of given value to disk

func (Util) Walk added in v0.2.14

func (l Util) Walk(root string, fn func(path string, d fs.DirEntry, err error) error)

Walk calls fs.WalkDir on Loader

Jump to

Keyboard shortcuts

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