Created
April 9, 2019 18:17
-
-
Save ericjkunz/bb3d61cdaaa8e528bde8969f4d0abdc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| extension UIColor { | |
| func withBrightnessComponent(_ brightness: CGFloat) -> UIColor { | |
| var h: CGFloat = 0 | |
| var s: CGFloat = 0 | |
| var a: CGFloat = 0 | |
| getHue(&h, saturation: &s, brightness: nil, alpha: &a) | |
| return UIColor(hue: h, saturation: s, brightness: brightness, alpha: a) | |
| } | |
| func multiplyingBrightness(by factor: CGFloat) -> UIColor { | |
| var h: CGFloat = 0 | |
| var s: CGFloat = 0 | |
| var b: CGFloat = 0 | |
| var a: CGFloat = 0 | |
| getHue(&h, saturation: &s, brightness: &b, alpha: &a) | |
| return UIColor(hue: h, saturation: s, brightness: b * factor, alpha: a) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment