Exemple #1
0
func redraw(g *gx.Graphics, pts []Point) {
	g.Clear()
	g.SetPenCol(gx.BLACK, 1.0)
	g.SetPenWidth(4)
	g.SetFillCol(gx.GREEN, 1.0)
	polygons(g)
	rainbow(g)
	trace(g, pts)
}
Exemple #2
0
func trace(g *gx.Graphics, pts []Point) {
	var hd []Point
	if len(pts) < 2 {
		return
	}
	tail := pts
	g.SetPenWidth(5)
	g.SetPenCol(gx.BLACK, 1.0)
	i := 0
	for {
		i++
		hd, tail = head(tail)
		if len(hd) == 0 {
			continue
		}
		if i>last && len(hd)>Nsmooth {
			hd = simplify(hd)
			frozen := hd[:len(hd)-Nsmooth]
			sm := hd[len(hd)-Nsmooth:]
			sm = smooth(sm)
			hd = append(frozen, sm...)
		}
		lpt := hd[0]
		for i := 1; i < len(hd); i++ {
			pt := hd[i]
			g.Line(lpt.x, lpt.y, pt.x, pt.y)
			lpt = pt
		}
		if len(tail) == 0 {
			return
		}
		last = i
	}
}
Exemple #3
0
func polygons(g *gx.Graphics) {
	for i := 6; i >= 3; i-- {
		g.Polygon(100, 100, 100, i, 0)
	}
}
Exemple #4
0
func xbgopen(g *gx.Graphics) int {
	return xbopen("g:"+g.Name(), "rw", g)
}