1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00
vimr/SwiftNeoVim/ColorUtils.swift

27 lines
565 B
Swift
Raw Normal View History

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
fileprivate var colorCache = [Int: NSColor]()
class ColorUtils {
static func colorIgnoringAlpha(_ rgb: Int) -> NSColor {
if let color = colorCache[rgb] {
return color
}
let red = (CGFloat((rgb >> 16) & 0xFF)) / 255.0;
let green = (CGFloat((rgb >> 8) & 0xFF)) / 255.0;
let blue = (CGFloat((rgb ) & 0xFF)) / 255.0;
let color = NSColor(srgbRed: red, green: green, blue: blue, alpha: 1.0)
colorCache[rgb] = color
return color
}
}