Socket
Socket
Sign inDemoInstall

path2d-polyfill

Package Overview
Dependencies
1
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    path2d-polyfill

Polyfills Path2D api for canvas rendering


Version published
Weekly downloads
755K
decreased by-1.89%
Maintainers
1
Install size
60.5 kB
Created
Weekly downloads
 

Readme

Source

path2d-polyfill

CI

Polyfills Path2D api and roundRect for CanvasRenderingContext2D

Usage

Add this script tag to your page to enable the feature.

<script lang="javascript" src="https://cdn.jsdelivr.net/npm/path2d-polyfill/dist/path2d-polyfill.min.js"></script>

This will polyfill the browser's window object with Path2D features and it will also polyfill roundRect if they are missing in both CanvasRenderingContexst and Path2D.

Example of usage

ctx.fill(new Path2D("M 80 80 A 45 45 0 0 0 125 125 L 125 80 Z"));
ctx.stroke(new Path2D("M 80 80 A 45 45 0 0 0 125 125 L 125 80 Z"));

Support table

MethodSupported
constructor(SVGPath)Yes
addPath()Yes
closePath()Yes
moveTo()Yes
lineTo()Yes
bezierCurveTo()Yes
quadraticCurveTo()Yes
arc()Yes
ellipse()Yes
rect()Yes
roundRect()Yes

See it in action

Clone path2d-polyfill

pnpm install
pnpm dev

open http://localhost:5173/ to see the example page.

Contributing

Recommended to use vscode with the prettier extension to keep formatting intact.

Keywords

FAQs

Last updated on 04 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc