Skip to content

Latest commit

 

History

History

ColorInterpolator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

ColorInterpolator

A simple way of interpolating multiple colors at a time.

Usage

Creating a range of interpolated colors between red and green is as easy as:

let interpolator: ColorInterpolator = LinearColorInterpolator()
let colors = stride(from: 0.0, to: 1, by: 0.1).compactMap { try? interpolator.interpolate(.red, with: .green, percentage: $0) }

Interpolating multiple colors:

let colors: [UIColor] = [...]
let percentage: CGFloat = ...
try? colorInterpolator.interpolate(colorPoints: colors, percentage: percentage)

Source code

You can find source code here.