Skip to content

Commit

Permalink
check changelog for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiving committed May 25, 2024
1 parent e90c351 commit 197f6da
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 32 deletions.
65 changes: 65 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'material_colors'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=material-colors"
],
"filter": {
"name": "material_colors",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'theme'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=theme",
"--package=material-colors"
],
"filter": {
"name": "theme",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'image'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=image",
"--package=material-colors"
],
"filter": {
"name": "image",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
40 changes: 20 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

- **added**: Add tests for:
- 🟢 `mod:blend`
- 🟢 `mod:contrast`
- 🟢 `mod:dislike`
- 🟢 `mod:dynamic_color/dynamic_scheme`
- `mod:dynamic_color`
- 🟢 `mod:hct/cam16`
- 🟢 `mod:hct`
- 🟢 `mod:hct/viewing_conditions`
- `mod:palette/core`
- `mod:palette/tonal`
- 🟢 `mod:quantize/quantizer_celebi`
- 🟢 `mod:quantize/quantizer_wsmeans`
- 🟢 `mod:quantize/quantizer_wu`
- 🟢 `mod:scheme/content`
- 🟢 `mod:utils/math`

(Tests marked with a empty red circle are currently failing)

- **fixed**: Fix stack overflow in QuantizerWu creation
- `mod:blend`
- `mod:contrast`
- `mod:dislike`
- `mod:dynamic_color/dynamic_scheme`
- `mod:dynamic_color`
- `mod:hct/cam16`
- `mod:hct`
- `mod:hct/viewing_conditions`
- `mod:palette/core`
- `mod:palette/tonal`
- `mod:quantize/quantizer_celebi`
- `mod:quantize/quantizer_wsmeans`
- `mod:quantize/quantizer_wu`
- `mod:scheme/content`
- `mod:utils/math`

- **fixed**: Fix stack overflow in `struct:QuantizerWu` creation
- **fixed**: Fix `func:on_secondary_container` in `struct:MaterialDynamicColors`
- **fixed**: Fix `func:critical_plane_below` and `func:critical_plane_above` in `struct:HctSolver`

## 0.3.2 (May 8th, 2024)

Expand Down Expand Up @@ -70,7 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **added:** Add support for the serde with the `serde` feature
- **changed:** Update dependencies
- **changed:** Update tests
- **fixed:** Fix `secondary_container` color in dynamic colors
- **fixed:** Fix `func:secondary_container` in `struct:MaterialDynamicColors`

## 0.1.6 (February 2nd, 2024)

Expand Down
18 changes: 15 additions & 3 deletions src/dynamic_color/material_dynamic_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,28 @@ impl MaterialDynamicColors {

define_key! {
background secondary_container => secondary_palette;
[tone, scheme] => if _is_monochrome(scheme) { if scheme.is_dark { 30.0 } else { 85.0 } } else if _is_fidelity(scheme) { if scheme.is_dark { 30.0 } else { 90.0 } } else { Self::_find_desired_chroma_by_tone(scheme.secondary_palette.hue(), scheme.secondary_palette.chroma(), if scheme.is_dark { 30.0 } else { 90.0 }, !scheme.is_dark) };
[tone, scheme] => {
let initial_tone = if scheme.is_dark { 30.0 } else { 90.0 };

if _is_monochrome(scheme) { if scheme.is_dark { 30.0 } else { 90.0 } }
else if !_is_fidelity(scheme) { initial_tone }
else { Self::_find_desired_chroma_by_tone(scheme.secondary_palette.hue(), scheme.secondary_palette.chroma(), initial_tone, !scheme.is_dark) }
};
[background, scheme] => Self::highest_surface(scheme);
[contrast_curve] => ContrastCurve { low: 1.0, normal: 1.0, medium: 3.0, high: 4.5 };
[tone_delta_pair, _scheme] => ToneDeltaPair::new(Self::secondary_container(), Self::secondary(), 10.0, TonePolarity::Nearer, false);
}

define_key! {
on_secondary_container => secondary_palette;
[tone, scheme] => if _is_fidelity(scheme) { DynamicColor::foreground_tone(Self::secondary_container().get_tone(scheme), 4.5) } else if scheme.is_dark { 90.0 } else { 10.0 };
[background, scheme] => Self::highest_surface(scheme);
[tone, scheme] => if _is_fidelity(scheme) {
DynamicColor::foreground_tone((Self::secondary_container().tone)(scheme), 4.5)
} else if scheme.is_dark {
90.0
} else {
10.0
};
[background, _scheme] => Self::secondary_container();
[contrast_curve] => ContrastCurve { low: 4.5, normal: 7.0, medium: 11.0, high: 21.0 };
}

Expand Down
14 changes: 8 additions & 6 deletions src/hct/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,12 @@ impl HctSolver {
]
}

fn critical_plane_below(x: f64) -> u8 {
(x - 0.5).floor() as u8
fn critical_plane_below(x: f64) -> i16 {
(x - 0.5).floor() as i16
}

fn critical_plane_above(x: f64) -> u8 {
(x - 0.5).ceil() as u8
fn critical_plane_above(x: f64) -> i16 {
(x - 0.5).ceil() as i16
}

/// Finds a color with the given Y and hue on the boundary of the
Expand Down Expand Up @@ -528,10 +528,11 @@ impl HctSolver {
};

for _ in 0..8 {
if (i16::from(r_plane) - i16::from(l_plane)).abs() <= 1 {
if (r_plane - l_plane).abs() <= 1 {
break;
}
let m_plane = ((f32::from(l_plane) + f32::from(r_plane)) / 2.0).floor() as u8;

let m_plane = ((f64::from(l_plane) + f64::from(r_plane)) / 2.0).floor() as i16;
let mid_plane_coordinate = CRITICAL_PLANES[m_plane as usize];
let mid = Self::set_coordinate(left, mid_plane_coordinate, right, axis);
let mid_hue = Self::hue_of(mid);
Expand Down Expand Up @@ -660,6 +661,7 @@ impl HctSolver {
}

let [red, green, blue] = Self::bisect_to_limit(y, hue_radians);

let linrgb = LinearRgb { red, green, blue };

linrgb.into()
Expand Down
11 changes: 8 additions & 3 deletions src/quantize/quantizer_wu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl QuantizerWu {
}
}

pub fn volume(cube: &Cube, moment: &Box<[i64; TOTAL_SIZE]>) -> i64 {
pub fn volume(cube: &Cube, moment: &[i64; TOTAL_SIZE]) -> i64 {
moment[Self::get_index::<u8>(cube.r(1), cube.g(1), cube.b(1))]
- moment[Self::get_index::<u8>(cube.r(1), cube.g(1), cube.b(0))]
- moment[Self::get_index::<u8>(cube.r(1), cube.g(0), cube.b(1))]
Expand All @@ -425,7 +425,7 @@ impl QuantizerWu {
- moment[Self::get_index::<u8>(cube.r(0), cube.g(0), cube.b(0))]
}

pub fn bottom(cube: &Cube, direction: &Direction, moment: &Box<[i64; TOTAL_SIZE]>) -> i64 {
pub fn bottom(cube: &Cube, direction: &Direction, moment: &[i64; TOTAL_SIZE]) -> i64 {
match direction {
Direction::Red => {
-moment[Self::get_index::<u8>(cube.r(0), cube.g(1), cube.b(1))]
Expand All @@ -448,7 +448,12 @@ impl QuantizerWu {
}
}

pub fn top(cube: &Cube, direction: &Direction, position: i32, moment: &Box<[i64; TOTAL_SIZE]>) -> i64 {
pub fn top(
cube: &Cube,
direction: &Direction,
position: i32,
moment: &[i64; TOTAL_SIZE],
) -> i64 {
match direction {
Direction::Red => {
moment[Self::get_index(position as usize, cube.g(1), cube.b(1))]
Expand Down

0 comments on commit 197f6da

Please sign in to comment.