https://github.com/bangbaoshi/wordcloudgit
git clone https://github.com/bangbaoshi/wordcloud.git cd wordcloud go run boot/main.go
經過以上三步便可在imgs目錄中生成文字雲圖片(查看imgs/out.png)github
boot/main.go中已經簡單介紹了使用方法golang
package main import ( "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() }