-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.go
72 lines (56 loc) · 1.78 KB
/
graph.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
package script
import (
"github.com/llgcode/draw2d"
"github.com/llgcode/draw2d/draw2dimg"
"github.com/peter-mount/go-anim/renderer"
draw2d2 "github.com/peter-mount/go-anim/util/draw2d"
"github.com/peter-mount/go-anim/util/font"
"image/color"
)
type Graph struct {
}
func (g Graph) NewContext() renderer.Context {
return g.New4k()
}
func (g Graph) New720p() renderer.Context {
return g.NewSizedContext(Width720p, Height720p)
}
func (g Graph) New1080p() renderer.Context {
return g.NewSizedContext(Width1080p, Height1080p)
}
func (g Graph) New4k() renderer.Context {
return g.NewSizedContext(Width4K, Height4K)
}
func (_ Graph) NewSizedContext(w, h int) renderer.Context {
return renderer.NewContext(w, h)
}
func (_ Graph) NewFont(name string, size float64, family draw2d.FontFamily, style draw2d.FontStyle) font.Font {
return font.New(name, size, family, style)
}
func (_ Graph) ParseFont(s string) (font.Font, error) {
return font.ParseFont(s)
}
func (_ Graph) SetFont(gc *draw2dimg.GraphicContext, s string) error {
f, err := font.ParseFont(s)
if err != nil {
return err
}
gc.SetFontData(f.FontData())
gc.SetFontSize(f.Size())
return nil
}
func (_ Graph) FillPoly(gc *draw2dimg.GraphicContext, c color.Color, v ...float64) {
draw2d2.FillPoly(gc, c, v...)
}
func (_ Graph) FillPolyRel(gc *draw2dimg.GraphicContext, c color.Color, v ...float64) {
draw2d2.FillPolyRel(gc, c, v...)
}
func (_ Graph) FillRectangle(gc *draw2dimg.GraphicContext, x, y, w, h float64, c color.Color) (float64, float64) {
return draw2d2.FillRectangle(gc, x, y, w, h, c)
}
func (_ Graph) Rectangle(gc *draw2dimg.GraphicContext, x, y, w, h float64) {
draw2d2.Rectangle(gc, x, y, w, h)
}
func (_ Graph) RelLine(gc *draw2dimg.GraphicContext, x, y float64, v ...float64) {
draw2d2.RelLine(gc, x, y, v...)
}