{"id":32150730,"url":"https://github.com/ishape-swift/ioverlay","last_synced_at":"2025-10-21T10:18:33.774Z","repository":{"id":180131887,"uuid":"664639403","full_name":"iShape-Swift/iOverlay","owner":"iShape-Swift","description":"Boolean Operations for 2D Polygons: Supports intersection, union, difference, xor, and self-intersections for all polygon varieties.","archived":false,"fork":false,"pushed_at":"2024-11-27T18:52:56.000Z","size":844,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-27T17:46:35.180Z","etag":null,"topics":["boolean-operations","clipper","clipping","difference","intersection","poly-bool","polygon","polygon-clipping","self-intersection","union","vatti-clipping","xor"],"latest_commit_sha":null,"homepage":"https://ishape-rust.github.io/iShape-js/overlay/stars_demo.html","language":"Swift","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/iShape-Swift.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}},"created_at":"2023-07-10T12:25:00.000Z","updated_at":"2025-08-21T05:33:01.000Z","dependencies_parsed_at":"2024-04-19T20:27:20.596Z","dependency_job_id":null,"html_url":"https://github.com/iShape-Swift/iOverlay","commit_stats":null,"previous_names":["ishape-swift/ioverlay"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/iShape-Swift/iOverlay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iShape-Swift%2FiOverlay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iShape-Swift%2FiOverlay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iShape-Swift%2FiOverlay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iShape-Swift%2FiOverlay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iShape-Swift","download_url":"https://codeload.github.com/iShape-Swift/iOverlay/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iShape-Swift%2FiOverlay/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280241999,"owners_count":26296883,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["boolean-operations","clipper","clipping","difference","intersection","poly-bool","polygon","polygon-clipping","self-intersection","union","vatti-clipping","xor"],"created_at":"2025-10-21T10:18:32.702Z","updated_at":"2025-10-21T10:18:33.766Z","avatar_url":"https://github.com/iShape-Swift.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iOverlay\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/iShape-Swift/iOverlay/blob/main/Readme/balloons.svg\" width=\"250\"/\u003e\n\u003c/p\u003e\n\nThe iOverlay is a fast poly-bool library supporting main operations like union, intersection, difference, and xor, governed by either the even-odd or non-zero rule.  \nThis library is optimized for different scenarios, ensuring high performance across various use cases. For detailed performance benchmarks, check out the [Performance Comparison](https://ishape-rust.github.io/iShape-js/overlay/performance/performance.html)\n\n## [Documentation](https://ishape-rust.github.io/iShape-js/overlay/stars_demo.html)\nTry out iOverlay with an interactive demo. The demo covers operations like union, intersection, difference and exclusion\n\n- [Stars Rotation](https://ishape-rust.github.io/iShape-js/overlay/stars_demo.html)\n- [Shapes Editor](https://ishape-rust.github.io/iShape-js/overlay/shapes_editor.html)\n\n\n\n## Features\n\n- **Operations**: union, intersection, difference, and exclusion.\n- **Polygons**: with holes, self-intersections, and multiple paths.\n- **Simplification**: removes degenerate vertices and merges collinear edges.\n- **Fill Rules**: even-odd and non-zero.\n\n\n\n## Working Range and Precision\nThe iOverlay library operates within the following ranges and precision levels:\n\nExtended Range: From -1,000,000 to 1,000,000 with a precision of 0.001.\nRecommended Range: From -100,000 to 100,000 with a precision of 0.01 for more accurate results.\nUtilizing the library within the recommended range ensures optimal accuracy in computations and is advised for most use cases.\n\n\n\n## Installation\n\nInstalling iOverlay is simple and easy using Swift Package Manager. Just follow these steps:\n\n- Open your Xcode project.\n- Select your project and open tab Package Dependencies.\n- Click on the \"+\" button.\n- In search bar enter ```https://github.com/iShape-Swift/iOverlay```\n- Click the \"Add\" button.\n- Wait for the package to be imported.\n- In your Swift code, add the following using statement to access the library:\n\n```swift\nimport iOverlay\n```\n\n\n\n## Usage\n\nHere's an example of how you can create a square with a hole and *union / differnce / intersect / xor* with other polygon:\n\n```swift\nvar overlay = CGOverlay()\n\n// add shape\noverlay.add(path: [\n    CGPoint(x:-20, y:-16),\n    CGPoint(x:-20, y: 16),\n    CGPoint(x: 20, y: 16),\n    CGPoint(x: 20, y:-16)\n], type: ShapeType.subject)\n\n// add hole\noverlay.add(path: [\n    CGPoint(x:-12, y:-8),\n    CGPoint(x:-12, y: 8),\n    CGPoint(x: 12, y: 8),\n    CGPoint(x: 12, y:-8)\n], type: ShapeType.subject)\n\n// add clip\noverlay.add(path: [\n    CGPoint(x:-4, y:-24),\n    CGPoint(x:-4, y: 24),\n    CGPoint(x: 4, y: 24),\n    CGPoint(x: 4, y:-24)\n], type: ShapeType.clip)\n\n// make overlay graph\nlet graph = overlay.buildGraph()\n\n// get union shapes\nlet union = graph.extractShapes(overlayRule: OverlayRule.union)\n\n// get difference shapes\nlet difference = graph.extractShapes(overlayRule: OverlayRule.difference)\n\n// get intersect shapes\nlet intersect = graph.extractShapes(overlayRule: OverlayRule.intersect)\n\n// get exclusion shapes\nlet xor = graph.extractShapes(overlayRule: OverlayRule.xor)\n\n// get clean shapes from subject, self intersections will be removed\nlet subject = graph.extractShapes(overlayRule: OverlayRule.subject)\n```\n\n### Shapes result\n\nThe output of the `extractShapes` function is a `[[[CGPoint]]]`, where:\n\n- The outer `[CGShape]` represents a set of shapes.\n- Each shape `[CGPath]` represents a collection of paths, where the first path is the outer boundary, and all subsequent paths are holes in this boundary.\n- Each path `[CGPoint]` is a sequence of points, forming a closed path.\n\n**Note**: Outer boundary paths have a clockwise order, and holes have a counterclockwise order.\n\n### Union\n\u003cp align=\"left\"\u003e\n\u003cimg src=\"https://github.com/iShape-Swift/iOverlay/blob/main/Readme/union.svg\" width=\"250\"/\u003e\n\u003c/p\u003e\n\n### Difference\n\u003cp align=\"left\"\u003e\n\u003cimg src=\"https://github.com/iShape-Swift/iOverlay/blob/main/Readme/difference.svg\" width=\"250\"/\u003e\n\u003c/p\u003e\n\n### Intersection\n\u003cp align=\"left\"\u003e\n\u003cimg src=\"https://github.com/iShape-Swift/iOverlay/blob/main/Readme/intersection.svg\" width=\"250\"/\u003e\n\u003c/p\u003e\n\n### Exclusion (xor)\n\u003cp align=\"left\"\u003e\n\u003cimg src=\"https://github.com/iShape-Swift/iOverlay/blob/main/Readme/exclusion.svg\" width=\"250\"/\u003e\n\u003c/p\u003e\n\n### Self-intersection\n\u003cp align=\"left\"\u003e\n\u003cimg src=\"https://github.com/iShape-Swift/iOverlay/blob/main/Readme/self-intersecting.svg\" width=\"250\"/\u003e\n\u003c/p\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishape-swift%2Fioverlay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishape-swift%2Fioverlay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishape-swift%2Fioverlay/lists"}