public CGPath BuildPath()

in FigmaSharp.Views/FigmaSharp.Views.Cocoa/Graphics/PathBuilder.cs [94:169]


		public CGPath BuildPath(string pathAsString)
		{
			try
			{
				_lastCommand = '~';
				_lastCurveControlPoint = null;
				_path = null;
				_commandStack.Clear();
				_relativePoint = new CGPoint(0, 0);
				_closeWhenDone = false;

				pathAsString = pathAsString.Replace("Infinity", "0");
				pathAsString = Regex.Replace(pathAsString, "([a-zA-Z])", " $1 ");
				pathAsString = pathAsString.Replace("-", " -");
				pathAsString = pathAsString.Replace(" E  -", "E-");
				pathAsString = pathAsString.Replace(" e  -", "e-");

				var args = pathAsString.Split(new[] { ' ', '\r', '\n', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);
				for (var i = args.Length - 1; i >= 0; i--)
				{
					var entry = args[i];
					var c = entry[0];
					if (char.IsLetter(c))
					{
						if (entry.Length > 1)
						{
							entry = entry.Substring(1);
							if (char.IsLetter(entry[0]))
							{
								if (entry.Length > 1)
								{
									_commandStack.Push(entry.Substring(1));
								}

								_commandStack.Push(entry[0].ToString(CultureInfo.InvariantCulture));
							}
							else
							{
								_commandStack.Push(entry);
							}
						}

						_commandStack.Push(c.ToString(CultureInfo.InvariantCulture));
					}
					else
					{
						_commandStack.Push(entry);
					}
				}

				while (_commandStack.Count > 0)
				{
					if (_path == null)
					{
						_path = new CGPath();
					}

					var vCommand = _commandStack.Pop();
					HandleCommand(vCommand);
				}

				if (_path != null)
				{
					if (_closeWhenDone)
					{
						_path.CloseSubpath();
					}
				}
			}
			catch (Exception exc)
			{
				throw new Exception($"An error occurred parsing the path: {pathAsString}", exc);
			}

			return _path;
		}