How to use the svg-pathdata.SVGPathData.MOVE_TO function in svg-pathdata

To help you get started, we’ve selected a few svg-pathdata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jasonwebb / 2d-diffusion-limited-aggregation-experiments / core / SVGLoader.js View on Github external
currentPath.points = []

    // Scrape all points from all points, and record breakpoints
    for(let inputPath of inputPaths) {
      let pathData = new SVGPathData(inputPath.getAttribute('d'));

      let previousCoords = {
        x: 0,
        y: 0
      };

      for(let [index, command] of pathData.commands.entries()) {
        switch(command.type) {
          // Move ('M') and line ('L') commands have both X and Y
          case SVGPathData.MOVE_TO:
          case SVGPathData.LINE_TO:
            currentPath.points.push([
              command.x, 
              command.y
            ]);

            break;

          // Horizontal line ('H') commands only have X, using previous command's Y
          case SVGPathData.HORIZ_LINE_TO:
            currentPath.points.push([
              command.x,
              previousCoords.y
            ]);
            
            break;