(updaterState *UpdaterState, updates *Topic[Update])
| 41 | } |
| 42 | |
| 43 | func 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 | |
| 69 | func (g *MapGenerator) Run(ctx context.Context, wg *sync.WaitGroup, errch chan error) { |
| 70 | defer log.Debug("mapgenerator: exit") |
no test coverage detected