1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 18:39:52 +03:00
vimr/SwiftNeoVim/ColorUtils.swift
Tae Won Ha d548cb01a0
Update neovim
- adapt to (neovim/neovim@031756c5e6)
    * int -> Integer
    * bool -> Boolean
    * some char * -> String
2017-05-11 08:08:58 +02:00

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
}
}