mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fix colour hex in gui
This commit is contained in:
@@ -12,6 +12,14 @@ use crate::{
|
||||
|
||||
fn decode_hex(s: &str) -> RgbaColor<u8> {
|
||||
let s = s.trim_start_matches('#');
|
||||
if s.len() < 6 {
|
||||
return RgbaColor {
|
||||
alpha: 255,
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
};
|
||||
}
|
||||
let c: Vec<u8> = (0..s.len())
|
||||
.step_by(2)
|
||||
.map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap_or(164))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2024-04-16 23:52+0000\n"
|
||||
"POT-Creation-Date: 2024-04-16 23:55+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
||||
@@ -66,11 +66,11 @@ export component ColourSlider inherits VerticalLayout {
|
||||
blend_lightness(base_colour, 0.1),
|
||||
blend_lightness(base_colour, 0.0)
|
||||
];
|
||||
function blend_lightness(c1: color, f: float) -> color {
|
||||
function blend_lightness(c1: color,f: float) -> color {
|
||||
rgb(c1.red * f, c1.green * f, c1.blue * f)
|
||||
}
|
||||
//
|
||||
function set_base_colour() {
|
||||
function set_base_colour(){
|
||||
root.base_colour = base_colours[c1.value].mix(base_colours[c1.value + 1], c1.value - Math.floor(c1.value));
|
||||
root.final_colour = blend_lightness(base_colour, ((base_shade.length - c2.value) / base_shade.length));
|
||||
root.colourbox = root.final_colour;
|
||||
@@ -141,9 +141,13 @@ export component ColourSlider inherits VerticalLayout {
|
||||
enabled <=> root.enabled;
|
||||
// width: 50%;
|
||||
text <=> root.hex;
|
||||
edited => {
|
||||
accepted => {
|
||||
base_colour = hex_to_colour(self.text);
|
||||
root.colourbox = base_colour;
|
||||
root.final_colour = base_colour;
|
||||
root.colourbox = root.final_colour;
|
||||
root.external_colour_change();
|
||||
root.released();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user