英文:
How can you create your own array of colors in google go?
问题
你可以通过在Go语言中创建自定义颜色调色板来避免使用标准的颜色调色板。
英文:
I don't want to use the standard color palettes in the go language, so I am wondering how can you create your own color palette.
答案1
得分: 3
你可以查看项目lucasb-eyer/go-colorful,它可以生成颜色调色板。
pal1, err1 := colorful.WarmPalette(10)
pal2 := colorful.FastWarmPalette(10)
pal3, err3 := colorful.HappyPalette(10)
pal4 := colorful.FastHappyPalette(10)
pal5, err5 := colorful.SoftPalette(10)
下图显示了所有这些方法生成的调色板(源代码在**
doc/palettegens/palettegens.go
**中),按照它们的顺序从上到下排列:
- Warm(温暖色调)
- FastWarm(快速温暖色调)
- Happy(快乐色调)
- FastHappy(快速快乐色调)
- Soft(柔和色调)
- SoftEx(棕色调)
所有这些调色板都包含一些随机性,所以结果可能会有所不同。
英文:
You can have a look at the project lucasb-eyer/go-colorful, which can generate color palettes.
pal1, err1 := colorful.WarmPalette(10)
pal2 := colorful.FastWarmPalette(10)
pal3, err3 := colorful.HappyPalette(10)
pal4 := colorful.FastHappyPalette(10)
pal5, err5 := colorful.SoftPalette(10)
> The following picture shows the palettes generated by all of these methods (sourcecode in doc/palettegens/palettegens.go
), in the order they were presented, i.e. from top to bottom:
> - Warm,
- FastWarm,
- Happy,
- FastHappy,
- Soft,
- SoftEx(isbrowny).
> All of them contain some randomness, so YMMV.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论