util

package
v0.0.0-...-a4aebfb Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoCrop

func AutoCrop(img *image.Paletted) image.Image

func AutoCropGeneric

func AutoCropGeneric(img image.Image) image.Image

remove all alpha-0 pixels from the border of the image

func ClonePalette

func ClonePalette(p color.Palette) color.Palette

func DrawDistortion

func DrawDistortion(screen *ebiten.Image, page *ebiten.Image, source *ebiten.Image, distortion Distortion, options ebiten.DrawImageOptions)

draw 'source' onto 'screen' with a distortion effect * for each segment in 'distortion', make a quad from 'source' where the width is 'source width' / segments in the distortion * the distortion segments define where to place each corner of the quad

func DrawOutline

func DrawOutline(screen *ebiten.Image, imageCache *ImageCache, pic *ebiten.Image, geom ebiten.GeoM, scale ebiten.ColorScale, time uint64, baseColor color.Color)

func DrawRect

func DrawRect(screen *ebiten.Image, rect image.Rectangle, color_ color.Color)

func DrawTextCursor

func DrawTextCursor(screen *ebiten.Image, source *ebiten.Image, cursorX float64, y float64, counter uint64)

func First

func First[T any](slice []T, default_ T) T

func ImageRect

func ImageRect(x int, y int, img *ebiten.Image) image.Rectangle

func Lighten

func Lighten(c color.Color, amount float64) color.Color

func PremultiplyAlpha

func PremultiplyAlpha(c color.RGBA) color.RGBA

func RotateHue

func RotateHue(c color.Color, radian float64) color.Color

func RotateSlice

func RotateSlice[T any](slice []T, forward bool)

func Scale2x

func Scale2x(input image.Image, smooth bool) image.Image

func Scale3x

func Scale3x(input image.Image, smooth bool) image.Image

func ToRGBA

func ToRGBA(c color.Color) color.RGBA

Types

type AlphaFadeFunc

type AlphaFadeFunc func() float32

func MakeFadeIn

func MakeFadeIn(time uint64, counter *uint64) AlphaFadeFunc

func MakeFadeOut

func MakeFadeOut(time uint64, counter *uint64) AlphaFadeFunc

type Animation

type Animation struct {
	Frames       []*ebiten.Image
	CurrentFrame int
	Repeat       int
	// contains filtered or unexported fields
}

func MakeAnimation

func MakeAnimation(frames []*ebiten.Image, loop bool) *Animation

func MakePaletteRotateAnimation

func MakePaletteRotateAnimation(lbxFile *lbx.LbxFile, scaler Scaler, index int, rotateIndexLow int, rotateIndexHigh int) *Animation

create an animation by rotating the colors in a palette for a given lbx/index pair. * all the colors between indexLow and indexHigh will be rotated once in the animation

func MakeRepeatAnimation

func MakeRepeatAnimation(frames []*ebiten.Image, repeats int) *Animation

func MakeReverseAnimation

func MakeReverseAnimation(frames []*ebiten.Image, loop bool) *Animation

func (*Animation) Done

func (animation *Animation) Done() bool

func (*Animation) Frame

func (animation *Animation) Frame() *ebiten.Image

func (*Animation) Next

func (animation *Animation) Next() bool

returns true if there are frames left, otherwise false

type Distortion

type Distortion struct {
	Segments []Segment
	Top      image.Point
	Bottom   image.Point
}

type ImageCache

type ImageCache struct {
	LbxCache *lbx.LbxCache
	// FIXME: have some limit on the number of entries, and remove old ones LRU-style
	Cache map[string][]*ebiten.Image

	ShaderCache map[shaders.Shader]*ebiten.Shader

	Scaler      data.ScaleAlgorithm
	ScaleAmount int
}

func MakeImageCache

func MakeImageCache(lbxCache *lbx.LbxCache) ImageCache

func (*ImageCache) ApplyScale

func (cache *ImageCache) ApplyScale(input image.Image) image.Image

func (*ImageCache) Clear

func (cache *ImageCache) Clear()

remove all entries from the cache

func (*ImageCache) GetImage

func (cache *ImageCache) GetImage(lbxFile string, spriteIndex int, animationIndex int) (*ebiten.Image, error)

func (*ImageCache) GetImageTransform

func (cache *ImageCache) GetImageTransform(lbxFile string, spriteIndex int, animationIndex int, extra string, transform ImageTransformFunc) (*ebiten.Image, error)

func (*ImageCache) GetImages

func (cache *ImageCache) GetImages(lbxPath string, index int) ([]*ebiten.Image, error)

func (*ImageCache) GetImagesTransform

func (cache *ImageCache) GetImagesTransform(lbxPath string, index int, extra string, transform ImageTransformFunc) ([]*ebiten.Image, error)

func (*ImageCache) GetShader

func (cache *ImageCache) GetShader(shader shaders.Shader) (*ebiten.Shader, error)

type ImageTransformFunc

type ImageTransformFunc func(*image.Paletted) image.Image

func ComposeImageTransform

func ComposeImageTransform(transform1 ImageTransformFunc, transform2 ImageTransformGenericFunc) ImageTransformFunc

type ImageTransformGenericFunc

type ImageTransformGenericFunc func(image.Image) image.Image

type Scaler

type Scaler interface {
	ApplyScale(image.Image) image.Image
}

type Segment

type Segment struct {
	Top    image.Point
	Bottom image.Point
}

Jump to

Keyboard shortcuts

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