giftxt

package module
v0.0.0-...-379b151 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2018 License: MIT Imports: 13 Imported by: 0

README

giftxt

giftxt generates black and white gif from text. It has a web service and a gif telegram inline bot implemented. giftxt also has a heroku configuration to deploy it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClampedInt

func ClampedInt(value, min, max int) int

ClampedInt returns a clamped integer where if value > max it returns max or if val < min then it returns min.

func ClampedStringLength

func ClampedStringLength(text string, max int) int

ClampedStringLength returns the clamped length of the string to max cache length available.

func GetAdjustedFontSize

func GetAdjustedFontSize(local *truetype.Font, text string, max int32) float64

GetAdjustedFontSize returns the adjusted font size for a given message.

func GetColoredImage

func GetColoredImage(paint color.Color) *image.Paletted

GetColoredImage returns base image to use while drawing.

func GetFaceFromFontAndSize

func GetFaceFromFontAndSize(local *truetype.Font, fontSize float64) *font.Face

GetFaceFromFontAndSize returns a face from a font and font size.

func GetLongestWord

func GetLongestWord(words []string) string

GetLongestWord returns the longest word from a given slice of words.

func GetWordsFromString

func GetWordsFromString(str string) []string

GetWordsFromString returns a slice containing the words of a given string.

func LoadTypeFace

func LoadTypeFace(fontfile string) *truetype.Font

LoadTypeFace loads a font from file and returns it. Font file cannot be customized.

func MakeGif

func MakeGif(frames []*image.Paletted, delay int) *gif.GIF

MakeGif returns a GIF from a set of Paletted frames,

func MeasureStringLength

func MeasureStringLength(local *truetype.Font, size float64, text string) (fixed.Int26_6, *font.Face)

MeasureStringLength measures the length of the string and the font face.

func NewBlankImage

func NewBlankImage() *image.Paletted

NewBlankImage returns a blank new Image

func ProcessText

func ProcessText(str string) string

ProcessText processes text before making a message out of it.

func RenderMessage

func RenderMessage(face *font.Face, words []string) []*image.Paletted

RenderMessage renders the entire message and returns frames

func RenderSingleWord

func RenderSingleWord(face *font.Face, word string) *image.Paletted

RenderSingleWord renders the word onto an image with colorBg

func Stitch

func Stitch(frames []*image.Paletted, delay int, writer io.Writer)

Stitch simply stitches all frames into a GIF and writes it stream.

Types

type FontFaceCache

type FontFaceCache struct {
	CacheMap   map[int]float64
	Till       int
	CanvasSize int32
}

FontFaceCache is struct that holds a precalculated set of font faces.

func GetFontSizeCrossMap

func GetFontSizeCrossMap(local *truetype.Font, size int32, till int) *FontFaceCache

GetFontSizeCrossMap generates a cross reference map for the length vs. font face

func LoadFontFaceCache

func LoadFontFaceCache(reader io.Reader) (*FontFaceCache, error)

LoadFontFaceCache loads a FontFaceCache and returns it

func (*FontFaceCache) Export

func (context *FontFaceCache) Export(writer io.Writer) error

Export serializes the current object in gob encoding

func (*FontFaceCache) GetFace

func (context *FontFaceCache) GetFace(local *truetype.Font, length int) *font.Face

GetFace returns a font face from font size.

func (*FontFaceCache) GetFontSize

func (context *FontFaceCache) GetFontSize(length int) float64

GetFontSize returns a font size from font size.

type Message

type Message struct {
	Text    string
	Words   []string
	Longest string
}

Message is a struct indicating the structure of an incoming message.

func NewMessage

func NewMessage(str string) *Message

NewMessage returns pointer to new initialized Message struct.

Directories

Path Synopsis
cmd
precache command
telegram command
web command

Jump to

Keyboard shortcuts

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