• Version 3.0.0
  • Published
  • 430 kB
  • 1 dependency
  • MIT license


npm i @antv/util
yarn add @antv/util
pnpm add @antv/util


> AntV 底层依赖的工具库,不建议在自己业务中使用。



function angleTo

angleTo: (
v1: [number, number],
v2: [number, number],
direct?: boolean
) => number;
  • 二维向量 v1 到 v2 的夹角

    Parameter v1

    Parameter v2

    Parameter direct

function catmullRom2Bezier

catmullRom2Bezier: (
crp: number[],
z?: boolean,
constraint?: Pos[]
) => PathCommand[];
  • create bezier spline from catmull rom spline

    Parameter crp

    Catmull Rom Points

    Parameter z

    Spline is loop

    Parameter constraint


function direction

direction: (v1: number[], v2: number[]) => number;
  • 向量 v1 到 向量 v2 夹角的方向

    Parameter v1


    Parameter v2

    向量 {Boolean} >= 0 顺时针 < 0 逆时针

function fillPath

fillPath: (source: any, target: any) => any;

    function fillPathByDiff

    fillPathByDiff: (source: string, target: string) => string;

      function formatPath

      formatPath: (fromPath: any[][], toPath: any[][]) => any[][];

        function getArcParams

        getArcParams: (
        startPoint: any,
        params: any
        ) => {
        cx: number;
        cy: number;
        rx: any;
        ry: any;
        startAngle: number;
        endAngle: number;
        xRotation: number;
        arcFlag: any;
        sweepFlag: any;

          function getLineIntersect

          getLineIntersect: (p0: Point, p1: Point, p2: Point, p3: Point) => Point | null;

            function gradient

            gradient: (colors: string | string[]) => (percent: number) => string;
            • 获取渐变函数

              Parameter colors

              多个颜色 颜色值

            function isPointInPolygon

            isPointInPolygon: (points: any, x: any, y: any) => boolean;
            • 判断点是否在多边形内 dxq613@gmail.com

            function isPolygonsIntersect

            isPolygonsIntersect: (points1: any, points2: any) => boolean;

              function parsePath

              parsePath: (p: string) => string[];

                function parsePathArray

                parsePathArray: (path: any[]) => string;

                  function parsePathString

                  parsePathString: (pathString: string) => any[];

                    function path2Absolute

                    path2Absolute: (pathString: string) => any[];

                      function path2Curve

                      path2Curve: (
                      path: PathCommand[] | string,
                      needZCommandIndexes?: boolean
                      ) => PathCommand[] | (number[] | PathCommand[])[];

                        function path2Segments

                        path2Segments: (path: any) => any[];

                          function pathIntersection

                          pathIntersection: (path1: any, path2: any) => number | any[];

                            function rectPath

                            rectPath: (x: number, y: number, w: number, h: number, r?: number) => Ele[];

                              function rgb2arr

                              rgb2arr: (str: string) => number[];
                              • rgb 颜色转换成数组

                                Parameter str


                              function toCSSGradient

                              toCSSGradient: (gradientColor: any) => any;

                                function toRGB

                                toRGB: (color: string) => string;
                                • 将颜色转换到 rgb 的格式

                                  Parameter color

                                  颜色 将颜色转换到 '#ffffff' 的格式

                                function transform

                                transform: (m: number[], actions: any[][]) => any[];
                                • 根据 actions 来做 transform

                                  Parameter m

                                  Parameter actions

                                function vertical

                                vertical: (out: number[], v: number[], flag: boolean) => number[];
                                • 计算二维向量的垂直向量

                                  Parameter out

                                  Parameter v

                                  Parameter flag

                                Package Files (22)

                                Dependencies (1)

                                Dev Dependencies (22)

                                Peer Dependencies (1)


                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@antv/util.

                                • Markdown
                                • HTML
                                  <a href="https://www.jsdocs.io/package/@antv/util"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>