MCPcopy Create free account
hub / github.com/and3rson/raid / NewMapGenerator

Function NewMapGenerator

raid/mapgenerator.go:43–67  ·  view source on GitHub ↗
(updaterState *UpdaterState, updates *Topic[Update])

Source from the content-addressed store, hash-verified

41}
42
43func NewMapGenerator(updaterState *UpdaterState, updates *Topic[Update]) *MapGenerator {
44 mapTemplate, err := template.New("maptemplate").Parse(mapTemplateStr)
45 if err != nil {
46 log.Fatalf("mapgenerator: parse map template: %s", err)
47 }
48
49 f, err := freetype.ParseFont(dejaVuFontData)
50 if err != nil {
51 log.Fatalf("mapgenerator: parse TTF font: %s", err)
52 }
53
54 fontCtx := freetype.NewContext()
55 fontCtx.SetDPI(72)
56 fontCtx.SetFont(f)
57 fontCtx.SetFontSize(48)
58 fontCtx.SetSrc(image.Black)
59 fontCtx.SetHinting(font.HintingFull)
60
61 g := &MapGenerator{updaterState, updates, mapTemplate, fontCtx, &MapData{}}
62 if err := g.GenerateMap(updaterState, "", true); err != nil {
63 log.Fatalf("mapgenerator: generate initial map: %s", err)
64 }
65
66 return g
67}
68
69func (g *MapGenerator) Run(ctx context.Context, wg *sync.WaitGroup, errch chan error) {
70 defer log.Debug("mapgenerator: exit")

Callers 2

mainFunction · 0.92
mainFunction · 0.92

Calls 1

GenerateMapMethod · 0.95

Tested by

no test coverage detected