Documentation
¶
Index ¶
- func ClampedInt(value, min, max int) int
- func ClampedStringLength(text string, max int) int
- func GetAdjustedFontSize(local *truetype.Font, text string, max int32) float64
- func GetColoredImage(paint color.Color) *image.Paletted
- func GetFaceFromFontAndSize(local *truetype.Font, fontSize float64) *font.Face
- func GetLongestWord(words []string) string
- func GetWordsFromString(str string) []string
- func LoadTypeFace(fontfile string) *truetype.Font
- func MakeGif(frames []*image.Paletted, delay int) *gif.GIF
- func MeasureStringLength(local *truetype.Font, size float64, text string) (fixed.Int26_6, *font.Face)
- func NewBlankImage() *image.Paletted
- func ProcessText(str string) string
- func RenderMessage(face *font.Face, words []string) []*image.Paletted
- func RenderSingleWord(face *font.Face, word string) *image.Paletted
- func Stitch(frames []*image.Paletted, delay int, writer io.Writer)
- type FontFaceCache
- type Message
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClampedInt ¶
ClampedInt returns a clamped integer where if value > max it returns max or if val < min then it returns min.
func ClampedStringLength ¶
ClampedStringLength returns the clamped length of the string to max cache length available.
func GetAdjustedFontSize ¶
GetAdjustedFontSize returns the adjusted font size for a given message.
func GetColoredImage ¶
GetColoredImage returns base image to use while drawing.
func GetFaceFromFontAndSize ¶
GetFaceFromFontAndSize returns a face from a font and font size.
func GetLongestWord ¶
GetLongestWord returns the longest word from a given slice of words.
func GetWordsFromString ¶
GetWordsFromString returns a slice containing the words of a given string.
func LoadTypeFace ¶
LoadTypeFace loads a font from file and returns it. Font file cannot be customized.
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 ProcessText ¶
ProcessText processes text before making a message out of it.
func RenderMessage ¶
RenderMessage renders the entire message and returns frames
func RenderSingleWord ¶
RenderSingleWord renders the word onto an image with colorBg
Types ¶
type FontFaceCache ¶
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) GetFontSize ¶
func (context *FontFaceCache) GetFontSize(length int) float64
GetFontSize returns a font size from font size.