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

svgpath

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgpath

Low level toolkit for SVG paths transformations.

  • 2.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
317K
decreased by-0.8%
Maintainers
1
Weekly downloads
 
Created

What is svgpath?

The svgpath npm package is a tool for transforming and manipulating SVG path data. It allows you to perform various operations such as scaling, translating, rotating, and more on SVG path strings.

What are svgpath's main functionalities?

Scaling

This feature allows you to scale the SVG path data. In the example, the path is scaled by a factor of 2 in both the x and y directions.

const svgpath = require('svgpath');
const pathData = 'M10 10 H 90 V 90 H 10 Z';
const scaledPath = svgpath(pathData).scale(2, 2).toString();
console.log(scaledPath);

Translating

This feature allows you to translate (move) the SVG path data. In the example, the path is moved 10 units to the right and 20 units down.

const svgpath = require('svgpath');
const pathData = 'M10 10 H 90 V 90 H 10 Z';
const translatedPath = svgpath(pathData).translate(10, 20).toString();
console.log(translatedPath);

Rotating

This feature allows you to rotate the SVG path data. In the example, the path is rotated by 45 degrees.

const svgpath = require('svgpath');
const pathData = 'M10 10 H 90 V 90 H 10 Z';
const rotatedPath = svgpath(pathData).rotate(45).toString();
console.log(rotatedPath);

Matrix Transformation

This feature allows you to apply a matrix transformation to the SVG path data. In the example, a transformation matrix is applied to the path.

const svgpath = require('svgpath');
const pathData = 'M10 10 H 90 V 90 H 10 Z';
const matrixTransformedPath = svgpath(pathData).matrix([1, 0, 0, 1, 30, 30]).toString();
console.log(matrixTransformedPath);

Converting to Absolute Coordinates

This feature allows you to convert relative coordinates in the SVG path data to absolute coordinates. In the example, the relative commands are converted to absolute commands.

const svgpath = require('svgpath');
const pathData = 'M10 10 h 80 v 80 h -80 Z';
const absolutePath = svgpath(pathData).abs().toString();
console.log(absolutePath);

Other packages similar to svgpath

Keywords

FAQs

Package last updated on 27 Apr 2019

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