コード例 #1
0
ファイル: gxmain.go プロジェクト: Christopheraburns/clive
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)
}
コード例 #2
0
ファイル: gxmain.go プロジェクト: Christopheraburns/clive
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
	}
}
コード例 #3
0
ファイル: gxmain.go プロジェクト: Christopheraburns/clive
func polygons(g *gx.Graphics) {
	for i := 6; i >= 3; i-- {
		g.Polygon(100, 100, 100, i, 0)
	}
}
コード例 #4
0
ファイル: builtin.go プロジェクト: Christopheraburns/clive
func xbgopen(g *gx.Graphics) int {
	return xbopen("g:"+g.Name(), "rw", g)
}