From 1a6386f7ae796c1ce090e959639930ea30f37984 Mon Sep 17 00:00:00 2001 From: Drake Murphy Date: Tue, 2 Jan 2024 15:25:32 -0500 Subject: [PATCH] updated most libs --- Cargo.toml | 6 +++--- embroidery-lib/Cargo.toml | 12 ++++++------ formats/jef/Cargo.toml | 2 +- formats/svg/Cargo.toml | 4 ++-- formats/svg/src/write.rs | 24 ++++++++++++++++-------- formats/vp4/Cargo.toml | 2 +- src/error.rs | 9 +++++---- src/main.rs | 1 + 8 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cad3526..fc1f57e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,9 +16,9 @@ members = [ ] [dependencies] -failure = "^0.1.7" -log = "^0.4.8" -simplelog = "^0.7.5" +failure = "0.1.8" +log = "0.4.20" +simplelog = "0.12.1" embroidery-lib = { path = "./embroidery-lib" } embroidery-fmt-csv = { path = "./formats/csv" } embroidery-fmt-dst = { path = "./formats/dst" } diff --git a/embroidery-lib/Cargo.toml b/embroidery-lib/Cargo.toml index bc94a25..1559bb8 100644 --- a/embroidery-lib/Cargo.toml +++ b/embroidery-lib/Cargo.toml @@ -5,12 +5,12 @@ authors = ["Opal Symes "] edition = "2018" [dependencies] -euclid = "^0.18.2" -failure = "^0.1" -log = "^0.4" -palette = "^0.4.1" -unicode-segmentation = "^1.2" -byteorder = "1" +euclid = "0.22.9" +failure = "0.1.8" +log = "0.4.20" +palette = "0.7.3" +unicode-segmentation = "1.10.1" +byteorder = "1.5.0" [dev-dependencies] proptest = "0.9.4" diff --git a/formats/jef/Cargo.toml b/formats/jef/Cargo.toml index 32ac406..7820455 100644 --- a/formats/jef/Cargo.toml +++ b/formats/jef/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Opal Symes "] edition = "2018" [dependencies] -byteorder = "1" +byteorder = "1.5.0" embroidery-lib = { path = "../../embroidery-lib" } [dev-dependencies] diff --git a/formats/svg/Cargo.toml b/formats/svg/Cargo.toml index 0d17c0d..f00164c 100644 --- a/formats/svg/Cargo.toml +++ b/formats/svg/Cargo.toml @@ -6,5 +6,5 @@ edition = "2018" [dependencies] embroidery-lib = { path = "../../embroidery-lib" } -svgtypes = "^0.1.1" -palette = "^0.4.1" +svgtypes = "0.13.0" +palette = "0.7.3" diff --git a/formats/svg/src/write.rs b/formats/svg/src/write.rs index ba9b016..1e3dbc1 100644 --- a/formats/svg/src/write.rs +++ b/formats/svg/src/write.rs @@ -1,7 +1,8 @@ use std::io::Write; -use palette::{Lch, Srgb}; -use svgtypes::{PathBuilder, WriteBuffer, WriteOptions}; +use palette::{Lch, convert::FromColorUnclamped}; +use svgtypes::{PathParser, PathSegment}; +//use svgtypes::{WriteBuffer, WriteOptions, Path}; use embroidery_lib::errors::WriteResult as Result; use embroidery_lib::format::PatternWriter; @@ -24,8 +25,8 @@ impl PatternWriter for SvgPatternWriter { } } -fn generate_color(idx: usize, total: usize) -> Srgb { - Lch::new(50., 100., (idx as f32) * 360.0 / (total as f32)).into() +fn generate_color(idx: usize, total: usize) -> palette::Srgb { + palette::rgb::Rgb::from_color_unclamped(Lch::new(50., 100., (idx as f32) * 360.0 / (total as f32))) } fn write_pattern(pattern: &Pattern, writer: &mut dyn Write) -> Result<()> { @@ -81,6 +82,11 @@ fn write_pattern(pattern: &Pattern, writer: &mut dyn Write) -> Result<()> { } else { used_random_colors += 1; generate_color(used_random_colors - 1, total_colors).into() + /*Color { + red: value.red as u8, + green: value.green as u8, + blue: value.blue as u8, + }*/ }; writeln!(writer, " Result<()> { writeln!(writer, " >")?; for sg in cg.stitch_groups.iter() { - let mut path = PathBuilder::with_capacity(sg.stitches.len() + 2); + //let mut path = Path::with_capacity(sg.stitches.len() + 2); + let mut path = Vec::new(); if let Some(stitch) = sg.stitches.get(0) { - path = path.move_to(stitch.x, max_y - stitch.y); + //path.push_move_to(stitch.x, max_y - stitch.y); + path.push } writeln!(writer, " ", color)?; for (i, stitch) in sg.stitches.iter().enumerate() { if i != 0 { // reverse y axis so +ve y moves up - path = path.line_to(stitch.x, max_y - stitch.y); + path.push_line_to(stitch.x, max_y - stitch.y); } writeln!( writer, @@ -113,7 +121,7 @@ fn write_pattern(pattern: &Pattern, writer: &mut dyn Write) -> Result<()> { writeln!( writer, " ", - path.finalize().with_write_opt(&opt).to_string() + path.with_write_opt(&opt).to_string() )?; } writeln!(writer, " ")?; diff --git a/formats/vp4/Cargo.toml b/formats/vp4/Cargo.toml index e356e29..336f018 100644 --- a/formats/vp4/Cargo.toml +++ b/formats/vp4/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Opal Symes "] edition = "2018" [dependencies] -byteorder = "1" +byteorder = "1.5.0" embroidery-lib = { path = "../../embroidery-lib" } [dev-dependencies] diff --git a/src/error.rs b/src/error.rs index 7fc7b95..e65cb46 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,7 @@ use embroidery_lib::errors::{Error as EmbError, ErrorWithContext, ReadError, StdError as EmbStdError, WriteError}; -use simplelog::TermLogError; +use log::SetLoggerError; +//use simplelog::TermLogError; use std::fmt; use std::io; @@ -18,7 +19,7 @@ pub enum Error { Fmt(#[cause] fmt::Error), #[fail(display = "Logger Error: {}", _0)] - Log(#[cause] TermLogError), + Log(#[cause] SetLoggerError), #[fail(display = "Other Error: {}", _0)] Custom(String), @@ -75,8 +76,8 @@ impl From for Error { } } -impl From for Error { - fn from(err: TermLogError) -> Self { +impl From for Error { + fn from(err: SetLoggerError) -> Self { Error::Log(err) } } diff --git a/src/main.rs b/src/main.rs index 9d8f79d..4aa6688 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ fn main() -> Result<(), Error> { .set_location_level(LevelFilter::Error) .build(), TerminalMode::Mixed, + ColorChoice::Auto )?; let loader_unloaders = get_all();