Documentation ¶
Overview ¶
Package mod stores modification functions for images.
Index ¶
- Variables
- func Darker(c color.Color, f float64) color.Color
- func FadeColor(c color.Color, f float64) color.Color
- func Lighter(c color.Color, f float64) color.Color
- func Zoom(xPerc, yPerc, zoom float64) func(rgba image.Image) *image.RGBA
- type Filter
- func AndFilter(fs ...Filter) Filter
- func ApplyColor(c color.Color) Filter
- func ApplyMask(img image.RGBA) Filter
- func Brighten(brightenBy float32) Filter
- func ColorBalance(r, g, b float32) Filter
- func ConformToPalette(p color.Model) Filter
- func Fade(alpha int) Filter
- func FillMask(img image.RGBA) Filter
- func GiftFilter(fs ...gift.Filter) Filter
- func InPlace(m Mod) Filter
- func Saturate(saturateBy float32) Filter
- func StripOuterAlpha(m *image.RGBA, level int) Filter
- type InsetFilter
- type Mod
- func And(ms ...Mod) Mod
- func Crop(rect image.Rectangle) Mod
- func CropToSize(width, height int, anchor gift.Anchor) Mod
- func Cut(newWidth, newHeight int) Mod
- func CutFn(xMod, yMod, wMod, hMod func(int) int) Mod
- func CutFromLeft(newWidth, newHeight int) Mod
- func CutRel(relWidth, relHeight float64) Mod
- func CutRound(xOff, yOff float64) Mod
- func CutShape(sh shape.Shape) Mod
- func GiftTransform(fs ...gift.Filter) Mod
- func Highlight(c color.Color, thickness int) Mod
- func HighlightOff(c color.Color, thickness, xOff, yOff int) Mod
- func InnerHighlight(c color.Color, thickness int) Mod
- func InnerHighlightOff(c color.Color, thickness, xOff, yOff int) Mod
- func Inset(fn InsetFilter, dir intgeom.Dir2) Mod
- func Resize(width, height int, resampling Resampling) Mod
- func ResizeToFill(width, height int, resampling Resampling, anchor gift.Anchor) Mod
- func ResizeToFit(width, height int, resampling Resampling) Mod
- func Rotate(degrees float32) Mod
- func RotateBackground(degrees float32, bckgrnd color.Color, interpolation gift.Interpolation) Mod
- func RotateInterpolated(degrees float32, interpolation gift.Interpolation) Mod
- func SafeAnd(ms ...Mod) Mod
- func Scale(xRatio, yRatio float64) Mod
- func TrimColor(trimUnder color.Color) Mod
- type Resampling
- type Transform
Constants ¶
This section is empty.
Variables ¶
var BoxResampling = gift.BoxResampling
BoxResampling is a box resampling filter (average of surrounding pixels).
var CubicResampling = gift.CubicResampling
CubicResampling is a bicubic resampling filter (Catmull-Rom).
var FlipX = GiftTransform(gift.FlipHorizontal())
FlipX returns a new rgba which is flipped over the horizontal axis.
var FlipY = GiftTransform(gift.FlipVertical())
FlipY returns a new rgba which is flipped over the vertical axis.
var LanczosResampling = gift.LanczosResampling
LanczosResampling is a Lanczos resampling filter (3 lobes).
var LinearResampling = gift.LinearResampling
LinearResampling is a bilinear resampling filter.
var NearestNeighborResampling = gift.NearestNeighborResampling
NearestNeighborResampling is a nearest neighbor resampling filter.
var Rotate180 = GiftTransform(gift.Rotate180())
Rotate180 performs a specialized rotation for 180 degrees.
var Rotate270 = GiftTransform(gift.Rotate270())
Rotate270 performs a specialized rotation for 270 degrees.
var Rotate90 = GiftTransform(gift.Rotate90())
Rotate90 performs a specialized rotation for 360 degrees.
var Transpose = GiftTransform(gift.Transpose())
Transpose flips horizontally and rotates 90 degrees counter clockwise.
var Transverse = GiftTransform(gift.Transverse())
Transverse flips vertically and rotates 90 degrees counter clockwise.
Functions ¶
Types ¶
type Filter ¶
A Filter modifies an input image in place. This is useful notably for modifying a screen buffer, as they will refuse to be modified in any other way. This cannot change the dimensions of the underlying image.
func ApplyColor ¶
ApplyColor mixes a color into the rgba values of an image and returns that new rgba.
func ApplyMask ¶
ApplyMask mixes the rgba values of two images, according to their alpha levels, and returns that as a new rgba.
func Brighten ¶
Brighten brightens an image between -100 and 100. 100 will be solid white, -100 will be solid black, for all colors not zero before filtering.
func ColorBalance ¶
ColorBalance takes in 3 numbers between -100 and 500 and applies it to the given image
func ConformToPalette ¶
ConformToPalette( is not a modification, but acts like ConformToPalette( without allocating a new *image.RGBA
func FillMask ¶
FillMask replaces alpha 0 pixels in an RGBA with corresponding pixels in a second RGBA.
func GiftFilter ¶
GiftFilter converts any set of gift.Filters into a Filter. if a filter is internally a transformation in gift, this will not work and GiftTransform should be used instead.
func StripOuterAlpha ¶
StripOuterAlpha from the image given a source image and a alpha level to denote stripping. Note that this was implemented for ease of implementation but not speed. We could use image lib or a real depth first search to do fewer checks but this is easier...
type Mod ¶
A Mod takes an image and returns that image transformed in some way.
func CropToSize ¶
CropToSize applies crop with an optional anchor. See gift.CropToSize
func Cut ¶
Cut reduces (or increases, adding nothing) the dimensions of the input image, setting them to newWidth and newHeight.
func CutFn ¶
CutFn can reduce or add blank space to an input image. Each input function decides the starting location or offset of a cut.
func CutFromLeft ¶
CutFromLeft acts like cut but removes from the left and top rather than the right and bottom
func CutRel ¶
CutRel acts like Cut, but takes in a multiplier on the existing dimensions of the image.
func GiftTransform ¶
GiftTransform converts any set of gift.Filters into a Mod.
func Resize ¶
func Resize(width, height int, resampling Resampling) Mod
Resize will transform images to match the input dimensions. See gift.Resize.
func ResizeToFill ¶
func ResizeToFill(width, height int, resampling Resampling, anchor gift.Anchor) Mod
ResizeToFill will resize to fit and then crop using the given anchor. See gift.ResizeToFill.
func ResizeToFit ¶
func ResizeToFit(width, height int, resampling Resampling) Mod
ResizeToFit will resize while preserving aspect ratio. See gift.ResizeToFit.
func RotateBackground ¶
RotateBackground acts as RotateInterpolated, but allows for supplying a specific background color to the rotation.
func RotateInterpolated ¶
func RotateInterpolated(degrees float32, interpolation gift.Interpolation) Mod
RotateInterpolated acts as Rotate, but accepts an interpolation argument. standard rotation does this with Cubic Interpolation.