forked from yeqown/go-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_qr_shape_test.go
76 lines (63 loc) · 1.29 KB
/
image_qr_shape_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package standard
import (
"image"
"image/color"
"testing"
"github.com/fogleman/gg"
)
func Test_rectangle_Draw(t *testing.T) {
rect := image.Rect(0, 0, 100, 100)
rgba := image.NewRGBA(rect)
dc := gg.NewContextForRGBA(rgba)
dc.DrawRectangle(0, 0, 100, 100)
dc.SetColor(color.White)
dc.Fill()
ctx := &DrawContext{
Context: dc,
x: 0.0,
y: 0.0,
w: 50,
h: 50,
color: color.Black,
}
_shapeRectangle.Draw(ctx)
err := dc.SavePNG("./testdata/rectangle.png")
if err != nil {
t.Error(err)
t.FailNow()
}
}
func Test_circle_Draw(t *testing.T) {
rect := image.Rect(0, 0, 100, 100)
rgba := image.NewRGBA(rect)
dc := gg.NewContextForRGBA(rgba)
dc.DrawRectangle(0, 0, 100, 100)
dc.SetColor(color.White)
dc.Fill()
ctx := &DrawContext{
Context: dc,
x: 0.0,
y: 0.0,
w: 50,
h: 50,
color: color.Black,
}
_shapeCircle.Draw(ctx)
err := dc.SavePNG("./testdata/circle.png")
if err != nil {
t.Error(err)
t.FailNow()
}
}
func Test_gg(t *testing.T) {
rect := image.Rect(0, 0, 100, 100)
rgba := image.NewRGBA(rect)
dc := gg.NewContextForRGBA(rgba)
dc.DrawRectangle(0, 0, 100, 100)
dc.SetColor(color.White)
dc.Fill()
dc.DrawCircle(50, 50, 40)
dc.SetColor(color.Black)
dc.Fill()
_ = dc.SavePNG("./testdata/out.png")
}