JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 33
  • Score
    100M100P100Q57399F
  • License MIT

Package Exports

  • unit-path

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (unit-path) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

获取 canvas 中一些路径上的点

获取直线、二阶贝塞尔曲线、三阶贝塞尔曲线、圆、圆弧组成的点

安装

# npm i -S unit-path

使用

import UnitPath from 'unit-path';

const unitPath = new UnitPath();

const path = unitPath.setPath('LINE', { x: 50, y: 50 }, { x: 100, y: 100 });

const point = path.getPoint(.5);
// or
const points = path.getPoints(50);

参数说明

setPath('Line', sp, ep);
setPath('TWO_ORDER_BEZIER', sp, cp, ep);
setPath('THREE_ORDER_BEZIER', sp, cp1, cp2, ep);
setPath('ARC', x, y, r, sAngle, eAngle, anitclockwise?);

getPoint(t); // t取值范围 [0, 1]

getPoints(quantity); // 获取点的数量