Socket
Book a DemoInstallSign in
Socket

svg-path-to-polygon-points

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-path-to-polygon-points

[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

svg-path-to-polygon-points

Build Status

A simple npm module that converts an SVG path string into a polygon points string.

Installation

npm install svg-path-to-polygon-points

Usage

const svgToPolygonPoints = require('svg-path-to-polygon-points');
const path = 'M100,100 L200,200 L300,100';
const points = svgToPolygonPoints(path);
console.log(points);

[{
  x: 100,
  y: 100
}, {
  x: 110,
  y: 110
}, {
  x: 120,
  y: 120
}, {
  x: 130,
  y: 130
}, {
  x: 140,
  y: 140
}, {
  x: 150,
  y: 150
}, {
  x: 160,
  y: 160
}, {
  x: 170,
  y: 170
}, {
  x: 180,
  y: 180
}, {
  x: 190,
  y: 190
}, {
  x: 200,
  y: 200
}, {
  x: 210,
  y: 190
}, {
  x: 220,
  y: 180
}, {
  x: 230,
  y: 170
}, {
  x: 240,
  y: 160
}, {
  x: 250,
  y: 150
}, {
  x: 260,
  y: 140
}, {
  x: 270,
  y: 130
}, {
  x: 280,
  y: 120
}, {
  x: 290,
  y: 110.00000762939453
}]

API

svgToPolygonPoints(path)

Converts an SVG path string into a polygon points string.

Arguments path - The SVG path string to convert. Returns - A polygon points array

Contributing

Contributions are welcome! Please make a PR.

License

This project is licensed under the MIT License.

FAQs

Package last updated on 24 Feb 2023

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