rgbrender

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignPosition

func AlignPosition(align Align, bounds image.Rectangle, sizeX int, sizeY int) (image.Rectangle, error)

AlignPosition returns image.Rectangle bounds for an image within a given bounds

func DefaultFont

func DefaultFont() (*truetype.Font, error)

DefaultFont ...

func DrawImage

func DrawImage(canvas *rgb.Canvas, bounds image.Rectangle, img image.Image) error

DrawImage draws an image

func DrawImageAligned

func DrawImageAligned(canvas *rgb.Canvas, bounds image.Rectangle, img *image.RGBA, align Align) error

DrawImageAligned draws an image aligned within the given bounds

func DrawRectangle

func DrawRectangle(canvas *rgb.Canvas, startX int, startY int, sizeX int, sizeY int, fillColor color.Color) error

DrawRectangle ...

func FontFromAsset

func FontFromAsset(asset string) (*truetype.Font, error)

FontFromAsset ...

func PlayGIF

func PlayGIF(ctx context.Context, canvas *rgb.Canvas, gif *gif.GIF) error

PlayGIF reads and draw a gif file from r. It use the contained images and delays and loops over it, until a true is sent to the returned chan

func PlayImages

func PlayImages(ctx context.Context, canvas *rgb.Canvas, images []image.Image, delay []time.Duration, loop int) error

PlayImages plays s series of images. If loop == 0, it will play forever until the context is canceled

func ResizeGIF

func ResizeGIF(g *gif.GIF, bounds image.Rectangle, zoom float64) error

ResizeGIF ...

func ResizeImage

func ResizeImage(img image.Image, bounds image.Rectangle, zoom float64) image.Image

ResizeImage ...

func SaveGif

func SaveGif(img *gif.GIF, fileName string) error

SaveGif ...

func SaveGifAfero

func SaveGifAfero(fs afero.Fs, img *gif.GIF, fileName string) error

SaveGifAfero ...

func SavePng

func SavePng(img image.Image, fileName string) error

SavePng ...

func SavePngAfero

func SavePngAfero(fs afero.Fs, img image.Image, fileName string) error

SavePngAfero ...

func SetImageAlign

func SetImageAlign(canvas *rgb.Canvas, align Align, img image.Image) (image.Image, error)

SetImageAlign ...

func ShiftedSize

func ShiftedSize(xStart int, yStart int, bounds image.Rectangle) image.Rectangle

ShiftedSize shifts an image's start location and returns its resulting bounds

func ZoomImageSize

func ZoomImageSize(img image.Image, zoom float64) (int, int)

ZoomImageSize takes a zoom percentage and returns the resulting image size.

Types

type Align

type Align int

Align represents alignment vertically and horizontally

const (
	// CenterCenter ...
	CenterCenter Align = iota
	// CenterTop ...
	CenterTop
	// CenterBottom ...
	CenterBottom
	// RightCenter ...
	RightCenter
	// RightTop ...
	RightTop
	// RightBottom ...
	RightBottom
	// LeftCenter ...
	LeftCenter
	// LeftTop ...
	LeftTop
	// LeftBottom ...
	LeftBottom
)

type TextWriter

type TextWriter struct {
	XStartCorrection int
	YStartCorrection int
	FontSize         float64
	LineSpace        float64
	// contains filtered or unexported fields
}

TextWriter ...

func DefaultTextWriter

func DefaultTextWriter() (*TextWriter, error)

DefaultTextWriter ...

func NewTextWriter

func NewTextWriter(font *truetype.Font, fontSize float64) *TextWriter

NewTextWriter ...

func (*TextWriter) SetFont

func (t *TextWriter) SetFont(fnt *truetype.Font)

SetFont ...

func (*TextWriter) Write

func (t *TextWriter) Write(canvas *rgb.Canvas, bounds image.Rectangle, str []string, clr color.Color) error

Write ...

func (*TextWriter) WriteCentered

func (t *TextWriter) WriteCentered(canvas *rgb.Canvas, bounds image.Rectangle, str []string, clr color.Color) error

WriteCentered writes text in the center of the canvas, horizontally and vertically

Jump to

Keyboard shortcuts

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