Skip to content

Commit 9750566

Browse files
committed
draw example 2
1 parent 89883fa commit 9750566

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

drawPNG/main2.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"math/rand"
5+
"time"
6+
"fmt"
7+
"github.com/fogleman/gg"
8+
)
9+
10+
11+
func main() {
12+
r := rand.New(rand.NewSource(99))
13+
r.Seed(time.Now().UTC().UnixNano())
14+
15+
drawItem:= gg.NewContext(1000,1000)
16+
17+
drawItem.SetHexColor("#fff")
18+
drawItem.DrawCircle(500,500,400)
19+
drawItem.Fill()
20+
drawItem.DrawCircle(500,500,400)
21+
drawItem.SetRGBA(0, 0, 0, 0.2)
22+
drawItem.SetLineWidth(100)
23+
drawItem.Stroke()
24+
25+
26+
for i := 0; i <= 500; i++ {
27+
drawItem.SetHexColor(fmt.Sprintf("#%.3X",3840+r.Intn(100)))
28+
drawItem.RotateAbout(gg.Radians(float64(i*3)), 500, 500)
29+
drawItem.DrawLine(float64(i),float64(i),float64(i+5),float64(i+20))
30+
drawItem.SetLineWidth(r.Float64()*3)
31+
drawItem.Stroke()
32+
}
33+
34+
drawItem.SetHexColor("#333")
35+
drawItem.DrawCircle(500,500,100)
36+
drawItem.Fill()
37+
38+
defer drawItem.SavePNG("out3.png")
39+
40+
}

drawPNG/out3.png

-267 KB
Loading

0 commit comments

Comments
 (0)