{"id":19988879,"url":"https://github.com/chenhaiteng/coregraphicsextension","last_synced_at":"2026-04-10T21:47:32.479Z","repository":{"id":52107958,"uuid":"345585309","full_name":"chenhaiteng/CoreGraphicsExtension","owner":"chenhaiteng","description":"The extension of Core Graphics -- add angle and polar point to support polar coordinates","archived":false,"fork":false,"pushed_at":"2024-04-02T02:32:29.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-13T09:18:13.385Z","etag":null,"topics":["coregraphics","framework","ios","macos","polar-coordinates","radians","spm","swift","swift-package-manager","tvos","watchos"],"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/chenhaiteng.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":"2021-03-08T08:35:37.000Z","updated_at":"2024-09-23T13:55:42.000Z","dependencies_parsed_at":"2024-11-13T04:44:32.503Z","dependency_job_id":"3cd1f46c-82d1-4bc9-8a5f-6d6ef816dc06","html_url":"https://github.com/chenhaiteng/CoreGraphicsExtension","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhaiteng%2FCoreGraphicsExtension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhaiteng%2FCoreGraphicsExtension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhaiteng%2FCoreGraphicsExtension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhaiteng%2FCoreGraphicsExtension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenhaiteng","download_url":"https://codeload.github.com/chenhaiteng/CoreGraphicsExtension/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241430298,"owners_count":19961633,"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":["coregraphics","framework","ios","macos","polar-coordinates","radians","spm","swift","swift-package-manager","tvos","watchos"],"created_at":"2024-11-13T04:44:28.466Z","updated_at":"2026-04-10T21:47:27.454Z","avatar_url":"https://github.com/chenhaiteng.png","language":"Swift","funding_links":["https://www.buymeacoffee.com/chenhaiteng","https://img.buymeacoffee.com/button-api/?text=Buy"],"categories":[],"sub_categories":[],"readme":"# CoreGraphicsExtension ![GitHub](https://img.shields.io/github/license/chenhaiteng/coregraphicsextension?style=plastic)\n\nA small libray to provide polar coordinate feature to extend CoreGraphics\n\n\n## Installation:\n\n### CocoaPods\nCoreGraphicsExtension is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'CoreGraphicsExtension'\n```\n\n### Swift Package Manager\n#### - Add to Xcode:\n\n1. File \u003e Swift Packages \u003e Add Package Dependency...\n2. Choose Project you want to add CoreGraphicExtension\n3. Paste repository https://github.com/chenhaiteng/CoreGraphicsExtension.git\n4. Rules \u003e Version: Up to Next Major 0.3.1\nIt's can also apply Rules \u003e Branch : Main to access latest code.\n\n**Note:** It might need to link CoreGraphicsExtension to your target maunally.\n\n1. Open *Project Editor* by tap on root of project navigator\n2. Choose the target you want to use CoreGraphicsExtension.\n3. Choose **Build Phases**, and expand **Link Binary With Libraries**\n4. Tap on **+** button, and choose CoreGraphics to add it.\n\n#### - Add to SPM package: \n```swift\ndependencies: [\n    .package(name: \"CoreGraphicsExtension\", url: \"https://github.com/chenhaiteng/CoreGraphicsExtension.git\", from: \"0.3.1\")\n],\ntargets: [\n    .target(\n        name: \"MyPackage\",\n        dependencies: [\"CoreGraphicsExtension\"]),\n]\n```\n\n## Features:\n### CGAngle\nThe alias of CGFloat, and presume its unit as radians.\nIt also provides functions to transform radians and degrees.\n\n#### Usage:\n```swift\n// Create CGAngle\nlet rightAngle = CGAngle.pi/2\nlet rightAngle2 = CGAngle.degrees(90.0)\nlet rightAngle3 = CGAngle.radians(CGFloat.pi/2)\nlet rightAngle4 = CGAngle.radians(Double.pi/2)\n\n// Compare CGAngle with floating numbers in different unit. \nXCTAssertEqual(rightAngle, CGFloat.pi/2)\nXCTAssertEqual(rightAngle.degrees, 90)\nXCTAssertEqual(rightAngle.radians, CGFloat.pi/2)\n```\n\n### CGPolarPoint\nA structure to show point in polar coordiante.\nProvides convenient method to transform to rectangular coordinate(a.k.a Cartesian coordinate system) \n\n#### Usage:\n```swift\n// Create polar point\nlet originPt = CGPolarPoint.zero\nlet upPoint = CGPolarPoint(radius: CGFloat(1), angle: CGAngle.pi/2)\nlet rightUpPoint = CGPolarPoint(radius: CGFloat(sqrt(2)), angle: CGAngle.pi/4)\n\n// Get point in rectangular coordinate:\nlet rectPt = rightUpPoint.cgpoint\n```\n### CGPoint(Offset)\nApply convenient offset functions and operator(\u003e\u003e) on CGPoint.\n\n#### Usage:\n```swift\nlet basePt = CGPoint.zero\n\n// Offset the base point by a CGPoint.\nlet offsetPt = CGPoint(x: 1, y: 1)\nXCTAssertEqual(basePt.offset(by: offsetPt), offsetPt)\nXCTAssertEqual(basePt \u003e\u003e offsetPt, offsetPt)\n\n// Offset the base point by a CGSize.\nlet offsetSize = CGSize(width: 1, height: 1)\nXCTAssertEqual(basePt.offset(by: offsetSize), offsetPt)\nXCTAssertEqual(basePt \u003e\u003e offsetSize, offsetPt)\n\n// Offset the base point by specified dx and dy\nXCTAssertEqual(basePt.offset(dx: 1, dy: 1), offsetPt)\nXCTAssertEqual(basePt \u003e\u003e (1, 1), offsetPt)\n\n```\n\n### CGRect(Offset)\nApply convenient offset operator(\u003e\u003e) on CGRect.\n#### Usage:\n```swift\nlet baseRect = CGRect(origin: .zero, size: CGSize(width: 100, height: 120))\n\n// Offset the rect by CGPoint\nlet offsetPt = CGPoint(x: 1, y: 1)\nXCTAssertNotEqual((baseRect \u003e\u003e offsetPt).origin, baseRect.origin)\nXCTAssertEqual((baseRect \u003e\u003e offsetPt).origin, offsetPt)\nXCTAssertEqual((baseRect \u003e\u003e offsetPt).size, baseRect.size)\n\n// Offset the rect by CGSize\nlet offsetSize = CGSize(width: 1, height: 1)\nXCTAssertEqual((baseRect \u003e\u003e offsetSize).origin, offsetPt)\nXCTAssertEqual((baseRect \u003e\u003e offsetSize).size, baseRect.size)\n\n// Offset the rect by specified dx, dy.\nXCTAssertEqual((baseRect \u003e\u003e (1, 1)).origin, offsetPt)\nXCTAssertEqual((baseRect \u003e\u003e (1, 1)).size, baseRect.size)\n```\n\n### CGRect(FitSquare)\nCreate a derived square rect that scale to fit its source rect with the same center point.\n\n#### Usage:\n```swift\nlet originRect = CGRect(origin: .zero, size: CGSize(width: 100, height: 120))\nXCTAssertEqual(originRect.fitSquare(), CGRect(x: 0, y: 10, width: 100, height: 100))\n\n```\n\n### CGRect(Center)\nA computed variable that return current center of the rect.\n\n### Usage:\n```\nlet rect = CGRect(origin: .zero, size: CGSize(width: 100, height: 120))\nlet center = rect.center\n```\n\n# License\nCoreGraphicsExtension is released under the [MIT License](LICENSE).\n---\n\nIf you find this library useful, one coffee could help it going.\n\u003ca href=\"https://www.buymeacoffee.com/chenhaiteng\"\u003e\u003cimg src=\"https://img.buymeacoffee.com/button-api/?text=Buy me a coffee\u0026emoji=☕\u0026slug=chenhaiteng\u0026button_colour=FFDD00\u0026font_colour=000000\u0026font_family=Cookie\u0026outline_colour=000000\u0026coffee_colour=ffffff\" /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenhaiteng%2Fcoregraphicsextension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenhaiteng%2Fcoregraphicsextension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenhaiteng%2Fcoregraphicsextension/lists"}