feat: added monochrome (grayscaled) color to the Tachometer widget

This commit is contained in:
Serhiy Mytrovtsiy
2021-10-14 18:29:50 +02:00
parent 4168862287
commit 585014cba1
4 changed files with 41 additions and 3 deletions

View File

@@ -413,6 +413,15 @@ public extension NSColor {
let blue = CGFloat(b) / 255.0
self.init(red: red, green: green, blue: blue, alpha: alpha)
}
func grayscaled() -> NSColor {
guard let space = CGColorSpace(name: CGColorSpace.extendedGray),
let cg = self.cgColor.converted(to: space, intent: .perceptual, options: nil),
let color = NSColor.init(cgColor: cg) else {
return self
}
return color
}
}
public extension CATransaction {