2个不稳定版本
0.1.0 | 2023年3月28日 |
---|---|
0.0.0 | 2023年3月27日 |
#14 in #rgba
27 每月下载量
6KB
185 行
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));
}
编译时错误报告
// Invalid hex pattern, can take 3,4,6,8 hex number only
rgba!("#34678");
严格检查模式
features = ["strict"]
通常有效模式比指定模式更宽松,严格模式拒绝所有非CSS级别3输入
// will not panic by default
rgba!("rgba(10 10 10, 10)");
依赖项
~210KB