Relative & compound path

This commit is contained in:
Chris Tsang
2020-11-09 00:37:40 +08:00
parent 99cb79895b
commit 5f18837b61
7 changed files with 59 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
use wasm_bindgen::prelude::*;
use visioncortex::{clusters::Clusters, Color, ColorName, PointI32, PathSimplifyMode};
use visioncortex::{clusters::Clusters, Color, ColorName, PathSimplifyMode};
use crate::{canvas::*};
use crate::svg::*;
@@ -69,7 +69,7 @@ impl BinaryImageConverter {
self.canvas.log(&format!("tick {}", self.counter));
let cluster = self.clusters.get_cluster(self.counter);
if cluster.size() >= self.params.filter_speckle {
let svg_path = cluster.to_svg_path(
let paths = cluster.to_compound_path(
self.mode,
self.params.corner_threshold,
self.params.length_threshold,
@@ -77,9 +77,8 @@ impl BinaryImageConverter {
self.params.splice_threshold
);
let color = Color::color(&ColorName::White);
self.svg.prepend_path_with_fill(
&svg_path,
&PointI32::default(),
self.svg.prepend_path(
&paths,
&color,
);
}

View File

@@ -1,5 +1,5 @@
use wasm_bindgen::prelude::*;
use visioncortex::{PathSimplifyMode, PointI32};
use visioncortex::PathSimplifyMode;
use visioncortex::color_clusters::{IncrementalBuilder, Clusters, Runner, RunnerConfig};
use crate::canvas::*;
@@ -94,16 +94,15 @@ impl ColorImageConverter {
if self.counter < view.clusters_output.len() {
self.canvas.log("Vectorize tick");
let cluster = view.get_cluster(view.clusters_output[self.counter]);
let svg_path = cluster.to_svg_path(
let paths = cluster.to_compound_path(
&view, false, self.mode,
self.params.corner_threshold,
self.params.length_threshold,
self.params.max_iterations,
self.params.splice_threshold
);
self.svg.prepend_path_with_fill(
&svg_path,
&PointI32::new(0, 0),
self.svg.prepend_path(
&paths,
&cluster.residue_color(),
);
self.counter += 1;