Skip to content

Commit

Permalink
Merge pull request #14 from okaneco/rand
Browse files Browse the repository at this point in the history
Bump rand to 0.8, prepare for 0.2 release
  • Loading branch information
okaneco authored Mar 30, 2021
2 parents 4634be3 + e695db4 commit 220a506
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 51 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# `rscolorq` changelog

## Version 0.2.0 - 2021-03-31
Version bump for updating the `rand` dependency to `0.8`. No major API changes.

Executables are now available for download based on the latest pushed release
tag.

[#14][14] - Bump `rand` to 0.8
[#13][13] - Executable build workflow
[#11][11] - Add chunks_exact[_mut] methods for accessing Matrix2d rows,
`no_file` flag to binary

## Version 0.1.2 - 2021-02-20
Previous behavior relied on wrapping overflow in some places which could panic
in debug mode. This behavior has been changed to use checked arithmetic
Expand All @@ -16,5 +27,8 @@ the crate and install it from crates.io using `cargo`.
## Version 0.1.0 - 2020-10-20
- Initial Commit

[14]: https://github.com/okaneco/rscolorq/pull/14
[13]: https://github.com/okaneco/rscolorq/pull/13
[11]: https://github.com/okaneco/rscolorq/pull/11
[6]: https://github.com/okaneco/rscolorq/pull/6
[5]: https://github.com/okaneco/rscolorq/pull/5
57 changes: 23 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rscolorq"
version = "0.1.2"
version = "0.2.0"
authors = ["okaneco <[email protected]>"]
edition = "2018"
exclude = ["test", "gfx", ".github"]
Expand Down Expand Up @@ -37,12 +37,12 @@ features = ["std"]
optional = true

[dependencies.rand]
version = "0.7"
version = "0.8"
default-features = false
features = ["std"]

[dependencies.rand_pcg]
version = "0.2"
version = "0.3"
default-features = false

[dependencies.structopt]
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ mix as an average illusory color in the human eye.
[Pointillism]: https://en.wikipedia.org/wiki/Pointillism#Gallery

To use as a library, add the following to your `Cargo.toml`; add the
`palette_color` feature to enable Lab color quantization.
`palette_color` feature to enable Lab color quantization. Executable builds can
be found at https://github.com/okaneco/rscolorq/releases.


```toml
[dependencies.rscolorq]
version = "0.1"
version = "0.2"
default-features = false
```

Expand Down
10 changes: 5 additions & 5 deletions src/bin/rscolorq/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn print_colors_lab(colors: &[palette::Srgb<u8>]) -> Result<(), Box<dyn std:

/// Saves image buffer to file.
pub fn save_image(
output: &std::path::PathBuf,
output: &std::path::Path,
imgbuf: &[u8],
width: u32,
height: u32,
Expand Down Expand Up @@ -94,7 +94,7 @@ pub fn save_palette(
res: &[[u8; 3]],
height: u32,
width: Option<u32>,
title: &std::path::PathBuf,
title: &std::path::Path,
) -> Result<(), Box<dyn std::error::Error>> {
let len = res.len() as u32;
let w = match width {
Expand Down Expand Up @@ -123,15 +123,15 @@ pub fn save_palette(
*pixel = image::Rgb(color);
}

Ok(save_image(title, &imgbuf.to_vec(), w, height)?)
save_image(title, &imgbuf.to_vec(), w, height)
}

/// Save palette image file.
pub fn save_palette_lab(
res: &[palette::Srgb<u8>],
height: u32,
width: Option<u32>,
title: &std::path::PathBuf,
title: &std::path::Path,
) -> Result<(), Box<dyn std::error::Error>> {
let len = res.len() as u32;
let w = match width {
Expand Down Expand Up @@ -160,5 +160,5 @@ pub fn save_palette_lab(
*pixel = image::Rgb([color.red, color.green, color.blue]);
}

Ok(save_image(title, &imgbuf.to_vec(), w, height)?)
save_image(title, &imgbuf.to_vec(), w, height)
}
6 changes: 3 additions & 3 deletions src/color/lab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ impl SpatialQuant for Lab<D65, f64> {

fn random(rng: &mut impl rand::Rng) -> Self {
Self {
l: rng.gen_range(0.0, 100.0),
a: rng.gen_range(-128.0, 127.0),
b: rng.gen_range(-128.0, 127.0),
l: rng.gen_range(0.0..=100.0),
a: rng.gen_range(-128.0..=127.0),
b: rng.gen_range(-128.0..=127.0),
white_point: PhantomData,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/color/rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ impl SpatialQuant for Rgb {

fn random(rng: &mut impl rand::Rng) -> Self {
Self {
red: rng.gen_range(0.0, 1.0),
green: rng.gen_range(0.0, 1.0),
blue: rng.gen_range(0.0, 1.0),
red: rng.gen_range(0.0..=1.0),
green: rng.gen_range(0.0..=1.0),
blue: rng.gen_range(0.0..=1.0),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/quant/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn compute_max_coarse_level(mut width: usize, mut height: usize) -> usize {
/// Fill a matrix with random f64 from 0 to 1.
pub fn fill_random(arr: &mut Matrix3d<f64>, rng: &mut impl rand::Rng) {
arr.iter_mut().for_each(|a| {
*a = rng.gen_range(0.0, 1.0);
*a = rng.gen_range(0.0..=1.0);
});
}

Expand Down

0 comments on commit 220a506

Please sign in to comment.