Documentation ¶
Overview ¶
Package applies randomized glitch effects to images. Effects can be applied to individual images or applied in sequences for animatons.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ColorShift ¶ added in v0.4.0
type ColorShift struct { Rect image.Rectangle MaxHeight int MaxShift int N int // contains filtered or unexported fields }
Colorshift represents an effect that moves blocks randomly left and right by shifting color channels.
Example ¶
package main import ( "log" "github.com/keithroger/imgge" ) func main() { // Import jpeg using included function img, err := imgge.JpegToImage("images/original.jpg") if err != nil { log.Fatal(err) } // Create and Apply Effect effect := imgge.NewColorShift(img.Bounds(), 20, 30, 25) effect.Apply(img) // Export to png using included function err = imgge.SaveAsPng("ColorShift.png", img) if err != nil { log.Fatal(err) } }
Output:
func NewColorShift ¶ added in v0.4.0
func NewColorShift(r image.Rectangle, maxHeight, maxShift, n int) *ColorShift
NewColorShift creates a Colorshift struct. The Effect will be drawn within the rectangle r with shifted blocks max height of maxHeight and max horizontal shift of maxShift.
func (*ColorShift) Apply ¶ added in v0.4.0
func (c *ColorShift) Apply(img draw.Image)
Apply shifts sections of the image according to the stucts settings.
func (*ColorShift) Next ¶ added in v0.4.3
func (c *ColorShift) Next()
Next makes small random changes to the position of the shifted blocks.
func (*ColorShift) Randomize ¶ added in v0.4.0
func (c *ColorShift) Randomize()
Randomize reinitializes the positions of the shifted blocks.
type Effect ¶
type Effect interface { // Draws the effect to the image with with the current settings defined by the struct. Apply(draw.Image) // Next makes small variations to the effect. // Use in a sequence of images to produce an animated effect. Next() // Resets random components of effect. Randomize() }
Effect provides methods for applying effects and randomization.
type PixelPop ¶ added in v0.4.0
type PixelPop struct { Rect image.Rectangle MinSize, MaxSize int N int // contains filtered or unexported fields }
PixelPop represents an effect that makes random pixels and draws a square of the same color.
Example ¶
package main import ( "log" "github.com/keithroger/imgge" ) func main() { // Import jpeg using included function img, err := imgge.JpegToImage("images/original.jpg") if err != nil { log.Fatal(err) } // Create and Apply Effect effect := imgge.NewPixelPop(img.Bounds(), 15, 50, 100) effect.Apply(img) // Export to png using included function err = imgge.SaveAsPng("PixelPop.png", img) if err != nil { log.Fatal(err) } }
Output:
func NewPixelPop ¶ added in v0.4.0
NewPixelPop returns a PixelPop struct.
func (*PixelPop) Apply ¶ added in v0.4.0
Apply selects random pixels in the image and draws them as squares.
type PixelSort ¶ added in v0.4.0
type PixelSort struct { Rect image.Rectangle MaxLen int N int Orientation string // contains filtered or unexported fields }
Pixelsort represents an Effect that moves sorts lines of pixels.
Example ¶
package main import ( "log" "github.com/keithroger/imgge" ) func main() { // Import jpeg using included function img, err := imgge.JpegToImage("images/original.jpg") if err != nil { log.Fatal(err) } // Create and Apply Effect effect := imgge.NewPixelSort(img.Bounds(), 50, 100, "horiz") effect.Apply(img) // Export to png using included function err = imgge.SaveAsPng("PixelSort.png", img) if err != nil { log.Fatal(err) } }
Output:
func NewPixelSort ¶ added in v0.4.0
NewPixelSort returns a new PixelSort Effect.
type Shift ¶ added in v0.4.0
type Shift struct { Rect image.Rectangle MaxHeight int MaxShift int N int // contains filtered or unexported fields }
Shift represents an effect that moves blocks within the images randomly left or right
Example ¶
package main import ( "log" "github.com/keithroger/imgge" ) func main() { // Import jpeg using included function img, err := imgge.JpegToImage("images/original.jpg") if err != nil { log.Fatal(err) } // Create and Apply Effect effect := imgge.NewShift(img.Bounds(), 20, 30, 22) effect.Apply(img) // Export to png using included function err = imgge.SaveAsPng("Shift.png", img) if err != nil { log.Fatal(err) } }
Output:
func NewShift ¶ added in v0.4.0
NewShift creates a Shift struct. The Effect will be drawn within the rectangle r with shifted blocks max height of maxHeight and max horizontal shift of maxShift.
func (*Shift) Apply ¶ added in v0.4.0
Apply shifts sections of the image according to the Shift settings.