Giter VIP home page Giter VIP logo

bezierpath-length's Introduction

[UI/NS]BezierPath + Length

Build Status codecov Code Climate Swift PodVersion platform Twitter Donate

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 9.0+

Installation

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.

bezierpath-length's People

Contributors

apppear avatar louisdh avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.