background

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DarkColor is the default dark mode background color
	DarkColor = color.RGBA{R: 30, G: 30, B: 30, A: 255}
	// LightColor is the default light mode background color
	LightColor = color.RGBA{R: 240, G: 240, B: 240, A: 255}
)

Functions

This section is empty.

Types

type Background

type Background interface {
	// Render applies the background to the given content image
	// It returns a new image with the background applied
	Render(content image.Image) image.Image

	// SetCornerRadius sets the corner radius for the background
	SetCornerRadius(radius float64) Background

	// SetShadow sets the shadow configuration for the background
	SetShadow(shadow Shadow) Background
}

Background represents any type that can be used as a background

type ColorBackground

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

ColorBackground represents a solid color background

func NewColorBackground

func NewColorBackground() ColorBackground

NewColorBackground creates a new ColorBackground with the given color

func (ColorBackground) Render

func (bg ColorBackground) Render(content image.Image) image.Image

Render applies the background to the given content image It returns a new image with the background applied and the content centered

func (ColorBackground) SetColor

func (bg ColorBackground) SetColor(c color.Color) ColorBackground

SetColor sets the background color

func (ColorBackground) SetCornerRadius

func (bg ColorBackground) SetCornerRadius(radius float64) Background

SetCornerRadius sets the corner radius for the background

func (ColorBackground) SetPadding

func (bg ColorBackground) SetPadding(value int) ColorBackground

SetPadding sets equal padding for all sides

func (ColorBackground) SetPaddingDetailed

func (bg ColorBackground) SetPaddingDetailed(top, right, bottom, left int) ColorBackground

SetPaddingDetailed sets detailed padding for each side

func (ColorBackground) SetShadow

func (bg ColorBackground) SetShadow(shadow Shadow) Background

SetShadow sets the shadow configuration for the background

type GradientBackground

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

GradientBackground represents a gradient background

func NewGradientBackground

func NewGradientBackground(gradientType GradientType, stops ...GradientStop) GradientBackground

NewGradientBackground creates a new GradientBackground

func (GradientBackground) Render

func (bg GradientBackground) Render(content image.Image) image.Image

Render applies the gradient background to the given content image

func (GradientBackground) SetAngle

func (bg GradientBackground) SetAngle(angle float64) GradientBackground

SetAngle sets the angle for linear gradients (in degrees)

func (GradientBackground) SetCenter

func (bg GradientBackground) SetCenter(x, y float64) GradientBackground

SetCenter sets the center point for radial and angular gradients

func (GradientBackground) SetCornerRadius

func (bg GradientBackground) SetCornerRadius(radius float64) Background

SetCornerRadius sets the corner radius for the background

func (GradientBackground) SetIntensity

func (bg GradientBackground) SetIntensity(intensity float64) GradientBackground

SetIntensity sets the intensity modifier for special gradients

func (GradientBackground) SetPadding

func (bg GradientBackground) SetPadding(value int) GradientBackground

SetPadding sets equal padding for all sides

func (GradientBackground) SetPaddingDetailed

func (bg GradientBackground) SetPaddingDetailed(top, right, bottom, left int) GradientBackground

SetPaddingDetailed sets detailed padding for each side

func (GradientBackground) SetShadow

func (bg GradientBackground) SetShadow(shadow Shadow) Background

SetShadow sets the shadow configuration for the background

type GradientStop

type GradientStop struct {
	Color    color.Color
	Position float64 // Position between 0 and 1
}

GradientStop represents a color stop in a gradient

type GradientType

type GradientType int

GradientType represents the type of gradient

const (
	// LinearGradient represents a linear gradient
	LinearGradient GradientType = iota
	// RadialGradient represents a radial gradient
	RadialGradient
	// AngularGradient represents an angular/conic gradient
	AngularGradient
	// DiamondGradient represents a diamond-shaped gradient
	DiamondGradient
	// SpiralGradient represents a spiral-shaped gradient
	SpiralGradient
	// SquareGradient represents a square-shaped gradient
	SquareGradient
	// StarGradient represents a star-shaped gradient
	StarGradient
)

type ImageBackground

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

ImageBackground represents an image background

func NewImageBackground

func NewImageBackground(img image.Image) ImageBackground

NewImageBackground creates a new ImageBackground

func (ImageBackground) Render

func (bg ImageBackground) Render(content image.Image) image.Image

Render applies the image background to the given content image

func (ImageBackground) SetBlurRadius

func (bg ImageBackground) SetBlurRadius(radius float64) ImageBackground

SetBlurRadius sets the blur radius for the background image

func (ImageBackground) SetCornerRadius

func (bg ImageBackground) SetCornerRadius(radius float64) Background

SetCornerRadius sets the corner radius for the background

func (ImageBackground) SetOpacity

func (bg ImageBackground) SetOpacity(opacity float64) ImageBackground

SetOpacity sets the opacity of the background image (0.0 - 1.0)

func (ImageBackground) SetPadding

func (bg ImageBackground) SetPadding(value int) ImageBackground

SetPadding sets equal padding for all sides

func (ImageBackground) SetPaddingDetailed

func (bg ImageBackground) SetPaddingDetailed(top, right, bottom, left int) ImageBackground

SetPaddingDetailed sets detailed padding for each side

func (ImageBackground) SetScaleMode

func (bg ImageBackground) SetScaleMode(mode ImageScaleMode) ImageBackground

SetScaleMode sets the scaling mode for the image

func (ImageBackground) SetShadow

func (bg ImageBackground) SetShadow(shadow Shadow) Background

SetShadow sets the shadow configuration for the background

type ImageScaleMode

type ImageScaleMode int

ImageScaleMode determines how the image is scaled to fit the background

const (
	// ImageScaleFit scales the image to fit within the bounds while maintaining aspect ratio
	ImageScaleFit ImageScaleMode = iota
	// ImageScaleFill scales the image to fill the bounds while maintaining aspect ratio
	ImageScaleFill
	// ImageScaleCover scales the image to cover the entire area while maintaining aspect ratio (like CSS background-size: cover)
	ImageScaleCover
	// ImageScaleStretch stretches the image to exactly fit the bounds
	ImageScaleStretch
	// ImageScaleTile repeats the image to fill the bounds
	ImageScaleTile
)

type Padding

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

Padding represents padding values for a background

func NewPadding

func NewPadding(value int) Padding

NewPadding creates a new Padding with equal values on all sides

func NewPaddingHV

func NewPaddingHV(horizontal, vertical int) Padding

NewPaddingHV creates a new Padding with equal horizontal and vertical values

func (Padding) ToPoint

func (p Padding) ToPoint() image.Point

ToPoint converts the padding to an image.Point for compatibility This uses the horizontal (Left) and vertical (Top) values

type Shadow

type Shadow interface {
	// SetOffset sets the X and Y offset of the shadow
	SetOffset(x, y float64) Shadow

	// SetBlur sets the blur radius of the shadow
	SetBlur(radius float64) Shadow

	// SetSpread sets the spread radius of the shadow
	SetSpread(radius float64) Shadow

	// SetColor sets the color of the shadow
	SetColor(c color.Color) Shadow

	// SetCornerRadius sets the corner radius of the shadow
	SetCornerRadius(radius float64) Shadow

	// Apply applies the shadow effect to the given image
	Apply(img image.Image) image.Image
}

Shadow represents a shadow configuration that can be applied to a background

func NewShadow

func NewShadow() Shadow

NewShadow creates a new shadow with default values

Jump to

Keyboard shortcuts

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