MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / construct_config

Function construct_config

external/vtracer/src/python.rs:163–221  ·  view source on GitHub ↗
(
    colormode: Option<&str>,
    hierarchical: Option<&str>,
    mode: Option<&str>,
    filter_speckle: Option<usize>,
    color_precision: Option<i32>,
    layer_difference: Option<i32>,
    corne

Source from the content-addressed store, hash-verified

161}
162
163fn construct_config(
164 colormode: Option<&str>,
165 hierarchical: Option<&str>,
166 mode: Option<&str>,
167 filter_speckle: Option<usize>,
168 color_precision: Option<i32>,
169 layer_difference: Option<i32>,
170 corner_threshold: Option<i32>,
171 length_threshold: Option<f64>,
172 max_iterations: Option<usize>,
173 splice_threshold: Option<i32>,
174 path_precision: Option<u32>,
175 keying_threshold: Option<f32>,
176) -> Config {
177 // TODO: enforce color mode with an enum so that we only
178 // accept the strings 'color' or 'binary'
179 let color_mode = match colormode.unwrap_or("color") {
180 "color" => ColorMode::Color,
181 "binary" => ColorMode::Binary,
182 _ => ColorMode::Color,
183 };
184
185 let hierarchical = match hierarchical.unwrap_or("stacked") {
186 "stacked" => Hierarchical::Stacked,
187 "cutout" => Hierarchical::Cutout,
188 _ => Hierarchical::Stacked,
189 };
190
191 let mode = match mode.unwrap_or("spline") {
192 "spline" => PathSimplifyMode::Spline,
193 "polygon" => PathSimplifyMode::Polygon,
194 "none" => PathSimplifyMode::None,
195 _ => PathSimplifyMode::Spline,
196 };
197
198 let filter_speckle = filter_speckle.unwrap_or(4);
199 let color_precision = color_precision.unwrap_or(6);
200 let layer_difference = layer_difference.unwrap_or(16);
201 let corner_threshold = corner_threshold.unwrap_or(60);
202 let length_threshold = length_threshold.unwrap_or(4.0);
203 let splice_threshold = splice_threshold.unwrap_or(45);
204 let max_iterations = max_iterations.unwrap_or(10);
205 let keying_threshold = keying_threshold.unwrap_or(0.2);
206 Config {
207 color_mode,
208 hierarchical,
209 filter_speckle,
210 color_precision,
211 layer_difference,
212 mode,
213 corner_threshold,
214 length_threshold,
215 max_iterations,
216 splice_threshold,
217 path_precision,
218 keying_threshold,
219 ..Default::default()
220 }

Callers 3

convert_image_to_svg_pyFunction · 0.85
convert_raw_image_to_svgFunction · 0.85
convert_pixels_to_svgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected