Exemplo n.º 1
0
func (g *StarPattern) Draw() *pix.Canvas {
	g.Clear("fff")

	pos := vec.Zero()
	dim := vec.New(70.0, 70.0)
	ct := dim.Scale(0.5, 0.5)
	hct := ct.Scale(0.5, 0.5)

	for pos.Y < g.Dim.Y {
		for pos.X < g.Dim.X {
			p1 := pos.Translate(ct.X, 0.0)
			p2 := pos.Add(*ct)
			g.Star(p1, hct)
			g.LineTo(p2.Pts())
			g.LineTo(p1.Pts())
			g.SetFillColor(hex_color.Black)
			g.Fill()

			pos = pos.Translate(dim.X, 0.0)
		}
		pos = vec.Zero().Translate(0.0, pos.Y+dim.Y)
	}

	return g.Canvas
}
Exemplo n.º 2
0
func Basic(name, file string) *Canvas {
	return NewCanvas(&Canvas{
		Dim:      vec.New(600.0, 400.0),
		Pos:      vec.Zero(),
		Name:     name,
		FileName: file,
	})
}