utils

package
v0.0.0-...-4c8cea9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePixelsExact

func ComparePixelsExact(imageA *image.RGBA, imageB *image.RGBA, globalBounds image.Rectangle) (float64, error)

ComparePixelsExact naively compares two images by checking how many of the pixels between them are identical. It returns a float that ranges between 0 (no matches) and 1 (identical pictures)

func ComparePixelsWeighted

func ComparePixelsWeighted(imageA *image.RGBA, imageB *image.RGBA, globalBounds image.Rectangle) (float64, error)

func FillSpace

func FillSpace(img *image.RGBA, nonTransparentImageBounds image.Rectangle)

FillSpace fills everything in img that doesn't fall within nonTransparentImageBounds with the scaled out edges and corners of img when masked by nonTransparentImageBounds

func HorizontalLine

func HorizontalLine(img *image.RGBA, xStart int, xEnd int, y int, c color.Color)

HorizontalLine draws a horizontal line onto an image

func InRange

func InRange(number1 float64, number2 float64, maxRange float64) bool

InRange returns wether two numbers are up to a maximum range away from each other

func PointCollides

func PointCollides(p image.Point, r image.Rectangle) bool

PointCollides returns true if p collides with r

func ReadImage

func ReadImage(path string) (img image.Image, err error)

ReadImage Takes the path to an image file in the file system and returns the decoded image

func ReadImageFromBytes

func ReadImageFromBytes(imageBytes []byte) (img image.Image, err error)

ReadImageFromBytes that a byte slice and attempts to decode it into an image

func ReadImageFromReader

func ReadImageFromReader(reader io.Reader) (img image.Image, err error)

ReadImageFromReader takes an io.Reader and attempts to decode it into an image

func Rectangle

func Rectangle(img *image.RGBA, rectangle image.Rectangle, c color.Color, fillColor color.Color)

Rectangle draws a rectangle onto an image

func RectanglesCollide

func RectanglesCollide(r1 image.Rectangle, r2 image.Rectangle) bool

RectanglesCollide returns true if r1 and r2 collide

func Scale

func Scale(img *image.RGBA, bounds image.Rectangle, interpolator draw.Interpolator) image.Image

Scale scales a given image to the desired dimensions

func VerticalLine

func VerticalLine(img *image.RGBA, yStart int, yEnd int, x int, c color.Color)

VerticalLine draws a vertical line onto an image

func WriteFile

func WriteFile(filePath string, reader io.Reader) error

WriteFile writes data from an io.Reader to filePath

func WriteImage

func WriteImage(img image.Image, writer io.Writer, extension string) (err error)

WriteImage encodes an image as either PNG or JPEG according to extension and writes it to writer. Note: extension needs to be prepended with a dot.

func WriteImageToFile

func WriteImageToFile(img image.Image, filePath string) error

WriteImageToFile encodes an image as either PNG or JPEG according to the extension of filePath and writes it to filePath.

Types

type FillConfig

type FillConfig struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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