This is a creation in Article, where the information may have evolved or changed.
This library is called GG, source code on GitHub.
1. Get the source code and install it locally:
First install git (portal): https://git-scm.com/download/
You can then get the source code from git and install it via the Go Get command (this is where go is installed by default): Go to the Gopath directory in cmd and enter: Go get github.com/fogleman/gg
After a while you can see that Gopath has the source of GG, and by the way GG's reliance on third-party libraries also downloaded.
2. The Src\github.com\fogleman\gg\examples catalogue is an example written by GG authors. Here, pick one out to practice practiced hand:
Package main Import ( "Github.com/fogleman/gg" " Math/rand" ) func main () { Const W = 1024 Const H = 1024x768 DC: = GG. Newcontext (W, H)//context, with long and wide DC. Setrgb (0, 0, 0) //Set current color DC. Clear () //Clear the context and start drawing below for I: = 0; I < i++ {//Draw 1000 lines, random position, length, color and transparency x1: = Rand. Float64 () * W y1: = Rand. Float64 () * H x2: = Rand. Float64 () * W y2: = Rand. Float64 () * H r: = Rand. Float64 () g: = Rand. Float64 () b: = Rand. Float64 () A: = Rand. Float64 () *0.5 + 0.5 w: = Rand. Float64 () + 1 DC. Setrgba (R, G, B, a) DC. Setlinewidth (w) DC. DrawLine (x1, y1, x2, y2)//Draw line DC. Stroke () //No This sentence is not the final drawing of the line of the } DC. Savepng ("lines.png")//save context as a picture }