//
//  UIColor-Extension.swift
//  DouYuUI
//
//  Created by davidhuang on 2022/8/9.
//  Copyright © 2022 davidhuang. All rights reserved.
//

import UIKit
import SwifterSwift

extension UIColor {
    // MARK: - 当前 app 主颜色
    static let mainColor : UIColor = UIColor(hexString: "#46E0BB")!
    static let commonColor100 : UIColor = UIColor(hexString: "#333333",transparency: 1.0)!
    static let commonColor90 : UIColor = UIColor(hexString: "#333333",transparency: 0.9)!
    static let commonColor65 : UIColor = UIColor(hexString: "#333333",transparency: 0.65)!
    static let commonColor45 : UIColor = UIColor(hexString: "#333333",transparency: 0.45)!
    static let commonColor25 : UIColor = UIColor(hexString: "#333333",transparency: 0.25)!
    static let commonColor15 : UIColor = UIColor(hexString: "#333333",transparency: 0.15)!
    static let commonColor10 : UIColor = UIColor(hexString: "#333333",transparency: 0.10)!
    static let commonColor6 : UIColor = UIColor(hexString: "#333333",transparency: 0.06)!
    static let commonColor4 : UIColor = UIColor(hexString: "#333333",transparency: 0.04)!
    static let commonColor3 : UIColor = UIColor(hexString: "#333333",transparency: 0.03)!
    
    static let backgroundColor : UIColor = UIColor(hexString: "#F2F7F6",transparency: 1.0)!
    
    
    static let mainTextColor : UIColor = UIColor(hexString: "#00D19F")!
    static let selectBgColor : UIColor = UIColor(hexString: "#D9FCF7")!
    
    //黑色  50透明
    static let black50Persent : UIColor = UIColor.black.withAlphaComponent(0.5)
    
    
    public convenience init(r : CGFloat, g : CGFloat, b : CGFloat) {
        self.init(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1.0)
    }
    
    public func imageWithColor(width: Double = 1.0, height: Double = 1.0) -> UIImage {
        let rect = CGRect(x: 0.0, y: 0.0, width: width, height: height)
        UIGraphicsBeginImageContext(rect.size)
        let ctx = UIGraphicsGetCurrentContext()
        ctx!.setFillColor(self.cgColor)
        ctx!.fill(rect)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image!
    }
    
}

