Esempio n. 1
0
func (d *Diamonds) render(g *dwg.GraphicContext, h, v *vec.Vec, data chan Occur) {
	for step := range data {
		g.Save()
		g.Rotate(step.Arc)
		g.Translate(90, 0)
		d.drawDiamond(
			g,
			h.Scale(step.Scale, step.Scale),
			v.Scale(step.Scale, step.Scale),
			RgbaColor(150, 140+step.N, 0, step.Opacity),
		)
		g.Restore()
	}
}
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
		}
	}
}
Esempio n. 3
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()
}