{"id":20763708,"url":"https://github.com/glenzli/paperjs-offset","last_synced_at":"2025-04-30T07:50:20.059Z","repository":{"id":44507483,"uuid":"182532030","full_name":"glenzli/paperjs-offset","owner":"glenzli","description":"An offset function for paperjs path","archived":false,"fork":false,"pushed_at":"2023-07-12T08:27:34.000Z","size":264,"stargazers_count":100,"open_issues_count":13,"forks_count":21,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-25T16:47:32.942Z","etag":null,"topics":["bezier","canvas","curve","offset","paper","paperjs","stroke"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glenzli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-21T12:45:49.000Z","updated_at":"2025-03-24T01:17:00.000Z","dependencies_parsed_at":"2024-06-18T20:03:51.851Z","dependency_job_id":"1462d7e2-2101-4349-8bdb-8d30cbac801d","html_url":"https://github.com/glenzli/paperjs-offset","commit_stats":null,"previous_names":["luz-alphacode/paperjs-offset"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glenzli%2Fpaperjs-offset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glenzli%2Fpaperjs-offset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glenzli%2Fpaperjs-offset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glenzli%2Fpaperjs-offset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glenzli","download_url":"https://codeload.github.com/glenzli/paperjs-offset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251666227,"owners_count":21624291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bezier","canvas","curve","offset","paper","paperjs","stroke"],"created_at":"2024-11-17T10:45:41.226Z","updated_at":"2025-04-30T07:50:20.029Z","avatar_url":"https://github.com/glenzli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Paperjs Offset\nThe dicussion to implement a offset function in paper.js started years ago, yet the author have not decided to put a offset feature into the library. So I implement an extension of my own.\n\u003cbr/\u003eAs far as I know, the author has promised recently to implement a native offset functionality in near feature, the library will be closed once the native implement is published.\n\u003cbr/\u003eThis library implement both path offset and stroke offset, you may offset a path or expand a stroke like what you did in Adobe illustrator. Offset complicate path may cause unwanted self intersections, this library already take care some cases but bugs still exists. Please let me notice the false conditions in the issue pannel so I can correct it.\n\n## Usage\nFor node development, use\n```sh\nnpm install paperjs-offset\n```\nAnd then, in you project:\n```javascript\nimport paper from 'paper'\nimport { PaperOffset } from 'paperjs-offset'\n\n// call offset\nPaperOffset.offset(path, offset, options)\n\n// call offset stroke\nPaperOffset.offsetStroke(path, offset, options)\n```\n\nYou may still use the old way to extend paperjs module, which is **deprecated** and will be removed in future version.\n```typescript\nimport ExtendPaperJs from 'paperjs-offset'\n// extend paper.Path, paper.CompoundPath with offset, offsetStroke method\nExtendPaperJs(paper);\n\n// Warning: The library no longer include extended definitions for paper.Path \u0026 paper.CompoundPath, you may need your own declarations to use extension in typescript.\n(path as any).offset(10);\n```\n\nOr for web development, include the **paperjs-offset.js** or **paperjs-offset.min.js** in demo folder.\n\u003cbr/\u003eThe library now exposes a global variable **PaperOffset**, again, the extension of **paper.Path** and **paper.CompoundPath** with offset/offsetStroke functions is still available, but no longer recommended.\n```javascript\nlet path = new paper.Path(/* params */)\n\nPaperOffset.offset(path, 10, { join: 'round' })\nPaperOffset.offsetStroke(path, 10, { cap: 'round' })\n\n// deprecated\npath.offset(10, { join: 'round' })\n// deprecated\npath.offsetStroke(10, { cap: 'round' })\n```\n\nSample references:\n```typescript\noffset(path: paper.Path | paper.CompoundPath, offset: number, options?: OffsetOptions): paper.Path | paper.CompoundPath\n\noffsetStroke(path: paper.Path | paper.CompoundPath, offset: number, options?: OffsetOptions): paper.Path | paper.CompoundPath\n\ninterface OffsetOptions {\n  // the join style of offset path, default is 'miter'\n  join?: 'miter' | 'bevel' | 'round';\n  // the cap style of offset (only validate for offsetStroke), default is 'butt', ('square' will be supported in future)\n  cap?: 'butt' | 'round';\n  // the limit for miter style (refer to the miterLimit definition in paper)\n  limit?: number;\n  // whether the result should be insert into the canvas, default is true\n  insert?: boolean;\n}\n```\n\n## Preview\nThere are some cases that the library may return weird result or failed silently, please let me noticed in the project issues. And in some cases the library will yeild an ok result than a perfect one. Currently the library should give good results for closed shapes, but may fail in some open curve cases, I'm still working on it.\n![Preview](/public/preview.jpg)\n\nYou can use open demo folder for simple cases demonstration.\n\n## License\nDistributed under the MIT license. See [LICENSE](https://github.com/glenzli/paperjs-offset/blob/master/LICENSE) for detail.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglenzli%2Fpaperjs-offset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglenzli%2Fpaperjs-offset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglenzli%2Fpaperjs-offset/lists"}