public TurtleGraphics(LSystem sys, int width, int height)
 {
     LSystem = sys;
     Width = width;
     Height = height;
     Image = new Bitmap(Width, Height);
 }
예제 #2
0
        public static Dictionary<string, LSystem> LoadSystems()
        {
            // load pre-defined lsystems from file 'lsystems.json'
            var dict = new Dictionary<string, LSystem>();
            var jsonData = File.ReadAllText("lsystems.json");
            dynamic systems = JsonConvert.DeserializeObject(jsonData); // dynamic makes things easier
            foreach(var sys in systems)
            {
                var lsystem = new LSystem();
                lsystem.Start = sys.Axiom;
                lsystem.AngleDelta = Math.PI * (sys.Angle.Value / 180.0);

                foreach (var variable in sys.Variables)
                    lsystem.Variables.Add(variable.Value);

                foreach(var rule in sys.Rules)
                    lsystem.Rules.Add(rule.From.Value, rule.To.Value);

                dict.Add(sys.Name.Value, lsystem);
            }
            return dict;
        }
 public TurtleGraphics(LSystem sys)
 {
     LSystem = sys;
     Image = new Bitmap(Width, Height);
 }
 public TurtleGraphics(LSystem sys)
 {
     LSystem = sys;
     Image   = new Bitmap(Width, Height);
 }