📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP

d3-path

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-path

Serialize Canvas path commands to SVG.

3.1.0
latest
Version published
Weekly downloads
11M
-10.63%
Maintainers
2
Weekly downloads
 
Created

What is d3-path?

The d3-path npm package is a part of the D3.js library and provides a way to create and manipulate SVG path elements. It offers a simple API to generate complex path data for SVG elements, which can be used for drawing shapes, lines, and curves in web applications.

What are d3-path's main functionalities?

Move To

The moveTo method sets the starting point of a new sub-path to the specified (x, y) coordinates.

const d3 = require('d3-path');
const path = d3.path();
path.moveTo(100, 100);
console.log(path.toString());

Line To

The lineTo method adds a straight line from the current point to the specified (x, y) coordinates.

const d3 = require('d3-path');
const path = d3.path();
path.moveTo(100, 100);
path.lineTo(200, 200);
console.log(path.toString());

Arc

The arc method creates an arc centered at (x, y) with the specified radius and start and end angles.

const d3 = require('d3-path');
const path = d3.path();
path.arc(150, 150, 50, 0, Math.PI / 2);
console.log(path.toString());

Bezier Curve

The bezierCurveTo method creates a cubic Bézier curve from the current point to the specified (x, y) coordinates using the specified control points.

const d3 = require('d3-path');
const path = d3.path();
path.moveTo(100, 100);
path.bezierCurveTo(150, 50, 200, 150, 250, 100);
console.log(path.toString());

Close Path

The closePath method closes the current sub-path by drawing a straight line back to the starting point.

const d3 = require('d3-path');
const path = d3.path();
path.moveTo(100, 100);
path.lineTo(200, 200);
path.closePath();
console.log(path.toString());

Other packages similar to d3-path

FAQs

Package last updated on 19 Dec 2022

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