{"id":16756948,"url":"https://github.com/calda/cgpathintersection","last_synced_at":"2025-08-11T21:07:36.671Z","repository":{"id":44597761,"uuid":"73635897","full_name":"calda/CGPathIntersection","owner":"calda","description":":curly_loop: A library that identifies points where two CGPaths intersect","archived":false,"fork":false,"pushed_at":"2022-02-05T23:54:57.000Z","size":6501,"stargazers_count":68,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-02T12:17:26.731Z","etag":null,"topics":["core-graphics","intersection","ios","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/calda.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}},"created_at":"2016-11-13T18:52:51.000Z","updated_at":"2024-11-02T18:02:25.000Z","dependencies_parsed_at":"2022-08-20T19:20:29.033Z","dependency_job_id":null,"html_url":"https://github.com/calda/CGPathIntersection","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/calda/CGPathIntersection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calda%2FCGPathIntersection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calda%2FCGPathIntersection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calda%2FCGPathIntersection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calda%2FCGPathIntersection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calda","download_url":"https://codeload.github.com/calda/CGPathIntersection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calda%2FCGPathIntersection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269956542,"owners_count":24503194,"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-08-11T02:00:10.019Z","response_time":75,"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":["core-graphics","intersection","ios","swift"],"created_at":"2024-10-13T03:42:30.198Z","updated_at":"2025-08-11T21:07:36.646Z","avatar_url":"https://github.com/calda.png","language":"Swift","readme":"# CGPathIntersection\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fcalda%2FCGPathIntersection%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/calda/CGPathIntersection) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fcalda%2FCGPathIntersection%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/calda/CGPathIntersection)\n\n**CGPathIntersection** is a library for iOS, macOS, and tvOS that identifies points where two `CGPath`s intersect.\n\nSurprisingly, this is not provided out-of-the-box by `CoreGraphics`. Intersections can be calculated analytically for simple geometric shapes (especially straight lines), but that method becomes rather challenging when considering a `CGPath` can be arbitrarily complex. `CGPathIntersection` solves this problem by rendering each path into an image and then finding the exact pixels where they intersect.\n\n## Installation\n#### [Swift Package Manager](https://www.swift.org/package-manager/)\nAdd the following dependency to your package definition:\n\n```swift\n.package(\n  name: \"CGPathIntersection\",\n  url: \"https://github.com/calda/CGPathIntersection.git\",\n  from: \"4.0.0\")\n```\n\n#### [Carthage](https://github.com/Carthage/Carthage)\nAdd `github \"calda/CGPathIntersection\"` to your Cartfile\n\n#### [CocoaPods](https://github.com/cocoapods/cocoapods)\nAdd `pod 'CGPathIntersection'` to your Podfile\n\n## Usage\n\n```swift\nimport CGPathIntersection\n\nlet path1 = CGPath(...)\nlet path2 = CGPath(...)\n        \npath1.intersects(path2) // returns a boolean\npath1.intersectionPoints(with: path2) // returns an array of points\n```\n\nIf performing many calculations, you can increase performance by creating a `CGPathImage`. Any calculations performed on a pre-existing `CGPathImage` will run faster than the same calculation performed on a raw `CGPath`.\n\n```swift\nimport CGPathIntersection\n\nlet pathImage = CGPathImage(from: CGPath(...))\nlet otherPathImages: [CGPathImage] = [...]\n\nlet intersectingPaths = otherPathImages.filter { pathImage.intersects($0) }\n```\n\n## Example\n\nCGPathIntersection was created as a component of **[Streets](http://github.com/calda/Streets)**, a prototype SpriteKit game that simulates managing a network of streets. Streets uses CGPathIntersection to connect individual roads together with physical intersections. When a car reaches an intersection, it makes a random turn onto one of the other connected roads.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"images/streets.gif\" width=250px\u003e \u003cimg src=\"images/streets 2.gif\" width=250px\u003e\n\u003c/p\u003e\n\nStreets also has some support for more complex paths, like roundabouts:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"images/roundabout.jpg\" width=250px\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalda%2Fcgpathintersection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalda%2Fcgpathintersection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalda%2Fcgpathintersection/lists"}