config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxDimension   = 8192
	MaxImagePixels = 32 * 1024 * 1024
	MaxKValue      = 256
)

Variables

View Source
var PatternTypes = []string{"woodland", "multicam", "blocks", "blob", "marpat", "fleck"}

PatternTypes lists the canonical generator names in their conventional order.

Functions

This section is empty.

Types

type CamoColors

type CamoColors struct {
	Name   string   `json:"name"`
	Colors []string `json:"colors"`
}

CamoColors represents a named color palette for camouflage pattern generation. It contains a descriptive name and a list of hex color codes to be used in the pattern.

type Config

type Config struct {
	Width         int
	Height        int
	BasePixelSize int
	JSONFile      string
	OutputDir     string
	ColorsString  string
	Cores         int
	AddEdge       bool
	AddNoise      bool
	PatternType   string
	ImageDir      string
	KValue        int
	RatiosString  string
	ColorRatios   []float64
	ExistingFiles string
}

Config holds all configuration parameters for camouflage pattern generation. It includes image dimensions, pattern settings, file paths, and generation options.

func ParseFlags

func ParseFlags() *Config

ParseFlags parses command-line arguments and returns a validated configuration. It defines and processes all command-line flags for the gocamo application, providing default values and validation for user inputs. The function handles configuration for image dimensions, pattern generation settings, file paths, and processing options.

The function performs validation on several parameters:

  • CPU core count (clamped to available cores)
  • Image dimensions (minimum value enforcement)
  • Base pixel size validation
  • Color string format validation and cleanup
  • Automatic pattern type detection based on input flags

Special behaviors:

  • Using the -i flag automatically sets pattern type to "image"
  • Color strings are cleaned and validated for proper hex format
  • Invalid configurations cause the program to exit with an error message

Returns a pointer to a Config struct containing all parsed and validated settings. The program will exit with status 1 if critical validation errors occur.

func (*Config) AdjustBasePixelSize added in v1.0.3

func (cfg *Config) AdjustBasePixelSize() int

AdjustBasePixelSize calculates the optimal base pixel size that divides evenly into both width and height. It finds the divisor closest to the requested BasePixelSize to maintain the user's intended scale while ensuring perfect fit without transparent borders.

The function prioritizes larger divisors (closer to the original) when there are ties, and ensures the result is always at least 1.

func (*Config) SetColorRatios added in v1.0.3

func (cfg *Config) SetColorRatios(numColors int) error

SetColorRatios sets the color ratios for this configuration based on the number of colors. This should be called after colors are determined but before pattern generation.

func (*Config) ValidateResources added in v1.1.0

func (cfg *Config) ValidateResources() error

ValidateResources rejects configurations that can cause excessive memory or CPU consumption before generation starts.

Jump to

Keyboard shortcuts

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