本文整理匯總了Golang中github.com/BurntSushi/wingo/render.Color.ColorSet方法的典型用法代碼示例。如果您正苦於以下問題:Golang Color.ColorSet方法的具體用法?Golang Color.ColorSet怎麽用?Golang Color.ColorSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/wingo/render.Color
的用法示例。
在下文中一共展示了Color.ColorSet方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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))
}
示例2: setNoGradient
func setNoGradient(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
}
logger.Warning.Println(
k.Err("Gradients are not supported for this theme option."))
}