render

package
v0.99.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MasterAtlasManager = &AtlasManager{
	IconStateCache: map[string]IconState{},
	BasePath:       "media/sprites",
}

The main atlas manager instance.

Functions

This section is empty.

Types

type AnimatedIcon

type AnimatedIcon struct {
	CurrentState *IconState
	IconStates   map[string]*IconState
}

An animated icon is a set of icon states.

func NewAnimatedIconFromPath

func NewAnimatedIconFromPath(path string, stateKey string) (*AnimatedIcon, error)

Looks up the provided icon and state in the cache. Tries to cut and cache the icon if not already cached.

func (*AnimatedIcon) Draw

func (a *AnimatedIcon) Draw(screen *ebiten.Image, x, y, scaleX, scaleY, tilt float64)

func (*AnimatedIcon) DrawWithColorScale

func (a *AnimatedIcon) DrawWithColorScale(screen *ebiten.Image, x, y, scaleX, scaleY, tilt, r, g, b, alpha float64)

Colors the icon when rendering.

func (*AnimatedIcon) SetIconState

func (a *AnimatedIcon) SetIconState(state string) error

Changes the icon's active state.

func (*AnimatedIcon) Update

func (a *AnimatedIcon) Update(dt time.Duration)

Iterates through the frames.

type AnimationMode

type AnimationMode int
const (
	AnimationModeOnce     AnimationMode = iota
	AnimationModeLoop     AnimationMode = iota
	AnimationModePingPong AnimationMode = iota
)

type AtlasManager

type AtlasManager struct {
	IconStateCache map[string]IconState
	BasePath       string
	// contains filtered or unexported fields
}

AtlasManager caches cut icons to reuse them.

func (*AtlasManager) CacheIconStates

func (m *AtlasManager) CacheIconStates(path string) error

Parses an Aseprite format .json file, reads the .png spritesheet from the provided directory and cuts it. Caches the result.

func (*AtlasManager) CutAtlas

func (m *AtlasManager) CutAtlas(r io.Reader, meta AtlasMeta) ([]IconState, error)

Cuts the .png spritesheet into `Frame`s and combines them into `IconState`s.

func (*AtlasManager) GetIconState

func (m *AtlasManager) GetIconState(iconName, iconState string) (IconState, error)

GetIconState returns a cached icon state by compound key "iconName_iconState".

type AtlasMeta

type AtlasMeta struct {
	Name   string
	States []assets.IconStateMeta
}

AtlasMeta is a single atlas entity (png + aseprite-style JSON).

type Frame

type Frame struct {
	Image *ebiten.Image
	Time  time.Duration
}

A frame is an image and its duration.

type IconState

type IconState struct {
	Name            string
	CurrentFrame    int
	CurrentFrameRef *Frame
	Frames          []Frame
	Mode            AnimationMode

	Continuous bool
	// contains filtered or unexported fields
}

An icon state is a set of frames and additional info on how to iterate through them.

Jump to

Keyboard shortcuts

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