feat: Add with_opacity() helper for color opacity#49
feat: Add with_opacity() helper for color opacity#49sojotype wants to merge 4 commits intolukeyou05:mainfrom
Conversation
…rt for hexa(color,X%) format where:\n - color can be 'accent' for Windows accent color or hex code\n - X% specifies opacity percentage\n- Implements parse_hexa() function to handle new format\n- Updates get_color_from_hex() to detect and parse hexa format\n- Adds comprehensive tests for all hexa format variations\n- Supports hex codes with and without # prefix\n- Alpha value overrides any existing alpha in hex codes\n- Updates documentation in README.md and config.yaml with examples\n- Provides clear examples of hexa() usage in config files
|
Since |
That makes sense) Thanks for the idea) |
| } | ||
|
|
||
| fn get_color_from_hex(hex: &str) -> D2D1_COLOR_F { | ||
| // Check if the string is in with_opacity(color,X%) format |
There was a problem hiding this comment.
We should probably move the parse_with_opacity() call outside get_color_from_hex() since the names are different now. I think the best way to do that would be to break out lines 426 - 432 into a separate function called something like get_color_with_opacity(), and then use that function in lines 85 and 108 (right next to the other get_accent_color() and get_color_from_hex() calls). That does lead to more repeated code but I could refactor that out in the future.
There was a problem hiding this comment.
The config section in the README is meant to track whatever is in the latest release, so we should revert everything here since it won't be released until later.
Summary
This PR adds support for a new
hexa()color format that allows specifying colors with alpha transparency using a more readable percentage-based syntax.Changes
hexa(color,X%)format supportcolorcan beaccent(Windows accent color) or hex codeX%specifies opacity percentage (0-100%)parse_hexa()function insrc/colors.rsExamples
Benefits