Documentation
¶
Index ¶
- Variables
- func BuildBasePrompt(concept, style, variation string) string
- func BuildRowPrompt(state string, frameCount int, style string) string
- func ClearTransparentRGB(img *image.NRGBA) *image.NRGBA
- func ComposeAtlas(framesByState map[string][]*image.NRGBA) *image.NRGBA
- func ExtractStripFrames(path string, frameCount int, method string, fit bool) ([]*image.NRGBA, error)
- func Generate(ctx context.Context, env *tools.Env, prompt string, n int, references []string, ...) ([]string, error)
- func GenerateBaseDrafts(ctx context.Context, env *tools.Env, concept string, o DraftOptions) ([]string, error)
- func MirrorFrames(frames []*image.NRGBA) []*image.NRGBA
- func NormalizeCells(framesByState []StateFrames, pad int) map[string][]*image.NRGBA
- func RemoveBackground(img *image.NRGBA, chromaKey *[3]int, threshold float64) *image.NRGBA
- func SingleFrame(path string, fit bool) (*image.NRGBA, error)
- func StyleHint(style string) string
- type AtlasValidation
- type Box
- type DraftOptions
- type GenerationError
- type HatchOptions
- type HatchResult
- type ProgressFn
- type RowSpec
- type SpriteProvider
- type StateFrames
Constants ¶
This section is empty.
Variables ¶
var ( AtlasWidth = 8 * cellWidth AtlasHeight = len(RowSpecs) * cellHeight )
Atlas pixel size, eight cells wide and one row per state
var BaseVariations = []string{
"",
"a distinctly different colour palette and markings",
"a heavier, broader silhouette with sturdier proportions",
"a different facial structure and expression matching the concept tone, with unique accent/accessory details",
"a leaner, taller build and an alternate colour scheme",
"bolder, more saturated colours and a stronger expression matching the concept tone",
}
Per draft nudges varying the look but not the pose
var RowSpecs = []RowSpec{
{"idle", 0, 6}, {"running-right", 1, 8}, {"running-left", 2, 8}, {"waving", 3, 4}, {"jumping", 4, 5},
{"failed", 5, 8}, {"waiting", 6, 6}, {"running", 7, 6}, {"review", 8, 6},
}
Atlas rows in the petdex order, short rows leaving their tail transparent
var StateActions = map[string]string{
"idle": "a calm idle loop: subtle breathing, a tiny blink or gentle bob, no big gestures",
"running-right": "a sideways walk/run locomotion cycle moving to the RIGHT: the character " +
"faces and travels right with clear directional steps, a smooth gait loop",
"running-left": "a sideways walk/run locomotion cycle moving to the LEFT: the character " +
"faces and travels left with clear directional steps (the mirror of the " +
"right-facing run)",
"waving": "a friendly greeting: raising a paw/hand/limb to wave, clear up-and-down gesture",
"jumping": "a happy celebration jump: anticipation, lift off the ground, peak, and land",
"failed": "a sad or deflated reaction: slumped, dejected, small frown — readable but not noisy",
"waiting": "an expectant 'waiting on you' pose: looking up/out as if asking for input " +
"or approval — distinct from idle and review",
"running": "focused active work, staying IN PLACE (NOT walking or foot-running): " +
"leaning in, concentrating, busy 'thinking / processing / typing' energy",
"review": "careful inspection: a focused lean, head tilt, studying something intently",
}
What each state depicts, phrased to avoid detached effects, motion lines and shadows
Functions ¶
func BuildBasePrompt ¶
Base look prompt, a single centred full body mascot, the variation differentiating drafts
func BuildRowPrompt ¶
Row strip prompt of the frame count poses left to right, identity locked to the attached base
func ClearTransparentRGB ¶
Zeroes the colour of fully transparent pixels so no halo residue remains
func ComposeAtlas ¶
Packs per state frames into the atlas, short states leaving trailing cells transparent
func ExtractStripFrames ¶
func ExtractStripFrames(path string, frameCount int, method string, fit bool) ([]*image.NRGBA, error)
Turns one generated row strip into the frames, components first then slots, auto salvaging leniently
func Generate ¶
func Generate(ctx context.Context, env *tools.Env, prompt string, n int, references []string, sprite *SpriteProvider, prefix, aspectRatio string) ([]string, error)
Generates n sprite images and returns their local paths, retrying without the transparent flag where rejected
func GenerateBaseDrafts ¶
func GenerateBaseDrafts(ctx context.Context, env *tools.Env, concept string, o DraftOptions) ([]string, error)
Generates candidate base looks concurrently and returns their hardened image paths
func MirrorFrames ¶
Each frame flipped horizontally
func NormalizeCells ¶
func NormalizeCells(framesByState []StateFrames, pad int) map[string][]*image.NRGBA
Registers every frame into a cell with one shared scale and baseline so the pet never slides or pulses
func RemoveBackground ¶
Image with its flat background keyed out from the border inward, a real alpha background only repaired
func SingleFrame ¶
One frame from a standalone image, fit false giving the raw keyed sprite for NormalizeCells
Types ¶
type AtlasValidation ¶
type AtlasValidation struct {
OK bool
Width, Height int
Errors, Warnings []string
FilledStates []string
}
AtlasValidation is the geometry, occupancy and transparency check of an atlas
func ValidateAtlas ¶
func ValidateAtlas(atlas *image.NRGBA) AtlasValidation
Checks atlas geometry, occupancy and transparency
type DraftOptions ¶
type DraftOptions struct {
N int
Style string
References []string
Provider *SpriteProvider
OnDraft func(index int, path string)
IsCancelled func() bool
}
Draft generation options, zero N taking four and empty Style auto
type GenerationError ¶
type GenerationError struct{ Msg string }
GenerationError is any image generation failure, no provider, API error or IO
func (*GenerationError) Error ¶
func (e *GenerationError) Error() string
type HatchOptions ¶
type HatchOptions struct {
BaseImage, Slug, DisplayName, Description, Concept, Style string
OnProgress ProgressFn
Provider *SpriteProvider
IsCancelled func() bool
}
Hatch inputs, empty Style meaning auto
type HatchResult ¶
type HatchResult struct {
Slug, DisplayName, Spritesheet string
States []string
Validation AtlasValidation
}
HatchResult is the outcome of a successful hatch
func HatchPet ¶
func HatchPet(ctx context.Context, env *tools.Env, o HatchOptions) (*HatchResult, error)
Turns an approved base image into a full installed pet, idle falling back to the base look
type ProgressFn ¶
type ProgressFn func(event, detail string)
ProgressFn receives hatch progress events such as row, compose and save
type SpriteProvider ¶
type SpriteProvider struct {
Name string
Provider media.ImageGenProvider
SupportsReferences bool
}
SpriteProvider is the resolved image provider and whether it takes reference images
func ResolveProvider ¶
func ResolveProvider(ctx context.Context, env *tools.Env, requireReferences bool, prefer string) (*SpriteProvider, error)
Picks the sprite image provider, the env override, prefer, the active one, then the first available
type StateFrames ¶
StateFrames is one state's frames in insertion order