graphics

package
v0.0.0-...-6d09ece Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Font

type Font struct {
	Name string
	Size XY
	// contains filtered or unexported fields
}

func NewFontFromIndex

func NewFontFromIndex(name string, characterSize XY, canvas Image) Font

func NewFontFromIndexFile

func NewFontFromIndexFile(path string) (Font, error)

type Image

type Image struct {
	Size XY
	// contains filtered or unexported fields
}

func Cover

func Cover(background, foreground Image, at XY) (Image, error)

Cover places a 'foreground' Image over the 'background' Image. Use 'at' to specify the top-left corner into which the foreground should be placed. Use CoverWithPosition to use relative positioning.

Returns OverflowError in case the foreground overflows the background; you may decide to ignore this error.

func CoverWithPosition

func CoverWithPosition(background, foreground Image, at XY, position Position) (Image, error)

CoverWithPosition places a 'foreground' Image over the 'background' Image. Use 'at' to specify the top-left corner into which the foreground should be placed.

Returns OverflowError in case the foreground overflows the background; you may decide to ignore this error.

func Crop

func Crop(image Image, at, size XY) (Image, error)

func CropWithPosition

func CropWithPosition(image Image, at, size XY, position Position) (Image, error)

func ImportImage

func ImportImage(size XY, path string) (Image, error)

ImportImage loads a PNG/JPEG file and converts it to an Image.

func Invert

func Invert(image Image) Image

Invert switches up blacks and whites.

func NewBlackImage

func NewBlackImage(size XY) Image

NewBlackImage creates a fully black image of given size.

func NewImage

func NewImage(size XY, data []byte) (Image, error)

NewImage loads up an Image from a raw binary file.

func NewWhiteImage

func NewWhiteImage(size XY) Image

NewWhiteImage creates a fully white image of given size.

func Render

func Render(text string, font Font) Image

func (Image) ASCII

func (i Image) ASCII() string

func (Image) Encode

func (i Image) Encode() []byte

Encode writes out the Image as a byte string.

func (Image) Export

func (i Image) Export(path string) error

Export converts the image into a PNG file.

func (Image) ExportWithScale

func (i Image) ExportWithScale(path string, scale int) error

Export converts the image into a PNG file, with optional scale to increase the size of the image.

func (Image) String

func (i Image) String() string

type OverflowError

type OverflowError struct {
	Xp uint
	Xn uint
	Yp uint
	Yn uint
}

func (*OverflowError) Error

func (e *OverflowError) Error() string

type Position

type Position int
const (
	TOP_LEFT Position = iota + 1
	TOP_CENTER
	TOP_RIGHT
	MIDDLE_LEFT
	CENTER
	MIDDLE_RIGHT
	BOTTOM_LEFT
	BOTTOM_CENTER
	BOTTOM_RIGHT
)

type XY

type XY struct {
	X int
	Y int
}

func NewXY

func NewXY(from string) (XY, error)

func (XY) String

func (xy XY) String() string

Jump to

Keyboard shortcuts

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