Home

Awesome

ColorTempToRGB

Swift implementation of Tanner Helland's color-temperature-to-RGB algorithm.

You'll find the algorithm and new initializers for UIKit's UIColor and SwiftUI's Color in Extensions.swift. You can instantiate a color simply by passing in the desired color temperature in Kelvin.

Usage

For UIKit:

let warmWhiteColor = UIColor(temperature: 2700)

For SwiftUI:

let warmWhiteColor = Color(temperature: 2700)

If you're only using one of the extensions you'll probably want to move componentsForColorTemperature(temperature:) into the one you're using and mark it private.