{"id":26271294,"url":"https://github.com/lhuanyu/swiftclipper","last_synced_at":"2025-08-01T20:40:48.518Z","repository":{"id":93019795,"uuid":"214778072","full_name":"lhuanyu/SwiftClipper","owner":"lhuanyu","description":"A Swift version of polygon clipper.","archived":false,"fork":false,"pushed_at":"2023-04-21T00:55:35.000Z","size":49,"stargazers_count":23,"open_issues_count":2,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T15:14:14.122Z","etag":null,"topics":["polygon","polygon-clipping","polygon-intersection","polygon-offsetting","polygon-union","swift"],"latest_commit_sha":null,"homepage":"","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/lhuanyu.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,"zenodo":null}},"created_at":"2019-10-13T07:22:46.000Z","updated_at":"2025-04-10T18:39:45.000Z","dependencies_parsed_at":"2023-04-23T22:01:04.586Z","dependency_job_id":null,"html_url":"https://github.com/lhuanyu/SwiftClipper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lhuanyu/SwiftClipper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhuanyu%2FSwiftClipper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhuanyu%2FSwiftClipper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhuanyu%2FSwiftClipper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhuanyu%2FSwiftClipper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lhuanyu","download_url":"https://codeload.github.com/lhuanyu/SwiftClipper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhuanyu%2FSwiftClipper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263314105,"owners_count":23447291,"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":["polygon","polygon-clipping","polygon-intersection","polygon-offsetting","polygon-union","swift"],"created_at":"2025-03-14T06:19:19.081Z","updated_at":"2025-07-03T11:03:13.394Z","avatar_url":"https://github.com/lhuanyu.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftClipper\n\n**This package is basically a Swift translation of the [Clipper Lib](http://www.angusj.com/delphi/clipper.php) authored by Angusj.**\nFor the consideration of complexity and performance, some features(like big integer support, line clipping) have been temporarily removed. Most codes are reorganized or rewritten in a Swift convention.\n\n## Usage\n\n\nBasic functions are written as extensions of CGPoint Array. \n\n```swift\nimport SwiftClipper\n\nlet path = [CGPoint(x: -10, y: 10), CGPoint(x: 20, y: 10), CGPoint(x: 10, y: 0), CGPoint(x: 25, y: -8)]\nlet path2 = [CGPoint(x: -5, y: 5), CGPoint(x: 20, y: 5), CGPoint(x: 20, y: -15), CGPoint(x: -5, y: -15)]\n\nlet intersections  = path.intersection(path2) \n//[[(15.0, 5.0), (10.0, 0.0), (0.0, 5.0)]]\n\nlet unions = path.union(path2)\n//[[(15.0, 5.0), (20.0, 10.0), (-10.0, 10.0), (0.0, 5.0), (-5.0, 5.0), (-5.0, -15.0), (20.0, -15.0), (20.0, 5.0)]]\n```\n\nYou can also use the Clipper class for customized operations.\n\n```swift\nimport SwiftClipper\n\nlet path1 = [CGPoint(x: -10, y: 10), CGPoint(x: 20, y: 10), CGPoint(x: 10, y: 0), CGPoint(x: 25, y: -8)]\nlet path2 = [CGPoint(x: -5, y: 5), CGPoint(x: 20, y: 5), CGPoint(x: 20, y: -15), CGPoint(x: -5, y: -15)]\n\nvar paths = Paths()\nlet c = Clipper(options: .strictlySimple)\nc.addPath(path1, .subject, isClosed)\nc.addPath(path2, .clip, isClosed)\ntry c.execute(clipType: .difference, solution: \u0026paths)\n```\nAdditonal userful functions for geometry caculations are also included in these extensions. For details, check [Path+Geometry.swift](https://github.com/lhuanyu/SwiftClipper/blob/master/Sources/SwiftClipper/Path+Geometry.swift) and [Point.swift](https://github.com/lhuanyu/SwiftClipper/blob/master/Sources/SwiftClipper/Point.swift).\n\n## Note\n\nThe original lib uses integer numeric for caculations due to the presicion issue. For some cases, using a minor floating number as coordinates can reach a unpredicable or unprecise result. **If you want to a more precise result, try to use a magnification scale for your numbers**.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhuanyu%2Fswiftclipper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flhuanyu%2Fswiftclipper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhuanyu%2Fswiftclipper/lists"}