forked from vdobler/chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics_test.go
60 lines (47 loc) · 1.51 KB
/
graphics_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package chart_test
import (
"fmt"
"github.com/vdobler/chart"
"github.com/vdobler/chart/txtg"
"math"
"testing"
)
const r = 18
const ri = 10
func initDemoCircle() *txtg.TextGraphics {
g := txtg.NewTextGraphics(60, 40)
g.Line(0, 20, 59, 20, chart.Style{Symbol: '-'})
g.Line(30, 0, 30, 39, chart.Style{Symbol: '|'})
for p := 0.0; p <= 2*math.Pi; p += 0.1 {
x := int(r * math.Cos(p) * 1.5)
y := int(r * math.Sin(p))
g.Symbol(30+x, 20+y, '*', chart.Style{Symbol: '*'})
}
return g
}
func TestGenericWedge(t *testing.T) {
g := initDemoCircle()
s := chart.Style{Symbol: '#', FillColor: "#ff0000", LineColor: "#0000ff"}
ra := math.Pi / 2
chart.GenericWedge(g, 30, 20, r, ri, 0.15*ra, 0.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
chart.GenericWedge(g, 30, 20, r, ri, 1.15*ra, 1.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
chart.GenericWedge(g, 30, 20, r, ri, 2.15*ra, 2.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
chart.GenericWedge(g, 30, 20, r, ri, 3.15*ra, 3.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
// mored than one quadrant
g = initDemoCircle()
chart.GenericWedge(g, 30, 20, r, ri, 0.15*ra, 1.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
chart.GenericWedge(g, 30, 20, r, ri, 2.15*ra, 3.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
g = initDemoCircle()
chart.GenericWedge(g, 30, 20, r, ri, 1.5*ra, 2.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
// all 4 quadrants
g = initDemoCircle()
chart.GenericWedge(g, 30, 20, r, ri, 1.5*ra, 0.5*ra, 1.5, s)
fmt.Printf("\n%s\n", g.String())
}