public void Draw(string axiom, LPattern pattern) { foreach (var c in axiom) { Draw(c, pattern); } }
private void Draw(char command, LPattern pattern) { if (pattern.From == command && _currentRecursionLevel < MaxRecursionLevel) { _currentRecursionLevel++; foreach (var c in pattern.To) { Draw(c, pattern); } _currentRecursionLevel--; } else { switch (command) { case 'F': Forward(); break; case '-': TurnLeft(); break; case '+': TurnRight(); break; case '[': SaveContext(); break; case ']': LoadContext(); break; default: throw new NotSupportedException(); } } }