Documentation ¶
Index ¶
- func CalcRealSize(sizeStr string, parentSize int) (size int, err error)
- func DeferWhenOnRequestDone() func(retCode *int, msg, url, rBody, wBody *string)
- func DrawHorizLine(img *image.RGBA, c color.Color, fromX, toX, y int)
- func DrawVertLine(img *image.RGBA, c color.Color, x, fromY, toY int)
- func GetFontSizeByHeight(tf *truetype.Font, dpi float64, fontHeight int) (fontSize float64, err error)
- func Hex2RGB(hexStr string) (c color.Color, err error)
- func LoadFont(fontFile string) (font *truetype.Font, err error)
- func MeasureText(oneLineText string, tf *truetype.Font, dpi, fontSize float64) (width int, height int, err error)
- func MinInt(v1, v2 int) (min int)
- func ParseAbsoluteLocation(absolutePositionStr string, parentSize [2]int, selfSize [2]int) (minX, minY, maxX, maxY int, err error)
- func ParseNumPercentNumNone(numStr string, baseSize int) (isNone bool, realSize int, err error)
- func ParseRelativeLocation(relativePositionStr string, parentSize [2]int, selfSize [2]int, ...) (minX, minY, maxX, maxY int, err error)
- func RequestResource(resUrl string) (body io.ReadCloser, contentType string, err error)
- func ToRGBA(img image.Image) *image.RGBA
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcRealSize ¶
CalcRealSize 判断和计算sizeStr是纯数字类型的指标,还是百分百类型的,都转换为数字类型的返回, CalcRealSize("30", 200)=>30, CalcRealSize("30%", 200)=>60,CalcRealSize("30.0%", 200)=>60,
func DeferWhenOnRequestDone ¶
func DrawHorizLine ¶
DrawHorizLine 画一条水平线
func DrawVertLine ¶
DrawVertLine 画一条竖直线
func GetFontSizeByHeight ¶
func GetFontSizeByHeight(tf *truetype.Font, dpi float64, fontHeight int) (fontSize float64, err error)
GetFontSizeByHeight 通过文字的高度得到文字的大小(fontsize)
func Hex2RGB ¶
Hex2RGB 将十六进制的颜色码转换为颜色对象,比如#123456=>(R:12,G:34,B:56), #12345678=>((R:12,G:34,B:56,A:78)
func MeasureText ¶
func MeasureText(oneLineText string, tf *truetype.Font, dpi, fontSize float64) (width int, height int, err error)
MeasureText 测量一行文字的宽高
func ParseAbsoluteLocation ¶
func ParseAbsoluteLocation(absolutePositionStr string, parentSize [2]int, selfSize [2]int) (minX, minY, maxX, maxY int, err error)
ParseAbsoluteLocation 根据绝对定位配置,计算自身位置信息,ParseAbsoluteLocation("1% none none 2%",{100,200},{20,20})==>(20,20,40,40,nil)(如果没找到,则返回 math.MaxInt32)
func ParseNumPercentNumNone ¶
ParseNumPercentNumNone 解析字符串是整数型|百分比数|none,如果是非none,计算返回真正的尺寸
func ParseRelativeLocation ¶
func ParseRelativeLocation(relativePositionStr string, parentSize [2]int, selfSize [2]int, relativePosition [4]int) (minX, minY, maxX, maxY int, err error)
ParseRelativeLocation 根据相对定位配置,计算自身位置信息(如果没找到,则返回 math.MaxInt32)
func RequestResource ¶
func RequestResource(resUrl string) (body io.ReadCloser, contentType string, err error)
RequestResource 请求资源(一般来说是指获取图片资源)
Types ¶
This section is empty.