1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 11:35:35 +03:00
vimr/SwiftNeoVim/ColorUtils.swift
2017-01-31 20:57:44 +01:00

27 lines
571 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
fileprivate var colorCache = [UInt32: NSColor]()
class ColorUtils {
static func colorIgnoringAlpha(_ rgb: UInt32) -> 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
}
}