Beispiel #1
0
func (g *Generator) labels(data []string) *Generator {
	unicodeRegex, err := regexp.Compile("\\\\u")
	g.b.WriteString(textCenterDef)
	if err != nil {
		panic(err)
	}
	for i := range data {
		splat := strings.Split(data[i], ":")
		if len(splat) != 2 {
			continue
		}
		lh, txt := splat[0], splat[1]
		pt, err := point.FromSgfCoord(lh)
		if err != nil {
			continue
		}
		if unicodeRegex.MatchString(txt) {
			// General unicode support is difficult =(
			continue
		}
		s := pt.String()
		c := g.c.CoordMap[s]
		if _, ok := g.bstones[s]; ok {
			g.b.WriteString(Text(c, g.c.Radius*2-2, txt, WHITE))
		} else if _, ok := g.wstones[s]; ok {
			g.b.WriteString(Text(c, g.c.Radius*2-2, txt, BLACK))
		} else {
			g.b.WriteString(WhiteDisc(c, g.c.Radius*.95))
			g.b.WriteString(Text(c, g.c.Radius*2-2, txt, BLACK))
		}
	}
	return g
}
Beispiel #2
0
func (p *Props) GetAsPoints(prop SgfProperty) ([]*point.IntPt, error) {
	pts := make([]*point.IntPt, 0, 10)
	data, ok := p.Get(prop)
	if !ok {
		return pts, fmt.Errorf("No Data for prop %v", prop)
	}
	for _, v := range data {
		p, err := point.FromSgfCoord(v)
		if err != nil {
			return pts, err
		}
		pts = append(pts, p)
	}
	return pts, nil
}