Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svg-path-properties

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-path-properties

Calculate the length for an SVG path, to use it with node or a Canvas element

  • 0.4.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
77K
increased by4.08%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage Status

svg-path-properties

Pure Javascript alternative to getPointAtLength(t) and getTotalLength() functions. Works with Canvas and Node

JavaScript can access to path elements properties in a browser, such as its length and the point at a given length. Unfortunately, this can't be achieved using a Canvas element or when working with node. This library can be used to replace this need. It has no dependencies on other JavaScript libraries.

INSTALL

To use with npm, just type

npm install svg-path-properties

USAGE

var path = require("svg-path-properties");
var properties = path.svgPathProperties("M0,100 Q50,-50 100,100 T200,100");
var length = properties.getTotalLength();
var point = properties.getPointAtLength(200);
var tangent = properties.getTangentAtLength(200);
var allProperties = properties.getPropertiesAtLength(200);
var parts = properties.getParts(); --> Gets an array with the different sections of the path, each element containing the initial and final points, the length and the curve function

Check this block to see how it works with the browser.

CREDITS

Some parts of the code are taken from other libraries or questions at StackOverflow:

For Bézier curves:

For path parsing:

Keywords

FAQs

Package last updated on 30 Nov 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc