mirror of
https://github.com/visioncortex/vtracer.git
synced 2025-12-06 17:15:41 -08:00
Revert "Experiment with idealizing small circles"
This reverts commit c3012c6aef.
This commit is contained in:
@@ -13,7 +13,7 @@ keywords = ["svg", "computer-graphics"]
|
||||
[dependencies]
|
||||
clap = "2.33.3"
|
||||
image = "0.23.10"
|
||||
visioncortex = { version = "0.8.4" }
|
||||
visioncortex = { version = "0.8.1" }
|
||||
fastrand = "1.8"
|
||||
pyo3 = { version = "0.19.0", optional = true }
|
||||
|
||||
|
||||
@@ -5,17 +5,13 @@ use super::config::{ColorMode, Config, ConverterConfig, Hierarchical};
|
||||
use super::svg::SvgFile;
|
||||
use fastrand::Rng;
|
||||
use visioncortex::color_clusters::{KeyingAction, Runner, RunnerConfig, HIERARCHICAL_MAX};
|
||||
use visioncortex::{
|
||||
approximate_circle_with_spline, Color, ColorImage, ColorName, CompoundPath, PathSimplifyMode,
|
||||
};
|
||||
use visioncortex::{Color, ColorImage, ColorName};
|
||||
|
||||
const NUM_UNUSED_COLOR_ITERATIONS: usize = 6;
|
||||
/// The fraction of pixels in the top/bottom rows of the image that need to be transparent before
|
||||
/// the entire image will be keyed.
|
||||
const KEYING_THRESHOLD: f32 = 0.2;
|
||||
|
||||
const SMALL_CIRCLE: i32 = 12;
|
||||
|
||||
/// Convert an in-memory image into an in-memory SVG
|
||||
pub fn convert(img: ColorImage, config: Config) -> Result<SvgFile, String> {
|
||||
let config = config.into_converter_config();
|
||||
@@ -171,19 +167,7 @@ fn color_image_to_svg(mut img: ColorImage, config: ConverterConfig) -> Result<Sv
|
||||
let mut svg = SvgFile::new(width, height, config.path_precision);
|
||||
for &cluster_index in view.clusters_output.iter().rev() {
|
||||
let cluster = view.get_cluster(cluster_index);
|
||||
let paths = if matches!(config.mode, PathSimplifyMode::Spline)
|
||||
&& cluster.rect.width() < SMALL_CIRCLE
|
||||
&& cluster.rect.height() < SMALL_CIRCLE
|
||||
&& cluster.to_shape(&view).is_circle()
|
||||
{
|
||||
let mut paths = CompoundPath::new();
|
||||
paths.add_spline(approximate_circle_with_spline(
|
||||
cluster.rect.left_top(),
|
||||
cluster.rect.width(),
|
||||
));
|
||||
paths
|
||||
} else {
|
||||
cluster.to_compound_path(
|
||||
let paths = cluster.to_compound_path(
|
||||
&view,
|
||||
false,
|
||||
config.mode,
|
||||
@@ -191,8 +175,7 @@ fn color_image_to_svg(mut img: ColorImage, config: ConverterConfig) -> Result<Sv
|
||||
config.length_threshold,
|
||||
config.max_iterations,
|
||||
config.splice_threshold,
|
||||
)
|
||||
};
|
||||
);
|
||||
svg.add_path(paths, cluster.residue_color());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user