Documentation
¶
Index ¶
- Constants
- Variables
- func Float64Param(params map[string]interface{}, key string, defaultValue float64) float64
- func GetRegisteredEffects() []string
- func IntParam(params map[string]interface{}, key string, defaultValue int) int
- func ParseColor(hex string) (color.Color, error)
- func RegisterEffect(effect Effect)
- func StringParam(params map[string]interface{}, key string, defaultValue string) string
- type Compositor
- type Config
- type Effect
- type EffectDefinition
- type Layer
- type LayerDefinition
- type MediaFiles
- type OutputDefinition
- type Result
Constants ¶
const CustomResourcePrefix = "custom:"
CustomResourcePrefix marks a layer resource as a file in resources_dir.
Variables ¶
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 ¶
Float64Param extracts a float64 parameter with a default value
func GetRegisteredEffects ¶
func GetRegisteredEffects() []string
GetRegisteredEffects returns a list of all registered effect names
func ParseColor ¶
ParseColor parses a hex color string to color.Color
func RegisterEffect ¶
func RegisterEffect(effect Effect)
RegisterEffect registers an effect in the global registry
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 ¶
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
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 ¶
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 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