Documentation ¶
Overview ¶
Package mod stores modification functions for images
Index ¶
- Variables
- 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 ConformToPallete(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
- 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 GiftTransform(fs ...gift.Filter) Mod
- func Resize(width, height int, resampling gift.Resampling) Mod
- func ResizeToFill(width, height int, resampling gift.Resampling, anchor gift.Anchor) Mod
- func ResizeToFit(width, height int, resampling gift.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 Scale(xRatio, yRatio float64) Mod
- func TrimColor(trimUnder color.Color) Mod
- type Transform
Constants ¶
This section is empty.
Variables ¶
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 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 ConformToPallete ¶
ConformToPallete is not a modification, but acts like ConformToPallete 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.
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. (Consider: use generic int modifiers here so we don't need CutRel and Cut? i.e a function header like Cut(wMod, hMod func(int) int)? )
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 hand side rather than the right
func CutRel ¶
CutRel acts like Cut, but takes in a multiplier on the existing dimensions of the image.
func CutRound ¶
CutRound rounds the edges of the Modifiable with Bezier curves. Todo: We have a nice bezier toolkit now, so use it here
func GiftTransform ¶
GiftTransform converts any set of gift.Filters into a Mod.
func Resize ¶
func Resize(width, height int, resampling gift.Resampling) Mod
Resize will transform images to match the input dimensions. See gift.Resize.
func ResizeToFill ¶
ResizeToFill will resize to fit and then crop using the given anchor. See gift.ResizeToFill.
func ResizeToFit ¶
func ResizeToFit(width, height int, resampling gift.Resampling) Mod
ResizeToFit will resize while perserving 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.