/// <summary> /// Build map for the root /// </summary> public void Build(OrbitalBodyDescription root) { const int SIZE = 1001; using (var img = new Bitmap(SIZE, SIZE)) using (var gr = Graphics.FromImage(img)) { gr.SmoothingMode = SmoothingMode.HighQuality; //max orbit var max = root.GetMeAndChildren().Select(b => b.OrbitRadius).Max(); //scale var scale = 0.5 * (SIZE - 5) / max; //draw orbits DrawOrbit(gr, scale, root); //convert to png using (var ms = new MemoryStream()) { img.Save(ms, ImageFormat.Png); //save to root body root.Map = ms.ToArray(); root.MapScale = scale; } } }