utils

package
v0.0.0-...-c131409 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: MIT Imports: 10 Imported by: 8

Documentation

Overview

Package utils provide some helpers functions for other packages

Index

Constants

View Source
const (
	// RadToDeg Radians to Degrees
	RadToDeg = 180 / math.Pi
	// DegToRad Degrees to Radians
	DegToRad = math.Pi / 180
)

Variables

This section is empty.

Functions

func AppendStrUnique

func AppendStrUnique(slice []string, s string) []string

AppendStrUnique append to a string slice if the value doesn't already exist

func Bool2Obox

func Bool2Obox(b bool) int

Bool2Obox convert a boolen to a int (Opaquebox ass format).

func Bool2str

func Bool2str(b bool) string

Bool2str convert a bool to an string (ass format).

func ChangeSignF

func ChangeSignF(n float64) float64

ChangeSignF convert possitive to negative and back (float)

func ChangeSignN

func ChangeSignN(n int) int

ChangeSignN convert possitive to negative and back (integer)

func CircleRange

func CircleRange(
	n int, x, y, radius float64, f interpolate.Interp) (nums []float64)

CircleRange generate x, y coords of a circle.

func Deg

func Deg(r float64) float64

Deg Radians to Degrees

func DivMod

func DivMod(a, b int) (q, r int)

DivMod do a division an a modulo operation.

func Hex2int

func Hex2int(hexStr string) int

Hex2int convert hexadecimal to decimal.

func LenString

func LenString(text string) int

LenString length of a string.

func LoadFont

func LoadFont(fontName string, fontSize int) (face font.Face, err error)

LoadFont load and parse a truetype font.

func MeasureString

func MeasureString(ff font.Face, s string) (w float64, h float64)

MeasureString returns the rendered width and height of the specified text given the current font face.

func Obox2bool

func Obox2bool(s string) bool

Obox2bool convert a string to a boolean (Opaquebox ass format).

func Polar2Rect

func Polar2Rect(radius, angle float64) (x, y int)

Polar2Rect convert polar coords to rectangular.

func Rad

func Rad(d float64) float64

Rad Degrees to Radians

func RandomChoiceFloat

func RandomChoiceFloat(list []float64) float64

RandomChoiceFloat select a random choice in a float64 slice

func RandomChoiceInt

func RandomChoiceInt(list []int) int

RandomChoiceInt select a random choice in a int slice

func RandomChoiceString

func RandomChoiceString(list []string) string

RandomChoiceString select a random choice in a string slice

func RandomFloat

func RandomFloat(min, max float64) float64

RandomFloat random decimal number between min and max

func RandomFloatRange

func RandomFloatRange(n int, min, max float64) (nums []float64)

RandomFloatRange random n numbers between min and max (float)

func RandomInt

func RandomInt(min, max int) int

RandomInt random number between min and max

func RandomIntRange

func RandomIntRange(n, min, max int) (nums []int)

RandomIntRange random n numbers between min and max (integer)

func Rect2Polar

func Rect2Polar(px, py int) (angle, r float64)

Rect2Polar convert rectangolar coords to rectangular.

func Round

func Round(f float64, places int) float64

Round returns a rounded input with p places

func Str2bool

func Str2bool(s string) bool

Str2bool convert a string (ssa) to a boolean.

func Str2float

func Str2float(s string) float64

Str2float convert a string to an float.

func Str2int

func Str2int(s string) int

Str2int convert a string to an integer.

func TrimSpaceCount

func TrimSpaceCount(text string) (string, int, int)

TrimSpaceCount trims spaces of text and count the number of Left and Right spaces

Types

This section is empty.

Jump to

Keyboard shortcuts

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