theme

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorCSS

func ColorCSS(value color.NRGBA) string

func ColorHex

func ColorHex(value color.NRGBA) string

func IsTransparent

func IsTransparent(value color.NRGBA) bool

func ParseColor

func ParseColor(input any, field ...string) (color.NRGBA, error)

ParseColor accepts CSS Color Level 4 strings, 0xRRGGBB/0xRRGGBBAA integer values, and []number values containing RGB plus an optional alpha channel.

func Pixels

func Pixels(value float64, basis int) float64

func WithAlpha

func WithAlpha(value color.NRGBA, alpha float64) string

Types

type Align

type Align string
const (
	AlignLeft   Align = "left"
	AlignCenter Align = "center"
	AlignRight  Align = "right"
)

type Avatar

type Avatar struct {
	Grayscale    bool
	Position     Position
	WidthRatio   float64
	Fit          Fit
	Fallback     color.NRGBA
	FallbackText color.NRGBA
	HasFallback  bool
	Shape        Shape
}

type AvatarInput

type AvatarInput struct {
	Grayscale    *bool
	Position     *Position
	WidthRatio   *float64
	Fit          *Fit
	Shape        *Shape
	Fallback     *color.NRGBA
	FallbackText *color.NRGBA
	HasFallback  *bool
}

type BackgroundGradient

type BackgroundGradient struct {
	Type      BackgroundGradientType
	Direction BackgroundGradientDirection
	Stops     []ColorStop
}

type BackgroundGradientDirection

type BackgroundGradientDirection string
const (
	GradientHorizontal      BackgroundGradientDirection = "horizontal"
	GradientVertical        BackgroundGradientDirection = "vertical"
	GradientDiagonal        BackgroundGradientDirection = "diagonal"
	GradientDiagonalReverse BackgroundGradientDirection = "diagonal-reverse"
)

type BackgroundGradientType

type BackgroundGradientType string
const (
	LinearGradient BackgroundGradientType = "linear"
	RadialGradient BackgroundGradientType = "radial"
)

type ColorStop

type ColorStop struct {
	Color  color.NRGBA
	Offset float64
}

type Divider

type Divider struct {
	Enabled                    bool
	WidthRatio, Thickness, Gap float64
	Color                      color.NRGBA
	InheritColor               bool
}

type DividerInput

type DividerInput struct {
	Enabled                    *bool
	WidthRatio, Thickness, Gap *float64
	Color                      *color.NRGBA
	InheritColor               *bool
}

type Emoji

type Emoji struct {
	SideMarginRatio, TopMarginRatio float64
	Size                            int
}

type EmojiInput

type EmojiInput struct {
	SideMarginRatio, TopMarginRatio *float64
	Size                            *int
}

type Fit

type Fit string
const (
	Cover   Fit = "cover"
	Contain Fit = "contain"
)

type Gradient

type Gradient struct {
	Enabled    bool
	Vertical   bool
	StartRatio float64
	EndRatio   float64
	Stops      []GradientStop
}

type GradientInput

type GradientInput struct {
	Enabled              *bool
	Vertical             *bool
	StartRatio, EndRatio *float64
	Stops                *[]GradientStop
}

type GradientStop

type GradientStop struct {
	Offset float64
	Alpha  float64
}

type Input

type Input struct {
	Base               *Theme
	Extends            Name
	Layout             *LayoutMode
	Width              *int
	Height             *int
	Background         *color.NRGBA
	BackgroundGradient *BackgroundGradient
	Avatar             *AvatarInput
	Gradient           *GradientInput
	Text               *TextInput
	QuoteMark          *QuoteMarkInput
	Divider            *DividerInput
	Emoji              *EmojiInput
	DisplayName        *LabelInput
	Username           *LabelInput
	Watermark          *LabelInput
}

Input overlays a preset. Pointer fields preserve the difference between an omitted value and an intentional zero.

func Exact

func Exact(value Theme) Input

func Preset

func Preset(name Name) Input

type Label

type Label struct {
	Color    color.NRGBA
	Font     string
	Size     float64
	Prefix   string
	Position WatermarkPosition
	Weight   int
}

type LabelInput

type LabelInput struct {
	Color    *color.NRGBA
	Font     *string
	Size     *float64
	Prefix   *string
	Position *WatermarkPosition
	Weight   *int
}

type LayoutMode

type LayoutMode string
const (
	Side    LayoutMode = "side"
	Stacked LayoutMode = "stacked"
)

type Name

type Name string
const (
	Dark          Name = "dark"
	Light         Name = "light"
	Color         Name = "color"
	Portrait      Name = "portrait"
	PortraitLight Name = "portrait-light"
	Custom        Name = "custom"
)

type Overflow

type Overflow string
const (
	Ellipsis      Overflow = "ellipsis"
	Shrink        Overflow = "shrink"
	OverflowError Overflow = "error"
)

type Position

type Position string
const (
	Left  Position = "left"
	Right Position = "right"
)

type QuoteMark

type QuoteMark struct {
	Display      QuoteMarkDisplay
	Open, Close  string
	Size         float64
	Color        color.NRGBA
	InheritColor bool
	Gap          float64
	Weight       int
}

type QuoteMarkDisplay

type QuoteMarkDisplay string
const (
	QuoteInline QuoteMarkDisplay = "inline"
	QuoteBlock  QuoteMarkDisplay = "block"
	QuoteNone   QuoteMarkDisplay = "none"
)

type QuoteMarkInput

type QuoteMarkInput struct {
	Display      *QuoteMarkDisplay
	Open, Close  *string
	Size         *float64
	Color        *color.NRGBA
	InheritColor *bool
	Gap          *float64
	Weight       *int
}

type Rect

type Rect struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
}

type Shape

type Shape string
const (
	Rectangle Shape = "rectangle"
	Circle    Shape = "circle"
)

type Text

type Text struct {
	Color       color.NRGBA
	Font        string
	Size        float64
	MinSize     float64
	LineHeight  float64
	Align       Align
	Overflow    Overflow
	Area        Rect
	PhraseBreak bool
	Locale      string
	Weight      int
	AutoArea    bool
}

type TextInput

type TextInput struct {
	Color       *color.NRGBA
	Font        *string
	Size        *float64
	MinSize     *float64
	LineHeight  *float64
	Align       *Align
	Overflow    *Overflow
	Area        *Rect
	PhraseBreak *bool
	Locale      *string
	Weight      *int
	AutoArea    *bool
}

type Theme

type Theme struct {
	Name               Name
	Layout             LayoutMode
	Width              int
	Height             int
	Background         color.NRGBA
	BackgroundGradient *BackgroundGradient
	Avatar             Avatar
	Gradient           Gradient
	Text               Text
	QuoteMark          QuoteMark
	Divider            Divider
	Emoji              Emoji
	DisplayName        Label
	Username           Label
	Watermark          Label
}

func Resolve

func Resolve(input Input) (Theme, error)

type WatermarkPosition

type WatermarkPosition string
const (
	WatermarkAuto         WatermarkPosition = "auto"
	WatermarkBottomRight  WatermarkPosition = "bottom-right"
	WatermarkBottomLeft   WatermarkPosition = "bottom-left"
	WatermarkBottomCenter WatermarkPosition = "bottom-center"
)

Jump to

Keyboard shortcuts

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