{"id":24132049,"url":"https://github.com/kaiido/canvas-setclip","last_synced_at":"2026-05-09T22:13:17.862Z","repository":{"id":108907244,"uuid":"316662463","full_name":"Kaiido/canvas-setClip","owner":"Kaiido","description":"Canvas setClip and resetClip methods polyfill","archived":false,"fork":false,"pushed_at":"2021-02-05T08:29:52.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T21:36:36.243Z","etag":null,"topics":["canvas-setclip","html-canvas","path2d","path2d-objects","setclip"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Kaiido.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":"2020-11-28T05:17:12.000Z","updated_at":"2021-01-29T09:01:47.000Z","dependencies_parsed_at":"2023-03-13T14:20:33.341Z","dependency_job_id":null,"html_url":"https://github.com/Kaiido/canvas-setClip","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiido%2Fcanvas-setClip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiido%2Fcanvas-setClip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiido%2Fcanvas-setClip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaiido%2Fcanvas-setClip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kaiido","download_url":"https://codeload.github.com/Kaiido/canvas-setClip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241333468,"owners_count":19945801,"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":["canvas-setclip","html-canvas","path2d","path2d-objects","setclip"],"created_at":"2025-01-11T21:32:42.681Z","updated_at":"2025-11-26T01:04:52.895Z","avatar_url":"https://github.com/Kaiido.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# setClip.js\n\nA `CanvasRenderingContext2D.setClip()` and `CanvasRenderingContext2D.resetClip()` polyfill.  \n\nThese methods are not *yet* part of the specs, but a long-dated request by web-devs [1][1], [2][2]\nwhich faced implementers' disapproval because they were supposedly impossible to implement.  \n\nThis polyfill proves it's possible to have such methods, albeit through quite dirty\noverrides.\n\n### Additions to the CanvasDrawPath interface mixin:\n\n```webidl\ninterface mixin CanvasDrawPath {\n  undefined setClip(optional CanvasFillRule fillRule = \"nonzero\");\n  undefined setClip(Path2D path, optional CanvasFillRule fillRule = \"nonzero\");\n  undefined resetClip();\n}\n```\n\n### Caveats\nBecause it overwrites all the drawing methods of the original context by using Path2D objects, this polyfill comes with a few caveats:\n\n - It requires **native support** for Path2D objects.\n - It may **not** be compatible with some drawing polyfills like `ellipse` or `roundRect`.\n - Drawing complex pathes when the context is transformed is slower when this polyfill is active.\n\nFor this last point, it is certainly best if you design your project to use only Path2D all along.\n\n### Should I use this polyfill?\n\nYour call. You can, but it comes with no warranty and is more a proof-of-concept than a real production ready code.\n\n[1]: https://www.w3.org/Bugs/Public/show_bug.cgi?id=14499\n[2]: https://whatwg.whatwg.narkive.com/v89Kf0y0/remove-resetclip-from-the-canvas-2d-spec#post11","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaiido%2Fcanvas-setclip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaiido%2Fcanvas-setclip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaiido%2Fcanvas-setclip/lists"}