Documentation ¶
Overview ¶
Package cutils provides common parsing/conversion code for components to cut down on duplication
Index ¶
- func CombineErrors(history, latest error) error
- func ExclusiveNor(args ...bool) bool
- func ExclusiveOr(args ...bool) bool
- func ExtractFloat(raw, name string, props map[string][]string) (float64, map[string][]string, error)
- func ExtractInt(raw, name string, props map[string][]string) (int, map[string][]string, error)
- func ExtractString(raw, name string, props map[string][]string) (string, map[string][]string, error)
- func LoadFontFile(fs vfs.FileSystem, fileName interface{}) (*truetype.Font, error)
- func ParseColourStrings(colours ColourStrings, prefix string, inputProps map[string][]string) (color.NRGBA, map[string][]string, error)
- func ParseFont(fontName, fileName, url string, opts ParseFontOptions) (*truetype.Font, map[string][]string, error)
- func ParsePoint(x, y, xName, yName string, props map[string][]string) (image.Point, map[string][]string, error)
- func ScaleFontsToWidth(currentSize float64, currentWidth, maxWidth int, alignment TextAlignment) (newSize float64, alignmentOffset int)
- func SetBool(value interface{}) (bool, error)
- func SetColour(value interface{}) (color.Color, error)
- func SetFloat64(value interface{}) (float64, error)
- func SetImage(value interface{}) (image.Image, error)
- func SetInt(value interface{}) (int, error)
- func SetString(value interface{}) (string, error)
- func SetTime(value interface{}) (time.Time, error)
- func SetTimePointer(value interface{}) (*time.Time, error)
- func SetUint8(value interface{}) (uint8, error)
- type ColourStrings
- type ParseFontOptions
- type TextAlignment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombineErrors ¶
CombineErrors combines two errors, maintaining a history of errors separated by newlines
func ExclusiveNor ¶
ExclusiveNor returns false if one and only one of the passed in booleans is true
func ExclusiveOr ¶
ExclusiveOr returns true if one and only one of the passed in booleans is true
func ExtractFloat ¶
func ExtractFloat(raw, name string, props map[string][]string) (float64, map[string][]string, error)
ExtractFloat extracts a flot64 or variable(s) from the raw JSON data
func ExtractInt ¶
ExtractInt extracts an integer or variable(s) from the raw JSON data
func ExtractString ¶
func ExtractString(raw, name string, props map[string][]string) (string, map[string][]string, error)
ExtractString extracts a string or variable(s) from the raw JSON data
func LoadFontFile ¶
func LoadFontFile(fs vfs.FileSystem, fileName interface{}) (*truetype.Font, error)
LoadFontFile returns the font file found at the specified path on the specified file system
func ParseColourStrings ¶
func ParseColourStrings(colours ColourStrings, prefix string, inputProps map[string][]string) (color.NRGBA, map[string][]string, error)
ParseColourStrings turns a set of colour strings and an optional identifying prefix representing a colour channel each into a color.NRGBA struct
func ParseFont ¶
func ParseFont(fontName, fileName, url string, opts ParseFontOptions) (*truetype.Font, map[string][]string, error)
ParseFont turns a font name, file path or url into a truetype font
func ParsePoint ¶
func ParsePoint(x, y, xName, yName string, props map[string][]string) (image.Point, map[string][]string, error)
ParsePoint turns an X and Y string into an image.Point
func ScaleFontsToWidth ¶
func ScaleFontsToWidth(currentSize float64, currentWidth, maxWidth int, alignment TextAlignment) (newSize float64, alignmentOffset int)
ScaleFontsToWidth scales the input float to match the font size and alignment parameters
func SetFloat64 ¶
SetFloat64 turns an interface into a float64 and an error
func SetTimePointer ¶
SetTimePointer turns an interface into a time pointer and an error
Types ¶
type ColourStrings ¶
type ColourStrings struct {
// R, G, B, A are the colour channels
R, G, B, A string
}
ColourStrings is an RGBA set of strings
type ParseFontOptions ¶
type ParseFontOptions struct { // Props is the initial named properties map Props map[string][]string // FileSystem is the vfs FileSystem to use FileSystem vfs.FileSystem // FontPool is the gosysfonts Pool to use FontPool gosysfonts.Pool }
ParseFontOptions are the optional parameters for ParseFont
type TextAlignment ¶
type TextAlignment int
TextAlignment is a text alignment.
const ( // TextAlignmentLeft aligns text left TextAlignmentLeft TextAlignment = iota // TextAlignmentRight aligns text right TextAlignmentRight // TextAlignmentCentre aligns text centrally TextAlignmentCentre )
func ExtractTextAlignment ¶
func ExtractTextAlignment(raw, name string, props map[string][]string) (TextAlignment, map[string][]string, error)
ExtractTextAlignment extracts a TextAlignment from the raw JSON data
func StringToAlignment ¶
func StringToAlignment(alignment string) (converted TextAlignment)
StringToAlignment converts strings to TextAlignments, defaulting to Left