mod

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mod stores modification functions for images

Index

Constants

This section is empty.

Variables

FlipX returns a new rgba which is flipped over the horizontal axis.

FlipY returns a new rgba which is flipped over the vertical axis.

Rotate180 performs a specialized rotation for 180 degrees.

Rotate270 performs a specialized rotation for 270 degrees.

Rotate90 performs a specialized rotation for 360 degrees.

Transpose flips horizontally and rotates 90 degrees counter clockwise.

Transverse flips vertically and rotates 90 degrees counter clockwise.

Functions

func Zoom

func Zoom(xPerc, yPerc, zoom float64) func(rgba image.Image) *image.RGBA

Zoom zooms into a position on the input image. The position is determined by the input percentages, and how far the zoom is deep depends on the input zoom level-- 2.0 would quarter the number of unique pixels from the input to the output.

Types

type Filter

type Filter func(*image.RGBA)

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 AndFilter

func AndFilter(fs ...Filter) Filter

AndFilter combines multiple filters into one.

func ApplyColor

func ApplyColor(c color.Color) Filter

ApplyColor mixes a color into the rgba values of an image and returns that new rgba.

func ApplyMask

func ApplyMask(img image.RGBA) Filter

ApplyMask mixes the rgba values of two images, according to their alpha levels, and returns that as a new rgba.

func Brighten

func Brighten(brightenBy float32) Filter

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

func ColorBalance(r, g, b float32) Filter

ColorBalance takes in 3 numbers between -100 and 500 and applies it to the given image

func ConformToPallete

func ConformToPallete(p color.Model) Filter

ConformToPallete is not a modification, but acts like ConformToPallete without allocating a new *image.RGBA

func Fade

func Fade(alpha int) Filter

Fade reduces the alpha of an image

func FillMask

func FillMask(img image.RGBA) Filter

FillMask replaces alpha 0 pixels in an RGBA with corresponding pixels in a second RGBA.

func GiftFilter

func GiftFilter(fs ...gift.Filter) Filter

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 InPlace

func InPlace(m Mod) Filter

InPlace converts a Mod to a Filter.

func Saturate

func Saturate(saturateBy float32) Filter

Saturate saturates the input between -100 and 500 percent.

type Mod

type Mod func(image.Image) *image.RGBA

A Mod takes an image and returns that image transformed in some way.

func And

func And(ms ...Mod) Mod

And chains together multiple Mods into a single Mod

func Crop

func Crop(rect image.Rectangle) Mod

Crop will return the given rectangle portion of transformed images. See gift.Crop

func CropToSize

func CropToSize(width, height int, anchor gift.Anchor) Mod

CropToSize applies crop with an optional anchor. See gift.CropToSize

func Cut

func Cut(newWidth, newHeight int) Mod

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

func CutFn(xMod, yMod, wMod, hMod func(int) int) Mod

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

func CutFromLeft(newWidth, newHeight int) Mod

CutFromLeft acts like cut but removes from the left hand side rather than the right

func CutRel

func CutRel(relWidth, relHeight float64) Mod

CutRel acts like Cut, but takes in a multiplier on the existing dimensions of the image.

func CutRound

func CutRound(xOff, yOff float64) Mod

CutRound rounds the edges of the Modifiable with Bezier curves. Todo: We have a nice bezier toolkit now, so use it here

func GiftTransform

func GiftTransform(fs ...gift.Filter) Mod

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

func ResizeToFill(width, height int, resampling gift.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 gift.Resampling) Mod

ResizeToFit will resize while perserving aspect ratio. See gift.ResizeToFit.

func Rotate

func Rotate(degrees float32) Mod

Rotate returns a rotated rgba.

func RotateBackground

func RotateBackground(degrees float32, bckgrnd color.Color, interpolation gift.Interpolation) Mod

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.

func Scale

func Scale(xRatio, yRatio float64) Mod

Scale returns a scaled rgba.

func TrimColor

func TrimColor(trimUnder color.Color) Mod

TrimColor will trim inputs so that any rows or columns where each pixel is less than or equal to the input color are removed. This will change the dimensions of the image.

type Transform

type Transform = Mod

A Transform is a longer name for writing Mod

Jump to

Keyboard shortcuts

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