This is a creation in Article, where the information may have evolved or changed.
Golang version of the text cloud algorithm implementation
Project links
Https://github.com/bangbaoshi/wordcloud
The test steps are as follows
git clone https://github.com/bangbaoshi/wordcloud.gitcd wordcloudgo run boot/main.go
Create a text cloud picture in the IMGs directory with the above three steps (view imgs/out.png)
Catalogue Introduction
- The boot directory contains test cases
- Fonts directory contains several fonts (non-commercial use)
- IMGs Catalog contains template pictures, text clouds generated by the template image as a result of the appearance of
Instructions for use
The use method has been briefly introduced in the Boot/main.go
package mainimport ("image/color""github.com/bangbaoshi/wordcloud")func renderNow() {//需要写入的文本数组textList := []string{"恭喜", "发财", "万事", "如意"}//文本角度数组angles := []int{0, 15, -15, 90}//文本颜色数组colors := []*color.RGBA{&color.RGBA{0x0, 0x60, 0x30, 0xff},&color.RGBA{0x60, 0x0, 0x0, 0xff},&color.RGBA{0x73, 0x73, 0x0, 0xff},}//设置对应的字体路径,和输出路径render := wordcloud_go.NewWordCloudRender(60, 8,"./fonts/xin_shi_gu_yin.ttf","./imgs/tiger.png", textList, angles, colors, "./imgs/out.png")//开始渲染render.Render()}func main() {renderNow()}
Project Introduction
- Text cloud algorithm implemented using Golang language
- Use Golang to realize some interesting ideas