mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added monochrome (grayscaled) color to the Tachometer widget
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user