Latest 1.1.0
Homepage https://github.com/louisdh/bezierpath-length
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0, watchos 2.0
Authors

[UI/NS]BezierPath + Length

Build Status
codecov
Code Climate
BezierPathLength
PodVersion
platform
Twitter

This project provides a simple API to get the length of either a UIBezierPath or NSBezierPath. Example:

let rect = CGRect(origin: .zero, size: CGSize(width: 100, height: 300))
let path = UIBezierPath(ovalIn: rect)

// Length in pt.
let length = path.length

There’s also an API for getting a point on a path at a certain percentage, example:

// CGPoint at 50% of path
let point = path.point(at: 0.5)

Requirements

  • iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 8.2+

Installation

CocoaPods

To install, add the following line to your Podfile:

pod 'BezierPathLength', '~> 1.0.0'

How does it work?

The actual calculations are implemented on a CGPath extension, but a [UI/NS]BezierPath extension is available for convenience.

Any CGPath can be split into subpaths. Of which there are three types:

  • Linear
  • Quadratic curve
  • Cubic curve

See calculations.md for a detailed mathematical explanation of how the length of these three can be calculated.

License

This project is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "BezierPathLength",
    "version": "1.1.0",
    "license": "MIT",
    "summary": "A simple API to get the length of a CGPath, UIBezierPath or NSBezierPath, written in Swift.",
    "homepage": "https://github.com/louisdh/bezierpath-length",
    "social_media_url": "http://twitter.com/LouisDhauwe",
    "authors": {
        "Louis D'hauwe": "[email protected]"
    },
    "source": {
        "git": "https://github.com/louisdh/bezierpath-length.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "source_files": "Source/*.swift",
    "pushed_with_swift_version": "3.0.2"
}

Pin It on Pinterest

Share This