Thinner lines.

This commit is contained in:
Bill Thiede 2020-06-27 16:40:12 -07:00
parent 8ca9e67f85
commit 9fdb42850c
2 changed files with 2 additions and 48 deletions

View File

@ -34,7 +34,7 @@ pub fn svgify(input: &DynamicImage) -> Result<impl Node, PerlerError> {
let y_pos = box_offset.1 + 5 + y * 5;
let c = Circle::new()
.set("stroke", "black")
.set("stroke-width", 0.1)
.set("stroke-width", 0.05)
.set("cx", x_pos)
.set("cy", y_pos);
@ -59,7 +59,7 @@ pub fn svgify(input: &DynamicImage) -> Result<impl Node, PerlerError> {
.set("width", 150)
.set("height", 150)
.set("stroke", "black")
.set("stroke-width", 0.1)
.set("stroke-width", 0.05)
.set("x", box_offset.0)
.set("y", box_offset.1)
.set("rx", 1)

View File

@ -1,46 +0,0 @@
use std::fs::File;
use std::io;
use std::io::Write;
use std::path::PathBuf;
use anyhow::Result;
//use image::imageops::colorops::{index_colors, BiLevel};
//use image::math::nq::NeuQuant;
//use image::DynamicImage;
use structopt::StructOpt;
use perler::{simplify, svgify};
/// Convert image to SVG in the style of perler instructions.
#[derive(StructOpt, Debug)]
#[structopt(name = "perler")]
struct Opt {
/// Input image file.
input: PathBuf,
/// Optional output .svg file. Default prints to stdout.
output: Option<PathBuf>,
}
fn main() -> Result<()> {
let opt = Opt::from_args();
let img = image::open(opt.input)?;
/*
let mut img2 = img.to_rgba();
let raw = img.into_rgba().into_raw();
let cmap = NeuQuant::new(1, 256, &raw);
index_colors(&mut img2, &cmap);
let img = DynamicImage::ImageRgba8(img2.into());
*/
let img = simplify(&img);
let out_svg = svgify(&img)?;
let w: Box<dyn Write> = if let Some(path) = opt.output {
Box::new(File::create(path)?)
} else {
Box::new(io::stdout())
};
svg::write(w, &out_svg)?;
Ok(())
}