Example #1
0
func (f *Fractal) CreateTexture() *texture.Texture {
	f.reloadPrecision()
	var ratio = cx.NewFloat(f.Ratio())
	f.Zoom.SetY(f.Zoom.X)
	f.Zoom.MulY(ratio)
	var halfToUpperRight = f.Zoom.MulsDouble(.5)
	var lowerLeft = f.Center.Sub(halfToUpperRight)
	var wh = cx.New(Double(f.width), Double(f.height))
	var fxy = f.Zoom.DivComponents(wh)
	var coord = lowerLeft.Copy()
	defer func() {
		ratio.Clear()
		halfToUpperRight.Clear()
		lowerLeft.Clear()
		wh.Clear()
		fxy.Clear()
		coord.Clear()
	}()
	var sum Double = 0.0
	var col *Color24 = NewColor24(0, 0, 0)
	var intensity Double
	Printf("Idle time: ")
	util.Ts()
	cx.SetIterations(f.Iterations)
	for y := 0; y < f.height; y++ {
		coord.SetX(lowerLeft.X)
		coord.AddY(fxy.Y)
		for x := 0; x < f.width; x++ {
			coord.AddX(fxy.X)
			intensity = Double(f.Z0.DoMandel(coord)) / Double(f.Iterations)
			//intensity = intensity.Sqrt()
			f.gradient.Interpolate(col, intensity)
			f.grid.SetPixel24(x, y, col)
		}
		sum += intensity
	}
	Printf(">>>>>>>>>>>>>>>> Math time: ")
	util.Ts()
	f.renewTexture()
	Printf("GL time: ")
	util.Ts()
	Println("Intensity sum:", sum, col)
	return f.tex
}
Example #2
0
func (f *Fractal) ZoomIn(factor Double) {
	var fzoom = cx.NewFloat(factor)
	defer fzoom.Clear()
	f.Zoom.Mulsi(fzoom)
}