Beispiel #1
0
func (g *Generator) genStarPoints(mt *core.Movetree) *Generator {
	sp := getStarPoints(mt.Intersections())
	for _, pt := range sp {
		c := g.c.CoordMap[pt.String()]
		g.b.WriteString(StarPoint(c, g.c.Radius*.15))
	}
	return g
}
Beispiel #2
0
// Generate an EPS image for a baduk Movetree.
func Generate(mt *core.Movetree, side int) []byte {
	g := &Generator{
		side:    side,
		c:       ConstructCoords(mt.Intersections(), side),
		bstones: make(map[string]bool),
		wstones: make(map[string]bool),
	}
	g.header().content(mt).footer()
	return g.b.Bytes()
}
Beispiel #3
0
func (g *Generator) genLines(mt *core.Movetree) *Generator {
	ints := mt.Intersections()
	for i := 0; i < ints; i++ {
		rowStart, _ := g.c.CoordMap[(&point.IntPt{i, 0}).String()]
		rowEnd, _ := g.c.CoordMap[(&point.IntPt{i, ints - 1}).String()]
		g.b.WriteString(Line(rowStart, rowEnd))
		colStart := g.c.CoordMap[(&point.IntPt{0, i}).String()]
		colEnd := g.c.CoordMap[(&point.IntPt{ints - 1, i}).String()]
		g.b.WriteString(Line(colStart, colEnd))
	}
	g.b.WriteString(Stroke(0.5))
	return g
}
Beispiel #4
0
func (g *Generator) genStones(mt *core.Movetree) *Generator {
	r := g.c.Radius - 0.2
	bpts, _ := mt.Props().GetAsPoints(core.AB)
	wpts, _ := mt.Props().GetAsPoints(core.AW)
	for i, _ := range bpts {
		strForm := bpts[i].String()
		coord, ok := g.c.CoordMap[strForm]
		if ok {
			g.b.WriteString(Stone(coord, r, BLACK))
			g.bstones[strForm] = true
		}
	}
	for i, _ := range wpts {
		strForm := wpts[i].String()
		coord, ok := g.c.CoordMap[wpts[i].String()]
		if ok {
			g.b.WriteString(Stone(coord, r, WHITE))
			g.wstones[strForm] = true
		}
	}
	return g
}
Beispiel #5
0
func FromMovetree(mt *core.Movetree) *Cropping {
	ints := mt.getIntersections()
	middle := ints / 2
	return FromPreset(ALL)
}
Beispiel #6
0
func (g *Generator) content(mt *core.Movetree) *Generator {
	return g.genDefs().genLines(mt).genStarPoints(mt).genStones(mt).genMarks(mt.Props())
}