Latest 0.1.0
Homepage https://github.com/gscalzo/SwiftCubicSpline
License MIT
Platforms ios 8.0, requires ARC
Dependencies SAMCubicSpline
Frameworks Foundation, CoreGraphics
Authors

Version
License
Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

SwiftCubicSpline is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SwiftCubicSpline"

Example

        let spline = CubicSpline(points: [
            CGPoint(x: 0.0, y: 0.5),
            CGPoint(x: 0.1, y: 0.5),
            CGPoint(x: 0.2, y: 0.7),
            CGPoint(x: 0.4, y: 0.3),
            CGPoint(x: 0.6, y: 0.6),
            CGPoint(x: 0.8, y: 0.4),
            CGPoint(x: 0.9, y: 0.5),
            CGPoint(x: 1.0, y: 0.5)
            ])

        let graphSize = self.bounds.size
        for x in 0 ..< Int(graphSize.height) {
            let y = spline.interpolate(CGFloat(x)/graphSize.height)*graphSize.width
            if x == 0 {
                CGContextMoveToPoint(context, CGFloat(y), CGFloat(x));
            } else {
                CGContextAddLineToPoint(context, CGFloat(y), CGFloat(x));
            }
        }

screenshot

Author

giordano scalzo, [email protected]

Credits

Based and relying on SAMCubicSpline bye Sam Soffes

License

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

Latest podspec

{
    "name": "SwiftCubicSpline",
    "version": "0.1.0",
    "summary": "Cubic Spline in Swift.",
    "description": "                       An simple cubic spline engine in Swiftn",
    "homepage": "https://github.com/gscalzo/SwiftCubicSpline",
    "license": "MIT",
    "authors": {
        "giordano scalzo": "[email protected]"
    },
    "source": {
        "git": "https://github.com/gscalzo/SwiftCubicSpline.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/giordanoscalzo",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "SwiftCubicSpline": [
            "Pod/Assets/*.png"
        ]
    },
    "frameworks": [
        "Foundation",
        "CoreGraphics"
    ],
    "dependencies": {
        "SAMCubicSpline": [
            "~> 0.1.1"
        ]
    }
}

Pin It on Pinterest

Share This