config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Presets = map[Preset]presetDimensions{
	PresetWidescreen: {Width: 1920, Height: 1080},
	PresetDesktop:    {Width: 1440, Height: 900},
	PresetSquare:     {Width: 1200, Height: 1200},
	PresetPortrait:   {Width: 1080, Height: 1350},
}

Presets maps preset name strings to their width and height.

Functions

func PresetNames

func PresetNames() []string

PresetNames returns the ordered list of available preset names. This is maintained as a literal slice because Go maps are unordered.

Types

type Config

type Config struct {
	URL        string
	Dir        string
	Filename   string
	Preset     Preset
	Width      int
	Height     int
	Zoom       float64
	Scroll     int
	Crop       Crop
	Shift      bool
	Delay      time.Duration
	ChromePath string
}

Config holds all configuration for taking a screenshot.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config populated with sensible defaults.

func (*Config) ApplyPreset

func (c *Config) ApplyPreset(preset Preset) error

ApplyPreset sets Width and Height from the named preset.

func (Config) CaptureHeight added in v0.2.0

func (c Config) CaptureHeight() int

CaptureHeight returns the height that should be captured before crop is applied.

func (Config) CaptureWidth added in v0.2.0

func (c Config) CaptureWidth() int

CaptureWidth returns the width that should be captured before crop is applied.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that the configuration is complete and consistent.

type Crop added in v0.2.0

type Crop struct {
	Top    int
	Bottom int
	Left   int
	Right  int
}

Crop describes how many pixels should be removed from each edge.

func ParseCrop added in v0.2.0

func ParseCrop(value string) (Crop, error)

ParseCrop parses a crop specification in top,bottom,left,right order.

func (Crop) Horizontal added in v0.2.0

func (c Crop) Horizontal() int

Horizontal reports the total pixels removed from the left and right edges.

func (Crop) IsZero added in v0.2.0

func (c Crop) IsZero() bool

IsZero reports whether the crop removes nothing.

func (Crop) Vertical added in v0.2.0

func (c Crop) Vertical() int

Vertical reports the total pixels removed from the top and bottom edges.

type Preset

type Preset string

Preset represents a named screen resolution preset.

const (
	PresetWidescreen Preset = "widescreen"
	PresetDesktop    Preset = "desktop"
	PresetSquare     Preset = "square"
	PresetPortrait   Preset = "portrait"
	PresetCustom     Preset = "custom"
)

Jump to

Keyboard shortcuts

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