Documentation
¶
Overview ¶
Package background composes a backdrop — a solid color, gradient, or image — behind a piece of content, with optional padding, rounded corners, drop shadow, and blur.
Index ¶
- type Background
- func (b *Background) Render(content image.Image) (image.Image, error)
- func (b *Background) WithAngle(deg float64) *Background
- func (b *Background) WithBlur(style BlurStyle, radius float64) *Background
- func (b *Background) WithCenter(x, y float64) *Background
- func (b *Background) WithCornerRadius(r float64) *Background
- func (b *Background) WithIntensity(v float64) *Background
- func (b *Background) WithOpacity(o float64) *Background
- func (b *Background) WithPadding(px int) *Background
- func (b *Background) WithPaddingDetailed(top, right, bottom, left int) *Background
- func (b *Background) WithScaleMode(m ScaleMode) *Background
- func (b *Background) WithShadow(s *Shadow) *Background
- type BlurStyle
- type GradientType
- type Padding
- type ScaleMode
- type Shadow
- type Stop
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Background ¶
type Background struct {
// contains filtered or unexported fields
}
Background is a configurable backdrop. Build one with Solid, Gradient, Image, or ImageFromFile and chain the With* methods.
func Gradient ¶
func Gradient(t GradientType, stops ...Stop) *Background
Gradient creates a gradient backdrop of the given type.
func ImageFromFile ¶
func ImageFromFile(path string) (*Background, error)
ImageFromFile creates an image backdrop from a file on disk.
func (*Background) Render ¶
Render draws the backdrop behind (and around) the content image. A nil content produces just the backdrop at its padding size.
func (*Background) WithAngle ¶
func (b *Background) WithAngle(deg float64) *Background
WithAngle sets the gradient angle in degrees.
func (*Background) WithBlur ¶
func (b *Background) WithBlur(style BlurStyle, radius float64) *Background
WithBlur blurs the backdrop (gradient and image backdrops only).
func (*Background) WithCenter ¶
func (b *Background) WithCenter(x, y float64) *Background
WithCenter sets the gradient center as fractions of the canvas (0-1).
func (*Background) WithCornerRadius ¶
func (b *Background) WithCornerRadius(r float64) *Background
WithCornerRadius rounds the corners of the backdrop.
func (*Background) WithIntensity ¶
func (b *Background) WithIntensity(v float64) *Background
WithIntensity tunes spiral tightness and star point count.
func (*Background) WithOpacity ¶
func (b *Background) WithOpacity(o float64) *Background
WithOpacity sets the opacity of an image backdrop (0-1).
func (*Background) WithPadding ¶
func (b *Background) WithPadding(px int) *Background
WithPadding sets equal padding on all sides.
func (*Background) WithPaddingDetailed ¶
func (b *Background) WithPaddingDetailed(top, right, bottom, left int) *Background
WithPaddingDetailed sets the padding of each side individually.
func (*Background) WithScaleMode ¶
func (b *Background) WithScaleMode(m ScaleMode) *Background
WithScaleMode sets how an image backdrop is fitted.
func (*Background) WithShadow ¶
func (b *Background) WithShadow(s *Shadow) *Background
WithShadow draws a drop shadow behind the content.
type GradientType ¶
type GradientType int
GradientType selects the shape of a gradient backdrop.
const ( LinearGradient GradientType = iota RadialGradient AngularGradient DiamondGradient SpiralGradient SquareGradient StarGradient )
type Padding ¶
type Padding struct {
Top, Right, Bottom, Left int
}
Padding is the space between the content and the canvas edge.
type ScaleMode ¶
type ScaleMode int
ScaleMode controls how an image backdrop is fitted to the canvas.
type Shadow ¶
type Shadow struct {
// contains filtered or unexported fields
}
Shadow describes a drop shadow drawn behind the content.
func (*Shadow) Apply ¶
Apply returns the content composited over its shadow, expanded to fit. cornerRadius should match the corner radius of the content so the shadow hugs its silhouette.
func (*Shadow) WithOffset ¶
WithOffset moves the shadow relative to the content.
func (*Shadow) WithSpread ¶
WithSpread grows the shadow beyond the content bounds.