<commit_before>//
//  UIColor+Chroma.swift
//  Chroma
//
//  Created by <NAME> on 2/4/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

extension UIColor {
    
    public func isBlackOrWhite() -> Bool {
        var r: CGFloat = 0
        var g: CGFloat = 0
        var b: CGFloat = 0
        var a: CGFloat = 0
        self.getRed(&r, green: &g, blue: &b, alpha: &a)
        
        if (r > 0.91 && g > 0.91 && b > 0.91) || (r < 0.09 && g < 0.09 && b < 0.09) {
            return true
        } else {
            return false
        }
    }
    
    public func isDark() -> Bool {
        return self.luminance() < 0.5 ? true : false
    }
    
    public func luminance() -> Float {
        var r: CGFloat = 0
        var g: CGFloat = 0
        var b: CGFloat = 0
        var a: CGFloat = 0<commit_msg>Added convenience initializer for creating UIColor with saturation<commit_after>//
//  UIColor+Chroma.swift
//  Chroma
//
//  Created by <NAME> on 2/4/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

extension UIColor {
    
    public convenience init(fromColor color: UIColor, saturation: Float) {
        var h: CGFloat = 0
        var b: CGFloat = 0
        var a: CGFloat = 0
        color.getHue(&h, saturation: nil, brightness: &b, alpha: &a)
        
        self.init(hue: h, saturation: CGFloat(saturation), brightness: b, alpha: a)
    }
    
    public func isBlackOrWhite() -> Bool {
        var r: CGFloat = 0
        var g: CGFloat = 0
        var b: CGFloat = 0
        var a: CGFloat = 0
        self.getRed(&r, green: &g, blue: &b, alpha: &a)
        
        if (r > 0.91 && g > 0.91 && b > 0.91) || (r < 0.09 && g < 0.09 && b < 0.09) {
            return true
        } else {
            return false
        }
    }
    
    public func isDark() -> Bool {
        return self.luminance() < 0.5 ? true : false
    }
    
    public func luminance() -> Float {
        var r: CGFloat = 0
        var g: CGFloat = 0
        var b: CGFloat = 0
        var a: CGFloat = 0
{'fraction_non_alphanumeric': 0.128921568627451, 'fraction_numerical': 0.03676470588235294, 'mean_word_length': 1.5608531994981178, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '91773', 'n_tokens_mistral': 778, 'n_tokens_neox': 704, 'n_words': 226}