{"name":"path2d","version":"0.1.1","keywords":["Path2D","polyfill","canvas","roundRect"],"author":{"name":"nilzona"},"license":"MIT","_id":"path2d@0.1.1","maintainers":[{"name":"nilzona_user","email":"nilssonanders79@gmail.com"}],"homepage":"https://github.com/nilzona/path2d-polyfill#readme","bugs":{"url":"https://github.com/nilzona/path2d-polyfill/issues"},"dist":{"shasum":"d3c3886cd2252fb2a7830c27ea7bb9a862d937ea","tarball":"http://registry-npm.ywwl.com/path2d/download/path2d-0.1.1.tgz","fileCount":7,"integrity":"sha512-/+S03c8AGsDYKKBtRDqieTJv2GlkMb0bWjnqOgtF6MkjdUQ9a8ARAtxWf9NgKLGm2+WQr6+/tqJdU8HNGsIDoA==","signatures":[{"sig":"MEQCIEMX0WRKuGPz1MhhmyiGX+Y/dSud4CUcmV9QE+BhLncYAiAlGNFhBxZlvbKftMUKyrssK0vJK2PYiRz9720rW3rxoQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47268,"size":7496,"noattachment":false,"key":"/path2d/-/path2d-0.1.1.tgz"},"main":"dist/index.cjs","type":"module","_from":"file:path2d-0.1.1.tgz","types":"./dist/index.d.ts","engines":{"node":">=6"},"exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"lint":"eslint .","test":"vitest run","build":"tsup-node src/index.ts --target node18 --format esm,cjs --dts","watch":"pnpm build --watch","test:watch":"vitest","check-types":"tsc --noEmit","format:check":"prettier --check '**' --ignore-unknown","format:write":"prettier --write '**' --ignore-unknown","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"nilzona_user","email":"nilssonanders79@gmail.com"},"prettier":"@qlik/prettier-config","_resolved":"/tmp/c0dfa9859a979fbbc2b986d351b71b93/path2d-0.1.1.tgz","_integrity":"sha512-/+S03c8AGsDYKKBtRDqieTJv2GlkMb0bWjnqOgtF6MkjdUQ9a8ARAtxWf9NgKLGm2+WQr6+/tqJdU8HNGsIDoA==","repository":{"url":"git+https://github.com/nilzona/path2d-polyfill.git","type":"git"},"_npmVersion":"10.2.4","description":"Path2D API for node. Can be used for server-side rendering with canvas","directories":{},"_nodeVersion":"18.19.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"8.0.2","eslint":"8.57.0","rimraf":"5.0.5","vitest":"1.4.0","prettier":"3.2.5","@swc/core":"1.4.8","typescript":"5.4.2","@types/node":"20.11.28","@qlik/tsconfig":"0.2.4","@qlik/eslint-config":"0.7.13","@vitest/coverage-v8":"1.4.0","@qlik/prettier-config":"0.4.11"},"_npmOperationalInternal":{"tmp":"tmp/path2d_0.1.1_1710630926634_0.92970499977353","host":"s3://npm-registry-packages"},"readme":"# path2d\n\n[![CI](https://github.com/nilzona/path2d-polyfill/actions/workflows/ci.yml/badge.svg)](https://github.com/nilzona/path2d-polyfill/actions/workflows/ci.yml)\n\nImplements `Path2D` api and `roundRect` for CanvasRenderingContext2D\n\n## Usage\n\n```shell\nnpm install --save path2d\n```\n\n## Use in a node environment\n\nThe package exports a few functions that can be used in a node environment:\n\n- `Path2D` - class to create Path2D objects used by the polyfill methods\n- `parsePath` - function for parsing an SVG path string into canvas commands\n- `roundRect` - implementation of roundRect using canvas commands\n- `applyPath2DToCanvasRenderingContext` - Adds Path2D functions (if needed) to a CanvasRenderingContext and augments the fill, stroke and clip command\n- `applyRoundRectToCanvasRenderingContext2D` - Adds roundRect function (if needed) to a CanvasRenderingContext\n\n```js\nimport { Path2D } from \"path2d\";\n```\n\n### usage with node-canvas\n\nTo get Path2D features with the [node-canvas library](https://github.com/Automattic/node-canvas) use the following pattern:\n\n```js\nconst { createCanvas, CanvasRenderingContext2D } = require(\"canvas\");\nconst { applyPath2DToCanvasRenderingContext, Path2D } = require(\"path2d\");\n\napplyPath2DToCanvasRenderingContext(CanvasRenderingContext2D);\n// Path2D features has now been added to CanvasRenderingContext2D\n\nconst canvas = createCanvas(200, 200);\nconst ctx = canvas.getContext(\"2d\");\n\nconst p = new Path2D(\"M10 10 l 20 0 l 0 20 Z\");\nctx.fillStyle = \"green\";\nctx.fill(p);\n```\n\nA working example of a node express server that serves an image drawn with canvas [can be seen here](https://gist.github.com/nilzona/e611c99336d8ea1f645bd391a459c24f)\n\n## Support table\n\n| Method               | Supported |\n| -------------------- | :-------: |\n| constructor(SVGPath) |    Yes    |\n| addPath()            |    Yes    |\n| closePath()          |    Yes    |\n| moveTo()             |    Yes    |\n| lineTo()             |    Yes    |\n| bezierCurveTo()      |    Yes    |\n| quadraticCurveTo()   |    Yes    |\n| arc()                |    Yes    |\n| ellipse()            |    Yes    |\n| rect()               |    Yes    |\n| roundRect()          |    Yes    |\n\n## See it in action\n\nClone [path2d-polyfill](https://github.com/nilzona/path2d-polyfill)\n\n```shell\npnpm install\npnpm dev\n```\n\nopen <http://localhost:5173/> to see the example page.\n\n## Contributing\n\nRecommended to use vscode with the prettier extension to keep formatting intact.\n","publish_time":1710630926830,"_cnpm_publish_time":1710630926830,"dist-tags":{"latest":"0.3.5"}}