How to use @antv/path-util - 6 common examples

To help you get started, we’ve selected a few @antv/path-util 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 antvis / G6 / src / util / path.ts View on Github external
export const getSpline = (points: IPoint[]) => {
  const data: number[] = [];

  if (points.length < 2) {
    console.warn(`point length must largn than 2, now it's ${points.length}`);
  }
  for (const point of points) {
    const { x, y } = point;
    data.push(x);
    data.push(y);
  }

  const spliePath = catmullRom2Bezier(data);
  spliePath.unshift(['M', points[0].x, points[0].y]);
  return spliePath;
};
github antvis / G2 / packages / component / src / axis / helix.ts View on Github external
getLinePath() {
    const crp = this.get('crp');
    const axisStart = this.get('axisStart');
    const path = pathUtil.catmullRom2Bezier(crp);
    path.unshift([ 'M', axisStart.x, axisStart.y ]);
    return path;
  }
github antvis / G2 / packages / g2 / src / element / shape / point.ts View on Github external
const pathMetaParser = _.memoize((path: string) => {
  const segments = pathUtil.parsePathString(path);
  const nums = _.flatten(segments).filter((num) => _.isNumber(num));
  return {
    range: Math.max.apply(null, nums) - Math.min.apply(null, nums),
    segments,
  };
});
github antvis / G2 / src / geometry / shape / base.ts View on Github external
parsePath(path: string, isLineToArc: boolean = true): PathCommand[] {
    const coordinate = this.coordinate;
    let parsedPath = parsePathString(path);
    if (coordinate.isPolar && isLineToArc !== false) {
      parsedPath = convertPolarPath(coordinate, parsedPath);
    } else {
      parsedPath = convertNormalPath(coordinate, parsedPath);
    }
    return parsedPath;
  },
  /**
github antvis / G2 / packages / g2 / src / animate / action.ts View on Github external
function pathOut(shape, animateCfg) {
  if (shape.get('type') !== 'path') {
    return;
  }
  const path = pathUtil.path2Curve(shape.attr('path'));
  const endState = {
    path: [path[0]],
  };
  animateCfg.callback = () => shape.remove();

  doAnimation(shape, endState, animateCfg);
}
github antvis / G2 / packages / g2 / src / animate / action.ts View on Github external
function pathIn(shape, animateCfg) {
  if (shape.get('type') !== 'path') {
    return;
  }
  const path = pathUtil.path2Curve(shape.attr('path'));
  shape.attr('path', [path[0]]);
  const endState = {
    path,
  };

  doAnimation(shape, endState, animateCfg);
}

@antv/path-util

A common util collection for antv projects

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis