mod

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package mod stores modification functions for images.

Index

Constants

This section is empty.

Variables

View Source
var BoxResampling = gift.BoxResampling

BoxResampling is a box resampling filter (average of surrounding pixels).

View Source
var CubicResampling = gift.CubicResampling

CubicResampling is a bicubic resampling filter (Catmull-Rom).

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

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

View Source
var LanczosResampling = gift.LanczosResampling

LanczosResampling is a Lanczos resampling filter (3 lobes).

View Source
var LinearResampling = gift.LinearResampling

LinearResampling is a bilinear resampling filter.

View Source
var NearestNeighborResampling = gift.NearestNeighborResampling

NearestNeighborResampling is a nearest neighbor resampling filter.

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. It takes an alpha from 0-255.

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.

func StripOuterAlpha

func StripOuterAlpha(m *image.RGBA, level int) Filter

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

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.

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 and top rather than the right and bottom

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.

func CutShape

func CutShape(sh shape.Shape) Mod

CutShape unsets pixels that are not in the provided shape.

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 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 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 SafeAnd

func SafeAnd(ms ...Mod) Mod

SafeAnd removes any nil mods before passing the resultant set to the And function. It will also return a functional no-op if the mods passed in are all nil.

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 Resampling

type Resampling = gift.Resampling

A Resampling is a strategy for image resizing.

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