本文整理匯總了Golang中github.com/BurntSushi/wingo/render.Color.GradientSet方法的典型用法代碼示例。如果您正苦於以下問題:Golang Color.GradientSet方法的具體用法?Golang Color.GradientSet怎麽用?Golang Color.GradientSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/wingo/render.Color
的用法示例。
在下文中一共展示了Color.GradientSet方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setGradient
func setGradient(k wini.Key, clr *render.Color) {
// Check to make sure we have a value for this key
vals := k.Strings()
if len(vals) == 0 {
logger.Warning.Println(k.Err("No values found."))
return
}
// Use the last value
val := vals[len(vals)-1]
// If there are no spaces, it can't be a gradient.
if strings.Index(val, " ") == -1 {
if start, ok := getLastInt(k); ok {
clr.ColorSet(start)
}
return
}
// Okay, now we have to do things manually.
// Split up the value into two pieces separated by whitespace and parse
// each piece as an int.
splitted := strings.Split(val, " ")
if len(splitted) != 2 {
logger.Warning.Println(k.Err("Expected a gradient value (two colors "+
"separated by a space), but found '%s' "+
"instead.", val))
return
}
start, err := strconv.ParseInt(strings.TrimSpace(splitted[0]), 0, 0)
if err != nil {
logger.Warning.Println(k.Err("'%s' is not an integer. (%s)",
splitted[0], err))
return
}
end, err := strconv.ParseInt(strings.TrimSpace(splitted[1]), 0, 0)
if err != nil {
logger.Warning.Println(k.Err("'%s' is not an integer. (%s)",
splitted[1], err))
return
}
// finally...
clr.GradientSet(int(start), int(end))
}