util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromJson

func FromJson(file string, obj any) error

func FromJsonFs

func FromJsonFs(f fs.FS, file string, obj any) error

func ReadImage

func ReadImage(p string) (image.Image, error)

func ToJson

func ToJson(file string, obj any) error

func Walk

func Walk(base string, tileSet string, f func(sheet RawSpriteSheet, dir Directory) error) error

func WalkDirs

func WalkDirs(base string, tileSet string, sheet RawSpriteSheet, f func(sheet RawSpriteSheet, dir Directory) error) error

func WalkSheets

func WalkSheets(base string, tileSet string, f func(sheet RawSpriteSheet) error) error

func WriteImage

func WriteImage(file string, img image.Image) error

Types

type Directory

type Directory struct {
	Dir         string
	HasJson     bool
	Files       []File
	Directories []Directory
}

type File

type File struct {
	Name   string
	IsJson bool
}

type RawSprite

type RawSprite struct {
	Id         string     `json:"id"`
	File       []string   `json:"file"`
	Height     int        `json:"height,omitempty"`
	YOffset    int        `json:"y_offset,omitempty"`
	AnimFrames int        `json:"animation_frames,omitempty"`
	AnimSpeed  int        `json:"animation_speed,omitempty"`
	Multitile  [][]string `json:"multitile,omitempty"`
}

type RawSpriteSheet

type RawSpriteSheet struct {
	Directory string
	Width     int
	Height    int
}

type Sprite

type Sprite struct {
	Id         string  `json:"id"`
	Index      []int   `json:"index"`
	Height     int     `json:"height,omitempty"`
	YOffset    int     `json:"y_offset,omitempty"`
	AnimFrames int     `json:"animation_frames,omitempty"`
	AnimSpeed  int     `json:"animation_speed,omitempty"`
	Multitile  [][]int `json:"multitile,omitempty"`
}

func (*Sprite) IsAnimated

func (s *Sprite) IsAnimated() bool

func (*Sprite) IsMultitile

func (s *Sprite) IsMultitile() bool

type SpriteSheet

type SpriteSheet struct {
	SpriteWidth  int      `json:"sprite_width"`
	SpriteHeight int      `json:"sprite_height"`
	Sprites      []Sprite `json:"sprites"`
	TotalSprites int      `json:"total_sprites"`
}

type TileSet

type TileSet struct {
	TileWidth          int        `json:"tile_width"`
	TileHeight         int        `json:"tile_height"`
	BackgroundColor    color.RGBA `json:"background_color"`
	TextColor          color.RGBA `json:"text_color"`
	TextHighlightColor color.RGBA `json:"text_highlight_color"`
}

Jump to

Keyboard shortcuts

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