func (f *Fractal) LoadConfig() { b, e := ioutil.ReadFile(configfile) ass.Error(e) lines := strings.Split(string(b), "\n") var index = 0 var next = func() string { defer func() { index += 1 }() return lines[index] } Sscanf(next(), "%v %v", &f.width, &f.height) f.height = f.width Sscanf(next(), "%v %v", &f.Iterations, &f.Precision) f.reloadPrecision() var x, y = next(), next() Println(x, y) f.Center.SetString(x, y) f.Zoom.SetString(next(), "1.0") f.RenewResolution(f.width, f.height) }
func (f *Fractal) Quit() { b, e := ioutil.ReadFile(configfile) ass.Error(e) lines := strings.Split(string(b), "\n") var index = 0 var next = func(s string) { lines[index] = s index += 1 } next(Sprintf("%v %v", f.width, f.height)) next(Sprintf("%v %v", f.Iterations, f.Precision)) next(Sprint(f.Center.X)) next(Sprint(f.Center.Y)) next(Sprint(f.Zoom.X)) ioutil.WriteFile(configfile, []byte(strings.Join(lines, "\n")), 0) f.Center.Clear() f.Z0.Clear() f.Zoom.Clear() }