|
0 |
Index: colorsys/src/converters/rgb_to_hsl.rs
|
|
1 |
===================================================================
|
|
2 |
--- colorsys.orig/src/converters/rgb_to_hsl.rs
|
|
3 |
+++ colorsys/src/converters/rgb_to_hsl.rs
|
|
4 |
@@ -46,6 +46,7 @@ fn rgb_to_hsl_tst() {
|
|
5 |
fn a(x: ColorTuple, y: ColorTuple) -> bool {
|
|
6 |
let from_rgb_u = rgb_to_hsl(&Rgb::from(x));
|
|
7 |
let hsl_u = new_hsl_units(y.0, y.1, y.2);
|
|
8 |
+ #[cfg(feature = "std")]
|
|
9 |
println!("rgb {:?}\n\n", Into::<Hsl>::into(Rgb::from(x)));
|
|
10 |
from_rgb_u.approx_eq_clarify(&hsl_u, 0.5)
|
|
11 |
// Rgb::from(x).approx_eq_clarify(&Hsl::from(y), 0.5)
|
|
12 |
Index: colorsys/src/units/iter.rs
|
|
13 |
===================================================================
|
|
14 |
--- colorsys.orig/src/units/iter.rs
|
|
15 |
+++ colorsys/src/units/iter.rs
|
|
16 |
@@ -39,6 +39,8 @@ impl core::iter::Iterator for ColorUnits
|
|
17 |
#[cfg(test)]
|
|
18 |
mod test {
|
|
19 |
use crate::Rgb;
|
|
20 |
+ #[cfg(not(feature = "std"))]
|
|
21 |
+ use alloc::vec::Vec;
|
|
22 |
|
|
23 |
#[test]
|
|
24 |
fn color_iter_collect_test() {
|
|
25 |
Index: colorsys/src/common/mod.rs
|
|
26 |
===================================================================
|
|
27 |
--- colorsys.orig/src/common/mod.rs
|
|
28 |
+++ colorsys/src/common/mod.rs
|
|
29 |
@@ -34,5 +34,7 @@ pub(crate) fn f64_round(n: f64) -> f64 {
|
|
30 |
}
|
|
31 |
#[cfg(not(feature = "std"))]
|
|
32 |
pub(crate) fn f64_round(n: f64) -> f64 {
|
|
33 |
- f64::from(n as i32)
|
|
34 |
+ let adjustment = if n < 0.0 {-0.5} else {0.5};
|
|
35 |
+
|
|
36 |
+ f64::from((n+adjustment) as i32)
|
|
37 |
}
|
|
38 |
Index: colorsys/src/hsl/tests.rs
|
|
39 |
===================================================================
|
|
40 |
--- colorsys.orig/src/hsl/tests.rs
|
|
41 |
+++ colorsys/src/hsl/tests.rs
|
|
42 |
@@ -13,11 +13,11 @@ fn round_tuple(t: &ColorTuple) -> (u32,
|
|
43 |
fn hsl_to_rgb() {
|
|
44 |
let hsl = Hsl::from((126.0, 43.0, 52.0));
|
|
45 |
let rgb = Rgb::from(&hsl);
|
|
46 |
- #[cfg(feature = "std")]
|
|
47 |
+ //#[cfg(feature = "std")]
|
|
48 |
assert_eq!(round_tuple(&rgb.as_ref().into()), (80, 185, 90));
|
|
49 |
|
|
50 |
- #[cfg(not(feature = "std"))]
|
|
51 |
- assert_eq!(round_tuple(&rgb.as_ref().into()), (79, 185, 90));
|
|
52 |
+ /*#[cfg(not(feature = "std"))]
|
|
53 |
+ assert_eq!(round_tuple(&rgb.as_ref().into()), (79, 185, 90));*/
|
|
54 |
|
|
55 |
let hsl_new = Hsl::from(&rgb);
|
|
56 |
assert!(hsl_new.approx_eq(&hsl));
|
|
57 |
Index: colorsys/src/rgb/tests.rs
|
|
58 |
===================================================================
|
|
59 |
--- colorsys.orig/src/rgb/tests.rs
|
|
60 |
+++ colorsys/src/rgb/tests.rs
|
|
61 |
@@ -19,20 +19,20 @@ fn lighten() {
|
|
62 |
|
|
63 |
rgb.lighten(15.0);
|
|
64 |
|
|
65 |
- #[cfg(feature = "std")]
|
|
66 |
+ //#[cfg(feature = "std")]
|
|
67 |
assert_eq!(round_tuple(&rgb.into()), (135, 208, 142));
|
|
68 |
- #[cfg(not(feature = "std"))]
|
|
69 |
- assert_eq!(round_tuple(&rgb.into()), (134, 207, 141));
|
|
70 |
+ //#[cfg(not(feature = "std"))]
|
|
71 |
+ //assert_eq!(round_tuple(&rgb.into()), (134, 207, 141));
|
|
72 |
|
|
73 |
rgb2.lighten(45.0);
|
|
74 |
- #[cfg(feature = "std")]
|
|
75 |
+ //#[cfg(feature = "std")]
|
|
76 |
assert_eq!(round_tuple(&rgb2.into()), (245, 251, 245));
|
|
77 |
- #[cfg(not(feature = "std"))]
|
|
78 |
- assert_eq!(round_tuple(&rgb2.into()), (244, 250, 245));
|
|
79 |
+ //#[cfg(not(feature = "std"))]
|
|
80 |
+ //assert_eq!(round_tuple(&rgb2.into()), (244, 250, 245));
|
|
81 |
|
|
82 |
|
|
83 |
rgb3.lighten(-23.0);
|
|
84 |
- #[cfg(feature = "std")]
|
|
85 |
+ //#[cfg(feature = "std")]
|
|
86 |
assert_eq!(round_tuple(&rgb3.into()), (42, 107, 48));
|
|
87 |
|
|
88 |
rgb4.lighten(-203.0);
|
|
89 |
Index: colorsys/src/rgb/transform.rs
|
|
90 |
===================================================================
|
|
91 |
--- colorsys.orig/src/rgb/transform.rs
|
|
92 |
+++ colorsys/src/rgb/transform.rs
|
|
93 |
@@ -80,15 +80,15 @@ mod test {
|
|
94 |
}
|
|
95 |
|
|
96 |
let asserts = [
|
|
97 |
- #[cfg(feature = "std")]
|
|
98 |
+// #[cfg(feature = "std")]
|
|
99 |
((30.0, 108.0, 77.0), 20.0, (52, 188, 134)),
|
|
100 |
((30.0, 108.0, 77.0), 90.0, (255, 255, 255)),
|
|
101 |
- #[cfg(feature = "std")]
|
|
102 |
+// #[cfg(feature = "std")]
|
|
103 |
((30.0, 108.0, 77.0), -20.0, (8, 28, 20)),
|
|
104 |
- #[cfg(feature = "std")]
|
|
105 |
+// #[cfg(feature = "std")]
|
|
106 |
((0.0, 0.0, 0.0), 50.0, (128, 128, 128)),
|
|
107 |
- #[cfg(not(feature = "std"))]
|
|
108 |
- ((0.0, 0.0, 0.0), 50.0, (127, 127, 127)),
|
|
109 |
+// #[cfg(not(feature = "std"))]
|
|
110 |
+// ((0.0, 0.0, 0.0), 50.0, (127, 127, 127)),
|
|
111 |
((0.0, 0.0, 0.0), -50.0, (0, 0, 0)),
|
|
112 |
((0.0, 0.0, 0.0), 300.5, (255, 255, 255)),
|
|
113 |
];
|