Socket
Book a DemoInstallSign in
Socket

@brendangooch/bezier

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brendangooch/bezier

a typescript class representing a bezier curve

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

bezier

a typescript class representing a bezier curve

With the QuadraticBezier class you can set 3 control points (start, control, end) and retrieve the any point on the bezier at any given t value between (and beyond) 0 - 1.

You can retrieve a rough approximation of the curve length and move to a distance on the curve rather than a t value.

Additionally, you can set the control point by angle (in radians) and distance from the start point or make the curve a straight line by calling makeStraight().

Finally, you can also retrive a unit vector that is tangent to the curve at any given t value


// basic usage
const bezier = new QuadraticBezier();
bezier.setStart(100, 800);
bezier.setEnd(800, 800);
bezier.setControl(550, 100);

// retriece the point 10% along the curve
bezier.setT(0.1);
const x = bezier.x;
const y = bezier.y;

// retrieve the tangent vector of the curve at 10%
const tangent = bezier.tangent

// move along the curve by distance instead of t for more accurate traversal
bezier.refreshLookup();

// get total length
const length = bezier.length;

// move 500 units along the curve
bezier.setDistance(500);
const x = bezier.x;
const y = bezier.y;

// set control point as an angle and distance away from the start point
bezier.setStart(100, 800);
bezier.setEnd(800, 800);
bezier.setControlByAngleDistance(Math.PI / 2, 500); // 90 degress, 500 units away

// make the bezier a straight line (much more efficient to use a Vector)
bezier.setStart(100, 800);
bezier.setEnd(800, 800);
bezier.makeStraight();

FAQs

Package last updated on 10 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.