-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathaccent.rs
More file actions
25 lines (23 loc) · 763 Bytes
/
accent.rs
File metadata and controls
25 lines (23 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use objc2_app_kit::{NSColor, NSColorSpace};
use crate::Color;
/// Get the accent color.
pub fn accent_color() -> Option<Color> {
unsafe {
let accent = NSColor::controlAccentColor();
let color_space = NSColorSpace::genericRGBColorSpace();
let accent = accent.colorUsingColorSpace(&color_space);
accent.map(|accent| {
let mut r: f64 = 0.0;
let mut g: f64 = 0.0;
let mut b: f64 = 0.0;
let mut a: f64 = 0.0;
accent.getRed_green_blue_alpha(&mut r, &mut g, &mut b, &mut a);
Color::new(
(r * 255.0) as u8,
(g * 255.0) as u8,
(b * 255.0) as u8,
(a * 255.0) as u8,
)
})
}
}