closest-point-on-bezier

1.0.12 • Public • Published

closest-point-on-bezier

Given a bezier curve and a point, finds which point in the curve is closest to the given point

usage:

import closestPoint from "closest-point-on-bezier";

const {relative_position, absolute_point} = closestPoint(
    [
        {x:20,y:20},
        {x:20,y:100},
        {x:200,y:100},
        {x:200,y:20}
    ],
    {x:offsetX,y:offsetY}
)

result:

{
relative_position : number, // the relative position of the point on the curve (0 - 1)
absolute_point: { // the absolute position of the point(x, y)
    x : number,
    y : number
},

example of what data this program cauculates

image

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i closest-point-on-bezier

    Weekly Downloads

    1

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    4.62 kB

    Total Files

    4

    Last publish

    Collaborators

    • thiago-kaique