Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
12 changes: 6 additions & 6 deletions embroidery-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ authors = ["Opal Symes <code@opal.codes>"]
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"
2 changes: 1 addition & 1 deletion formats/jef/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Opal Symes <code@opal.codes>"]
edition = "2018"

[dependencies]
byteorder = "1"
byteorder = "1.5.0"
embroidery-lib = { path = "../../embroidery-lib" }

[dev-dependencies]
4 changes: 2 additions & 2 deletions formats/svg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
24 changes: 16 additions & 8 deletions formats/svg/src/write.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<()> {
Expand Down Expand Up @@ -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, " <g")?;
writeln!(writer, " fill='none'")?;
Expand All @@ -91,15 +97,17 @@ fn write_pattern(pattern: &Pattern, writer: &mut dyn Write) -> 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, " <g stroke='none' fill='{}' class='emb_ignore'>", 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,
Expand All @@ -113,7 +121,7 @@ fn write_pattern(pattern: &Pattern, writer: &mut dyn Write) -> Result<()> {
writeln!(
writer,
" <path d='{}' />",
path.finalize().with_write_opt(&opt).to_string()
path.with_write_opt(&opt).to_string()
)?;
}
writeln!(writer, " </g>")?;
Expand Down
2 changes: 1 addition & 1 deletion formats/vp4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Opal Symes <code@opal.codes>"]
edition = "2018"

[dependencies]
byteorder = "1"
byteorder = "1.5.0"
embroidery-lib = { path = "../../embroidery-lib" }

[dev-dependencies]
9 changes: 5 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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),
Expand Down Expand Up @@ -75,8 +76,8 @@ impl From<EmbStdError> for Error {
}
}

impl From<TermLogError> for Error {
fn from(err: TermLogError) -> Self {
impl From<SetLoggerError> for Error {
fn from(err: SetLoggerError) -> Self {
Error::Log(err)
}
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn main() -> Result<(), Error> {
.set_location_level(LevelFilter::Error)
.build(),
TerminalMode::Mixed,
ColorChoice::Auto
)?;

let loader_unloaders = get_all();
Expand Down