artwork

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CustomResourcePrefix = "custom:"

CustomResourcePrefix marks a layer resource as a file in resources_dir.

Variables

View Source
var MediaTypes = media.Types()

MediaTypes are the media type folder names a layer resource can use: the EmulationStation media folders internal/media places media in.

Functions

func Float64Param

func Float64Param(params map[string]interface{}, key string, defaultValue float64) float64

Float64Param extracts a float64 parameter with a default value

func GetRegisteredEffects

func GetRegisteredEffects() []string

GetRegisteredEffects returns a list of all registered effect names

func IntParam

func IntParam(params map[string]interface{}, key string, defaultValue int) int

IntParam extracts an integer parameter with a default value

func ParseColor

func ParseColor(hex string) (color.Color, error)

ParseColor parses a hex color string to color.Color

func RegisterEffect

func RegisterEffect(effect Effect)

RegisterEffect registers an effect in the global registry

func StringParam

func StringParam(params map[string]interface{}, key string, defaultValue string) string

StringParam extracts a string parameter with a default value

Types

type Compositor

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

Compositor handles artwork generation

func NewCompositor

func NewCompositor(config Config, cacheDir string) *Compositor

NewCompositor creates a new compositor with the given configuration

func (*Compositor) GenerateArtwork

func (c *Compositor) GenerateArtwork(romName string, mediaFiles MediaFiles, mediaRoot string) Result

GenerateArtwork composes every artwork output for one ROM. Each output is written to <mediaRoot>/<dir>/<romName>.<format>, where <dir> is the output's own output_dir or the global artwork output_dir. A failing output does not stop the others.

func (*Compositor) SetVerbose

func (c *Compositor) SetVerbose(verbose bool)

SetVerbose enables verbose logging

type Config

type Config struct {
	Enabled      bool               `mapstructure:"enabled"`
	OutputDir    string             `mapstructure:"output_dir"`
	ResourcesDir string             `mapstructure:"resources_dir"`
	Outputs      []OutputDefinition `mapstructure:"outputs"`
}

Config represents the artwork generation configuration

func (Config) Validate

func (c Config) Validate() error

Validate checks the artwork outputs: every layer resource must be a media type or a custom: resource, no output may write to a media type folder (it would overwrite downloaded media and read its own artwork back as a layer), and no two outputs may write the same format to the same folder (they would overwrite each other's files).

type Effect

type Effect interface {
	// Apply the effect to an image
	Apply(img image.Image, params map[string]interface{}) (image.Image, error)

	// Validate effect parameters
	Validate(params map[string]interface{}) error

	// Get effect name
	Name() string
}

Effect is the interface that all effects must implement

func GetEffect

func GetEffect(name string) (Effect, error)

GetEffect retrieves an effect by name from the registry

type EffectDefinition

type EffectDefinition struct {
	Type   string                 `mapstructure:"type"`    // Effect type name
	Params map[string]interface{} `mapstructure:",remain"` // All other fields become params
}

EffectDefinition defines an effect to apply to a layer

type Layer

type Layer struct {
	Image  image.Image
	X      int
	Y      int
	Width  int
	Height int
}

Layer represents a processed layer ready for composition

func ProcessLayer

func ProcessLayer(def LayerDefinition, mediaFiles MediaFiles, outputWidth, outputHeight int, resourcesDir string) (*Layer, error)

ProcessLayer loads and processes a single layer according to its definition

type LayerDefinition

type LayerDefinition struct {
	Resource string             `mapstructure:"resource"` // Source media type or "custom:{path}"
	X        string             `mapstructure:"x"`        // X position (pixels, %, or negative)
	Y        string             `mapstructure:"y"`        // Y position
	Width    string             `mapstructure:"width"`    // Width (pixels, %, or "auto")
	Height   string             `mapstructure:"height"`   // Height
	Align    string             `mapstructure:"align"`    // Horizontal align: left, center, right
	Valign   string             `mapstructure:"valign"`   // Vertical align: top, middle, bottom
	Effects  []EffectDefinition `mapstructure:"effects"`  // Effects to apply (in order)
}

LayerDefinition defines a single layer in the composition

type MediaFiles

type MediaFiles map[string]string

MediaFiles maps media types to file paths

type OutputDefinition

type OutputDefinition struct {
	Type       string            `mapstructure:"type"`       // Output name, used in logs and errors (e.g., "miximage", "marquee")
	OutputDir  string            `mapstructure:"output_dir"` // Folder under the media root (default: the global artwork output_dir)
	Width      int               `mapstructure:"width"`      // Target width in pixels (0 = auto)
	Height     int               `mapstructure:"height"`     // Target height in pixels (0 = auto)
	Format     string            `mapstructure:"format"`     // Output format: "png" (default) or "jpg"
	Background string            `mapstructure:"background"` // Background color (hex) or "transparent"
	Layers     []LayerDefinition `mapstructure:"layers"`     // Layers to composite (bottom to top)
}

OutputDefinition defines a single output image to generate

type Result

type Result struct {
	Paths  []string
	Errors []error
}

Result is what GenerateArtwork produced for one ROM: the path of every artwork output that was written, in output order, and one error per artwork output that failed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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