{"id":13995385,"url":"https://github.com/hfutrell/BezierKit","last_synced_at":"2025-07-22T21:32:44.268Z","repository":{"id":37674184,"uuid":"72259217","full_name":"hfutrell/BezierKit","owner":"hfutrell","description":"Bezier curves and paths in Swift for building vector applications","archived":false,"fork":false,"pushed_at":"2024-10-22T00:18:24.000Z","size":2278,"stargazers_count":273,"open_issues_count":14,"forks_count":26,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-23T15:05:43.313Z","etag":null,"topics":["bezier","curve","intersect","path","vector-graphics"],"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/hfutrell.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":"2016-10-29T02:06:14.000Z","updated_at":"2024-11-10T10:47:59.000Z","dependencies_parsed_at":"2024-06-21T16:52:33.203Z","dependency_job_id":"963ef856-0d53-4511-9820-30d55c58d720","html_url":"https://github.com/hfutrell/BezierKit","commit_stats":{"total_commits":1201,"total_committers":7,"mean_commits":"171.57142857142858","dds":"0.023313905079100694","last_synced_commit":"11a87c261d03ac4d0a7c8d20595b841e5307e8cb"},"previous_names":[],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfutrell%2FBezierKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfutrell%2FBezierKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfutrell%2FBezierKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfutrell%2FBezierKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hfutrell","download_url":"https://codeload.github.com/hfutrell/BezierKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227177933,"owners_count":17743204,"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":["bezier","curve","intersect","path","vector-graphics"],"created_at":"2024-08-09T14:03:22.693Z","updated_at":"2024-11-29T17:31:38.326Z","avatar_url":"https://github.com/hfutrell.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# BezierKit\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/hfutrell/BezierKit/branch/master/graph/badge.svg)](https://codecov.io/gh/hfutrell/BezierKit)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/BezierKit.svg)](https://img.shields.io/cocoapods/v/BezierKit.svg)\n\nBezierKit is a comprehensive Bezier Path library written in Swift.\n\n- [Warning! Prerelease software!](#warning-prerelease-software)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [License](#license)\n\n## Warning! Prerelease software!\n\nPlease note that BezierKit is currently pre-release software. Its releases follow [semantic versioning](https://semver.org/) which means that until it reaches 1.0 status the API may not be stable or backwards compatible.\n\n## Features\n- [x] Constructs linear (line segment), quadratic, and cubic Bézier curves\n- [x] Draws curves via CoreGraphics\n- [x] Determines positions, derivatives, and normals along curves\n- [x] Lengths of curves via Legendre-Gauss quadrature\n- [x] Intersects curves and computes cubic curve self-intersection to any degree of accuracy\n- [x] Determines bounding boxes, extrema,\n- [x] Locates nearest on-curve location to point\n- [x] to any degree of accuracy\n- [x] Splits curves into subcurves\n- [x] Offsets and outlines curves\n- [ ] Comprehensive Unit and Integration Test Coverage\n- [ ] Complete Documentation\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate BezierKit into your Xcode project using CocoaPods, add it to your target in your `Podfile`:\n\n```ruby\ntarget '\u003cYour Target Name\u003e' do\n    pod 'BezierKit', '\u003e= 0.16.1'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.\nOnce you have your Swift package set up, adding BezierKit as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\n// swift-tools-version:5.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"\u003cYour Target Name\u003e\",\n    dependencies: [\n        .package(url: \"https://github.com/hfutrell/BezierKit.git\", from: \"0.16.1\"),\n    ]\n)\n```\n\n## Usage\n\n### Constructing \u0026 Drawing Curves\n\nBezierKit supports cubic Bezier curves (`CubicCurve`) and quadratic Bezier curves (`QuadraticCurve`) as well as line segments (`LineSegment`) each of which adopts the `BezierCurve` protocol that encompasses most API functionality.\n\n\u003cimg src=\"https://raw.githubusercontent.com/hfutrell/BezierKit/master/images/usage-construct.png\" width=\"256\" height=\"256\"\u003e\n\n```swift\nimport BezierKit\n\nlet curve = CubicCurve(\n    p0: CGPoint(x: 100, y: 25),\n    p1: CGPoint(x: 10, y: 90),\n    p2: CGPoint(x: 110, y: 100),\n    p3: CGPoint(x: 150, y: 195)\n )\n \n let context: CGContext = ...       // your graphics context here\n Draw.drawSkeleton(context, curve)  // draws visual representation of curve control points\n Draw.drawCurve(context, curve)     // draws the curve itself\n```\n\n### Intersecting Curves\n\nThe `intersections(with curve: BezierCurve) -\u003e [Intersection]` method determines each intersection between `self` and `curve` as an array of `Intersection` objects. Each intersection has two fields: `t1` represents the t-value for `self` at the intersection while `t2` represents the t-value for `curve` at the intersection. You can use the `point(at:)` method on either of the curves to calculate the coordinates of the intersection by passing in the corresponding t-value for the curve.\n\nCubic curves may self-intersect which can be determined by calling the `selfIntersections()` method.\n\n\u003cimg src=\"https://raw.githubusercontent.com/hfutrell/BezierKit/master/images/usage-intersects.png\" width=\"256\" height=\"256\"\u003e\n\n```swift\nlet intersections: [Intersection] = curve1.intersections(with: curve2)\nlet points: [CGPoint] = intersections.map { curve1.point(at: $0.t1) }\n\nDraw.drawCurve(context, curve: curve1)\nDraw.drawCurve(context, curve: curve2)\nfor p in points {\n    Draw.drawPoint(context, origin: p)\n}\n```\n\n### Splitting Curves\n\nThe `split(from:, to:)` method produces a subcurve over a given range of t-values. The `split(at:)` method can be used to produce a left subcurve and right subcurve created by splitting across a single t-value.\n\n\u003cimg src=\"https://raw.githubusercontent.com/hfutrell/BezierKit/master/images/usage-split.png\" width=\"256\" height=\"256\"\u003e\n\n```swift\nDraw.setColor(context, color: Draw.lightGrey)\nDraw.drawSkeleton(context, curve: curve)\nDraw.drawCurve(context, curve: curve)\nlet subcurve = curve.split(from: 0.25, to: 0.75) // or try (leftCurve, rightCurve) = curve.split(at:)\nDraw.setColor(context, color: Draw.red)\nDraw.drawCurve(context, curve: subcurve)\nDraw.drawCircle(context, center: curve.point(at: 0.25), radius: 3)\nDraw.drawCircle(context, center: curve.point(at: 0.75), radius: 3)\n```\n\n### Determining Bounding Boxes\n\n\u003cimg src=\"https://raw.githubusercontent.com/hfutrell/BezierKit/master/images/usage-bounding-box.png\" width=\"256\" height=\"256\"\u003e\n\n```swift\nlet boundingBox = curve.boundingBox\nDraw.drawSkeleton(context, curve: curve)\nDraw.drawCurve(context, curve: curve)\nDraw.setColor(context, color: Draw.pinkish)\nDraw.drawBoundingBox(context, boundingBox: curve.boundingBox)\n```\n\n### More\n\nBezierKit is a powerful library with *a lot* of functionality. For the time being the best way to see what it offers is to build the MacDemos target and check out each of the provided demos.\n\n## License\n\nBezierKit is released under the MIT license. [See LICENSE](https://github.com/hfutrell/BezierKit/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfutrell%2FBezierKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhfutrell%2FBezierKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfutrell%2FBezierKit/lists"}