padding

package
v0.0.0-...-2fa1f84 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PaddingGray

func PaddingGray(img *image.Gray, kernelSize image.Point, anchor image.Point, border Border) (*image.Gray, error)

PaddingGray appends padding to a given grayscale image. The size of the padding is calculated from the kernel size and the anchor point. Supported border types are: BorderConstant, BorderReplicate, BorderReflect. Example of usage:

res, err := padding.PaddingGray(img, {5, 5}, {1, 1}, BorderReflect)

Note: this will add a 1px padding for the top and left borders of the image and a 3px padding fot the bottom and right borders of the image.

func PaddingRGBA

func PaddingRGBA(img *image.RGBA, kernelSize image.Point, anchor image.Point, border Border) (*image.RGBA, error)

PaddingRGBA appends padding to a given RGBA image. The size of the padding is calculated from the kernel size and the anchor point. Supported border types are: BorderConstant, BorderReplicate, BorderReflect. Example of usage:

res, err := padding.PaddingRGBA(img, {5, 5}, {1, 1}, BorderReflect)

Note: this will add a 1px padding for the top and left borders of the image and a 3px padding fot the bottom and right borders of the image.

Types

type Border

type Border int

Border is an enum type for supported padding types

const (
	// BorderConstant - xxxabcdefghxxx - where x is a black ( color.Gray{0} ) pixel
	BorderConstant Border = iota
	// BorderReplicate - aaaabcdefghhhh - replicates the nearest pixel
	BorderReplicate
	// BorderReflect - cbabcdefgfed - reflects the nearest pixel group
	BorderReflect
)

type Paddings

type Paddings struct {
	// PaddingLeft is the size of the left padding
	PaddingLeft int
	// PaddingRight is the size of the right padding
	PaddingRight int
	// PaddingTop is the size of the top padding
	PaddingTop int
	// PaddingBottom is the size of the bottom padding
	PaddingBottom int
}

Paddings struct holds the padding sizes for each padding

Jump to

Keyboard shortcuts

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