mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-27 07:42:48 +03:00
d548cb01a0
- adapt to (neovim/neovim@031756c5e6) * int -> Integer * bool -> Boolean * some char * -> String
27 lines
565 B
Swift
27 lines
565 B
Swift
/**
|
|
* 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
|
|
}
|
|
}
|