https://github.com/oovm/color-rs
Compile time color literal for rust
https://github.com/oovm/color-rs
color compile-time meta-programming rust
Last synced: about 1 year ago
JSON representation
Compile time color literal for rust
- Host: GitHub
- URL: https://github.com/oovm/color-rs
- Owner: oovm
- License: mpl-2.0
- Created: 2021-10-20T07:38:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T06:03:10.000Z (almost 3 years ago)
- Last Synced: 2024-12-10T09:40:31.538Z (over 1 year ago)
- Topics: color, compile-time, meta-programming, rust
- Language: Rust
- Homepage:
- Size: 283 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License.md
Awesome Lists containing this project
README
Rust Color
==========
### Compile time color parsing
```rust
use color::{rgba, RGBA};
#[test]
fn test_rgba() {
assert_eq!(rgba!("#334D6677"), RGBA::new(51, 76, 102));
assert_eq!(rgba!("rgba(51, 77, 102, .5)"), RGBA::new(51, 77, 102, 127));
assert_eq!(rgba!("rgba(20% 30% 40% 50%)"), RGBA::new(51, 77, 102, 127));
}
```

### Compile time error report
```rust
// Invalid hex pattern, can take 3,4,6,8 hex number only
rgba!("#34678");
```

### Strict check mode
```toml
features = ["strict"]
```
Normally valid mode is looser than specified, strict mode rejects all non-css level3 input
```rust
// will not panic by default
rgba!("rgba(10 10 10, 10)");
```