terminalpet

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DisabledID         = "disabled"
	DefaultManifestURL = "https://petdex.dev/api/manifest/v2"
	DefaultRankingURL  = "https://petdex.dev/api/pets/search?sort=installed&limit=60&includeMeta=0"
	TrustedAssetHost   = "assets.petdex.dev"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Animation

type Animation struct {
	// contains filtered or unexported fields
}

func AtlasAnimation

func AtlasAnimation(sheet image.Image, spriteVersion int) (*Animation, error)

func PreviewAnimation

func PreviewAnimation(sheet image.Image) (*Animation, error)

func ThumbnailAnimation

func ThumbnailAnimation(imageValue image.Image) (*Animation, error)

func (*Animation) ClickAnimation

func (a *Animation) ClickAnimation(index int) (State, bool)

func (*Animation) ClickDuration

func (a *Animation) ClickDuration(state State) (time.Duration, bool)

ClickDuration reports the duration of an authored click action. The boolean is false for ordinary activity states and built-in interactions.

func (*Animation) Frame

func (a *Animation) Frame(state State, phase int) image.Image

func (*Animation) FrameDelay

func (a *Animation) FrameDelay(state State, phase int) time.Duration

func (*Animation) PrimaryDuration

func (a *Animation) PrimaryDuration(state State) time.Duration

PrimaryDuration reports how long a non-idle action plays before it settles into its fallback loop. A zero duration means the state loops from its first frame or has no configured playback boundary.

type Client

type Client struct {
	RootDir      string
	ManifestURL  string
	RankingURL   string
	HTTPClient   *http.Client
	TrustedHosts map[string]bool
	// TrustedAssetHosts is narrower than TrustedHosts: catalog redirects may use
	// petdex.dev, while image and metadata downloads must stay on the asset host.
	TrustedAssetHosts map[string]bool
	Now               func() time.Time
}

func NewClient

func NewClient(rootDir string) *Client

func (*Client) Catalog

func (c *Client) Catalog(ctx context.Context) ([]Entry, error)

func (*Client) Install

func (c *Client) Install(ctx context.Context, entry Entry) (*Animation, error)

func (*Client) InstalledEntries

func (c *Client) InstalledEntries() ([]Entry, error)

func (*Client) InstalledEntry

func (c *Client) InstalledEntry(slug string) (Entry, error)

func (*Client) LoadInstalled

func (c *Client) LoadInstalled(slug string) (*Animation, error)

func (*Client) Preview

func (c *Client) Preview(ctx context.Context, entry Entry) (*Animation, error)

type Entry

type Entry struct {
	Slug           string `json:"slug"`
	DisplayName    string `json:"displayName"`
	Kind           string `json:"kind,omitempty"`
	SubmittedBy    string `json:"submittedBy,omitempty"`
	SpritesheetURL string `json:"spritesheet"`
	PetJSONURL     string `json:"petJson,omitempty"`
	AssetBase      string `json:"assetBase,omitempty"`
	SpriteVersion  int    `json:"spriteVersionNumber"`
	Local          bool   `json:"-"`
}

func (Entry) Label

func (e Entry) Label() string

type ImageDraw

type ImageDraw struct {
	ID           uint32
	Animation    *Animation
	State        State
	Phase        int
	X            int
	Y            int
	OffsetX      int
	OffsetY      int
	Columns      int
	Rows         int
	HeightPixels int
}

type ImageProtocol

type ImageProtocol uint8
const (
	ImageProtocolNone ImageProtocol = iota
	ImageProtocolKitty
	ImageProtocolKittyLocalFile
	ImageProtocolSixel
)

type ImageRenderer

type ImageRenderer struct {
	// contains filtered or unexported fields
}

func NewImageRenderer

func NewImageRenderer(support ImageSupport) *ImageRenderer

func NewImageRendererWithCache

func NewImageRendererWithCache(support ImageSupport, cacheDir string) *ImageRenderer

func (*ImageRenderer) Clear

func (r *ImageRenderer) Clear(writer io.Writer) error

func (*ImageRenderer) DeleteImages

func (r *ImageRenderer) DeleteImages(writer io.Writer, ids ...uint32) error

DeleteImages removes known application-owned Kitty image placements even when this renderer no longer considers them active. This is intended for process shutdown and recovery from a previous interrupted render.

func (*ImageRenderer) Invalidate

func (r *ImageRenderer) Invalidate()

func (*ImageRenderer) Render

func (r *ImageRenderer) Render(writer io.Writer) error

func (*ImageRenderer) Set

func (r *ImageRenderer) Set(draw *ImageDraw)

func (*ImageRenderer) Support

func (r *ImageRenderer) Support() ImageSupport

type ImageSupport

type ImageSupport struct {
	Protocol ImageProtocol
	Reason   string
}

func DetectImageSupport

func DetectImageSupport(getenv func(string) string) ImageSupport

func (ImageSupport) Supported

func (s ImageSupport) Supported() bool

type State

type State string
const (
	Idle      State = "idle"
	MoveRight State = "running-right"
	MoveLeft  State = "running-left"
	Waving    State = "waving"
	Jumping   State = "jumping"
	Running   State = "running"
	Waiting   State = "waiting"
	Review    State = "review"
	Failed    State = "failed"
)

Jump to

Keyboard shortcuts

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