From e391c225cde95f024d5c42cca9ccde08b2856415 Mon Sep 17 00:00:00 2001 From: freedit-dev <107944572+freedit-dev@users.noreply.github.com> Date: Fri, 23 Sep 2022 20:46:04 +0800 Subject: [PATCH 1/5] Update dependencies --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 402bf89..c661fef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ build-bin = ["md-5"] name = "identicon" [dependencies] -image = { version = "0.23.14", default-features = false, features = ["png"] } -md-5 = { version = "0.9.1", features = ["asm"], optional = true } +image = { version = "0.24", default-features = false, features = ["png"] } +md-5 = { version = "0.10", features = ["asm"], optional = true } [[bin]] name = "identicon" From 44cb2bc0d58fd0029fe70acc5dc2057ba3bcecad Mon Sep 17 00:00:00 2001 From: freedit-dev <107944572+freedit-dev@users.noreply.github.com> Date: Fri, 23 Sep 2022 20:48:06 +0800 Subject: [PATCH 2/5] update dependency --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7bb4aaf..7e67518 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use std::io; use std::io::Result; use std::process::exit; -use image::png::PngEncoder; +use image::{codecs::png::PngEncoder, ImageEncoder}; use image::ColorType; use md5::{Digest, Md5}; @@ -27,7 +27,7 @@ fn generate(input: &[u8]) -> Result<()> { let output = &mut io::stdout(); let encoder = PngEncoder::new(output); encoder - .encode(image.as_ref(), width, height, ColorType::Rgb8) + .write_image(image.as_ref(), width, height, ColorType::Rgb8) .map_err(|e| io::Error::new(io::ErrorKind::Other, e)) } From f6237bf8a721badd8c35cee3d2a90d8ac165e36c Mon Sep 17 00:00:00 2001 From: freedit-dev <107944572+freedit-dev@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:58:51 +0800 Subject: [PATCH 3/5] Create dependabot.yml --- .github/dependabot.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b5399af --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot#example-dependabotyml-file-for-github-actions= + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" From 73b8a209c1b4b0b8a1a35a10e9a8a92ca45078cb Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 13 Mar 2024 00:07:37 +0800 Subject: [PATCH 4/5] update --- Cargo.toml | 4 ++-- src/hsl.rs | 30 +++++++++++++----------------- src/lib.rs | 11 ++++------- src/main.rs | 4 ++-- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c661fef..ad3748f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ build-bin = ["md-5"] name = "identicon" [dependencies] -image = { version = "0.24", default-features = false, features = ["png"] } -md-5 = { version = "0.10", features = ["asm"], optional = true } +image = { version = "0.25.0", default-features = false, features = ["png"] } +md-5 = { version = "0.10", optional = true } [[bin]] name = "identicon" diff --git a/src/hsl.rs b/src/hsl.rs index 7a6f246..27cbd55 100644 --- a/src/hsl.rs +++ b/src/hsl.rs @@ -1,18 +1,14 @@ use image::Rgb; -pub struct HSL { +pub struct Hsl { hue: f32, sat: f32, lum: f32, } -impl HSL { - pub fn new(hue: f32, sat: f32, lum: f32) -> HSL { - HSL { - hue: hue, - sat: sat, - lum: lum, - } +impl Hsl { + pub fn new(hue: f32, sat: f32, lum: f32) -> Hsl { + Hsl { hue, sat, lum } } // http://www.w3.org/TR/css3-color/#hsl-color @@ -28,9 +24,9 @@ impl HSL { }; let a = lum * 2.0 - b; - let r = HSL::hue_to_rgb(a, b, hue + 1.0 / 3.0); - let g = HSL::hue_to_rgb(a, b, hue); - let b = HSL::hue_to_rgb(a, b, hue - 1.0 / 3.0); + let r = Hsl::hue_to_rgb(a, b, hue + 1.0 / 3.0); + let g = Hsl::hue_to_rgb(a, b, hue); + let b = Hsl::hue_to_rgb(a, b, hue - 1.0 / 3.0); Rgb([ (r * 255.0).round() as u8, @@ -66,41 +62,41 @@ impl HSL { #[cfg(test)] mod tests { - use super::HSL; + use super::Hsl; use image::Rgb; #[test] fn it_converts_black() { let black = Rgb([0, 0, 0]); - let rgb = HSL::new(0.0, 0.0, 0.0).rgb(); + let rgb = Hsl::new(0.0, 0.0, 0.0).rgb(); assert_eq!(black, rgb); } #[test] fn it_converts_white() { let white = Rgb([255, 255, 255]); - let rgb = HSL::new(0.0, 0.0, 100.0).rgb(); + let rgb = Hsl::new(0.0, 0.0, 100.0).rgb(); assert_eq!(white, rgb); } #[test] fn it_converts_red() { let red = Rgb([255, 0, 0]); - let rgb = HSL::new(0.0, 100.0, 50.0).rgb(); + let rgb = Hsl::new(0.0, 100.0, 50.0).rgb(); assert_eq!(red, rgb); } #[test] fn it_converts_green() { let green = Rgb([0, 255, 0]); - let rgb = HSL::new(120.0, 100.0, 50.0).rgb(); + let rgb = Hsl::new(120.0, 100.0, 50.0).rgb(); assert_eq!(green, rgb); } #[test] fn it_converts_blue() { let blue = Rgb([0, 0, 255]); - let rgb = HSL::new(240.0, 100.0, 50.0).rgb(); + let rgb = Hsl::new(240.0, 100.0, 50.0).rgb(); assert_eq!(blue, rgb); } } diff --git a/src/lib.rs b/src/lib.rs index 90f1ff5..9e443e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ use image::{ImageBuffer, Rgb, RgbImage}; -use hsl::HSL; +use hsl::Hsl; use nibbler::Nibbler; mod hsl; @@ -13,10 +13,7 @@ pub struct Identicon<'a> { impl<'a> Identicon<'a> { pub fn new(source: &[u8]) -> Identicon { - Identicon { - source: source, - size: 420, - } + Identicon { source, size: 420 } } // https://processing.org/reference/map_.html @@ -25,7 +22,7 @@ impl<'a> Identicon<'a> { } fn foreground(&self) -> Rgb { - // Use last 28 bits to determine HSL values. + // Use last 28 bits to determine Hsl values. let h1 = (self.source[12] as u16 & 0x0f) << 8; let h2 = self.source[13] as u16; @@ -37,7 +34,7 @@ impl<'a> Identicon<'a> { let sat = Identicon::map(s, 0, 255, 0, 20); let lum = Identicon::map(l, 0, 255, 0, 20); - HSL::new(hue, 65.0 - sat, 75.0 - lum).rgb() + Hsl::new(hue, 65.0 - sat, 75.0 - lum).rgb() } fn rect(image: &mut RgbImage, x0: u32, y0: u32, x1: u32, y1: u32, color: Rgb) { diff --git a/src/main.rs b/src/main.rs index 7e67518..ea56153 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,8 +4,8 @@ use std::io; use std::io::Result; use std::process::exit; -use image::{codecs::png::PngEncoder, ImageEncoder}; use image::ColorType; +use image::{codecs::png::PngEncoder, ImageEncoder}; use md5::{Digest, Md5}; use identicon::Identicon; @@ -27,7 +27,7 @@ fn generate(input: &[u8]) -> Result<()> { let output = &mut io::stdout(); let encoder = PngEncoder::new(output); encoder - .write_image(image.as_ref(), width, height, ColorType::Rgb8) + .write_image(image.as_ref(), width, height, ColorType::Rgb8.into()) .map_err(|e| io::Error::new(io::ErrorKind::Other, e)) } From 51e94d7fd3f472b27e8735b3c3bed90c685751de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:59:10 +0000 Subject: [PATCH 5/5] Bump actions/checkout from 2 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/rust.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 72fbea6..8979d53 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -5,7 +5,7 @@ jobs: name: cargo check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -18,7 +18,7 @@ jobs: name: cargo test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -31,7 +31,7 @@ jobs: name: cargo fmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal