1 Star 0 Fork 0

TimeFlieOk/color

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
color256.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
inhere 提交于 2018-08-23 13:23 . complete all functions. add more tests
package main
import (
"github.com/gookit/color"
"fmt"
)
// go run ./_examples/color256.go
func main() {
// var s *color.Style256
fmt.Printf("%-45s 256 Color(16 bit) Table %-35s\n", " ", " ")
// 0 - 16
fmt.Printf("%-22sStandard Color %-42sExtended Color \n", " ", " ")
for i := range []int{7:0} {// 0 -7 -> 8/16color: 30–37
color.S256(255, uint8(i)).Printf(" %-4d", i)
}
fmt.Print(" ")
for i := range []int{7:0} {// 8 -15 -> 16color: 90–97
i += 8
color.S256(0, uint8(i)).Printf(" %-4d", i)
}
var fg uint8 = 255
fmt.Printf("\n%-50s216 Color\n", " ")
for i := range []int{215:0} {// 16-231:6 × 6 × 6 立方(216色): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
v := i + 16
if i != 0 {
if i%18 == 0 {
fg = 0
fmt.Println() // new line
}
if i % 36 == 0 {
fg = 255
// fmt.Println() // new line
}
}
color.S256(fg, uint8(v)).Printf(" %-4d", v)
}
fmt.Printf("\n%-50s24th Order Grayscale Color\n", " ")
for i := range []int{23:0} {// // 232-255:从黑到白的24阶灰度色
if i < 12 {
fg = 255
} else {
fg = 0
}
i += 232
color.S256(fg, uint8(i)).Printf(" %-4d", i)
}
fmt.Println()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lutong_206/color.git
git@gitee.com:lutong_206/color.git
lutong_206
color
color
v1.1.6

搜索帮助