/// <summary>Adds the given parsed command into the given path.</summary> public static void AddCommand(VectorPath path, char command, float[] param, int currentLimit) { if (command == '\0') { return; } // Get the lc command: char lower = char.ToLower(command); // A lowercase char is relative // (and its lowercase if the lower one matches the original): bool isRelative = (command == lower); // Current point: float curX = 0f; float curY = 0f; float c1x = 0f; float c1y = 0f; if (path.LatestPathNode != null) { // Get current point: curX = path.LatestPathNode.X; curY = path.LatestPathNode.Y; } switch (lower) { case 'a': // Eliptical arc if (isRelative) { param[5] += curX; param[6] += curY; } path.EllipseArc(param[0], param[1], param[2], param[5], param[6], (param[3] == 1f), (param[4] == 1f)); break; case 'c': // Curve to if (isRelative) { param[0] += curX; param[1] += curY; param[2] += curX; param[3] += curY; param[4] += curX; param[5] += curY; } path.CurveTo(param[0], param[1], param[2], param[3], param[4], param[5]); break; case 'h': // Horizontal line to if (isRelative) { param[0] += curX; } path.LineTo(param[0], curY); break; case 'l': // Line to if (isRelative) { param[0] += curX; param[1] += curY; } path.LineTo(param[0], param[1]); break; case 'm': // Move to if (isRelative) { param[0] += curX; param[1] += curY; } path.MoveTo(param[0], param[1]); break; case 'q': // Quadratic bezier to if (isRelative) { param[0] += curX; param[1] += curY; param[2] += curX; param[3] += curY; } path.QuadraticCurveTo(param[0], param[1], param[2], param[3]); break; case 's': // Smooth curve to Reflect(path, out c1x, out c1y); if (isRelative) { param[0] += curX; param[1] += curY; param[2] += curX; param[3] += curY; } path.CurveTo(c1x, c1y, param[0], param[1], param[2], param[3]); break; case 't': // Smooth quadratic bezier to Reflect(path, out c1x, out c1y); if (isRelative) { param[0] += curX; param[1] += curY; } path.QuadraticCurveTo(c1x, c1y, param[0], param[1]); break; case 'v': // Vertical line to if (isRelative) { param[0] += curY; } path.LineTo(curX, param[0]); break; case 'z': // Close path path.ClosePath(); break; } }