Skip to content

Commit ddb47e1

Browse files
committed
Revert "Experiment with idealizing small circles"
This reverts commit c3012c6.
1 parent 1777971 commit ddb47e1

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

cmdapp/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ keywords = ["svg", "computer-graphics"]
1313
[dependencies]
1414
clap = "2.33.3"
1515
image = "0.23.10"
16-
visioncortex = { version = "0.8.4" }
16+
visioncortex = { version = "0.8.1" }
1717
fastrand = "1.8"
1818
pyo3 = { version = "0.19.0", optional = true }
1919

cmdapp/src/converter.rs

+10-27
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ use super::config::{ColorMode, Config, ConverterConfig, Hierarchical};
55
use super::svg::SvgFile;
66
use fastrand::Rng;
77
use visioncortex::color_clusters::{KeyingAction, Runner, RunnerConfig, HIERARCHICAL_MAX};
8-
use visioncortex::{
9-
approximate_circle_with_spline, Color, ColorImage, ColorName, CompoundPath, PathSimplifyMode,
10-
};
8+
use visioncortex::{Color, ColorImage, ColorName};
119

1210
const NUM_UNUSED_COLOR_ITERATIONS: usize = 6;
1311
/// The fraction of pixels in the top/bottom rows of the image that need to be transparent before
1412
/// the entire image will be keyed.
1513
const KEYING_THRESHOLD: f32 = 0.2;
1614

17-
const SMALL_CIRCLE: i32 = 12;
18-
1915
/// Convert an in-memory image into an in-memory SVG
2016
pub fn convert(img: ColorImage, config: Config) -> Result<SvgFile, String> {
2117
let config = config.into_converter_config();
@@ -171,28 +167,15 @@ fn color_image_to_svg(mut img: ColorImage, config: ConverterConfig) -> Result<Sv
171167
let mut svg = SvgFile::new(width, height, config.path_precision);
172168
for &cluster_index in view.clusters_output.iter().rev() {
173169
let cluster = view.get_cluster(cluster_index);
174-
let paths = if matches!(config.mode, PathSimplifyMode::Spline)
175-
&& cluster.rect.width() < SMALL_CIRCLE
176-
&& cluster.rect.height() < SMALL_CIRCLE
177-
&& cluster.to_shape(&view).is_circle()
178-
{
179-
let mut paths = CompoundPath::new();
180-
paths.add_spline(approximate_circle_with_spline(
181-
cluster.rect.left_top(),
182-
cluster.rect.width(),
183-
));
184-
paths
185-
} else {
186-
cluster.to_compound_path(
187-
&view,
188-
false,
189-
config.mode,
190-
config.corner_threshold,
191-
config.length_threshold,
192-
config.max_iterations,
193-
config.splice_threshold,
194-
)
195-
};
170+
let paths = cluster.to_compound_path(
171+
&view,
172+
false,
173+
config.mode,
174+
config.corner_threshold,
175+
config.length_threshold,
176+
config.max_iterations,
177+
config.splice_threshold,
178+
);
196179
svg.add_path(paths, cluster.residue_color());
197180
}
198181

0 commit comments

Comments
 (0)