A Metal-backed, blazingly fast alternative to CAGradientLayer.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Rainbows.xcodeproj
Rainbows
RainbowsDemo
.gitignore
Icon.sketch
LICENSE
README.md
jumbotron.png
screencast.gif

README.md

jumbotron

Rainbows

Rainbows is a Metal-backed alternative to CAGradientLayer that is incredibly fast. It provides drawing of axial (aka "linear"), radial (aka "circular"), sweep (aka "angular" aka "conical") and even trippy spiral gradients at no less than 60fps.

screencast

Usage

Let's say you want to add a trippy noir spiral gradient to your view:

import Rainbows

let gradientLayer = GradientLayer()
gradientLayer.gradient = Gradient(colors: [
    UIColor.black.cgColor, UIColor.white.cgColor
])
gradientLayer.configuration = .spiral(
    center: CGPoint(x: 0.5, y: 0.5),
    angle: 0.0 * CGFloat.pi * 2.0,
    scale: 1.0
)
gradientLayer.frame = view.layer.bounds
view.layer.addSublayer(gradientLayer)

Or just skip the detour via self.layer and use a convenient GradientView:

import Rainbows

let gradientView = GradientView()
gradientView.gradient = Gradient(colors: [
    UIColor.black.cgColor, UIColor.white.cgColor
])
gradientView.configuration = .spiral(
    center: CGPoint(x: 0.5, y: 0.5),
    angle: 0.0 * CGFloat.pi * 2.0,
    scale: 1.0
)

Installation

The recommended way to add Rainbows to your project is via Carthage:

github 'regexident/Rainbows'

License

Rainbows is available under the MPL-2.0 license. See the LICENSE file for more info.