Ejemplo n.º 1
0
func (d *Diamonds) drawDiamond(g *dwg.GraphicContext, h, v *vec.Vec, c color.Color) {
	g.SetFillColor(c)
	g.SetStrokeColor(c)
	g.BeginPath()

	g.MoveTo(0.0, v.Y)
	g.LineTo(h.X, 0.0)
	g.LineTo(0.0, -v.Y)
	g.LineTo(-h.X, 0.0)
	g.LineTo(0.0, v.Y)

	g.Fill()
}
func drawSnowflake(sys string, gc *draw2dimg.GraphicContext) {

	angle := float64(0)
	lineLength := float64(10)
	x, y := float64(1000), float64(1000)

	gc.MoveTo(x, y)

	for _, i := range sys {

		switch string(i) {

		case "F":
			x, y = nextPoint(angle, lineLength, x, y)
			gc.LineTo(x, y)
		case "+":
			angle += math.Pi / 3
		case "-":
			angle -= math.Pi / 3
		}
	}
}