mirror of
https://github.com/visioncortex/vtracer.git
synced 2026-09-26 14:01:18 -07:00
Expose simplify in the Python and Node bindings
Config(simplify=...) / property in Python; simplify option in Node, with the tolerance documented in .pyi, index.d.ts, and both READMEs. The Node README's option list also catches up with the clustering rename and the binary/watershed options, and test.js drops the stale colorMode key (silently ignored since the rename, so its bw assertion was testing the default path) and asserts simplify shrinks output.
This commit is contained in:
@@ -51,10 +51,11 @@ properties, plus the presets `Config.bw()`, `Config.poster()`, `Config.photo()`:
|
||||
| `length_threshold` | `4.0` | px |
|
||||
| `max_iterations` | `10` | |
|
||||
| `splice_threshold` | `45` | degrees |
|
||||
| `simplify` | `None` | curve simplification tolerance in px (try 1–2.5) |
|
||||
| `path_precision` | `2` | output decimal places |
|
||||
| `palette` | `None` | list of `#rrggbb` strings |
|
||||
| `max_colors` | `None` | auto-quantize target |
|
||||
| `optimize` | `1` | `0` off, `1` quantize+simplify, `2` + shorthands |
|
||||
| `optimize` | `1` | `0` off, `1` quantize+cleanup, `2` + shorthands |
|
||||
| `binary_threshold` | `128` | bw: fixed cutoff, foreground below it |
|
||||
| `adaptive` | `False` | bw: Bradley–Roth adaptive thresholding |
|
||||
| `adaptive_window` | `0` | bw adaptive: window px (`0` = auto) |
|
||||
|
||||
@@ -140,6 +140,7 @@ impl PyConfig {
|
||||
length_threshold = 4.0,
|
||||
max_iterations = 10,
|
||||
splice_threshold = 45,
|
||||
simplify = None,
|
||||
path_precision = 2,
|
||||
palette = None,
|
||||
max_colors = None,
|
||||
@@ -162,6 +163,7 @@ impl PyConfig {
|
||||
length_threshold: f64,
|
||||
max_iterations: usize,
|
||||
splice_threshold: i32,
|
||||
simplify: Option<f64>,
|
||||
path_precision: u32,
|
||||
palette: Option<Vec<String>>,
|
||||
max_colors: Option<usize>,
|
||||
@@ -188,8 +190,7 @@ impl PyConfig {
|
||||
length_threshold,
|
||||
max_iterations,
|
||||
splice_threshold,
|
||||
// Curve simplification is not surfaced in the Python API yet.
|
||||
simplify: None,
|
||||
simplify,
|
||||
path_precision: Some(path_precision),
|
||||
palette,
|
||||
max_colors,
|
||||
@@ -331,6 +332,15 @@ impl PyConfig {
|
||||
self.inner.splice_threshold = v;
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn simplify(&self) -> Option<f64> {
|
||||
self.inner.simplify
|
||||
}
|
||||
#[setter]
|
||||
fn set_simplify(&mut self, v: Option<f64>) {
|
||||
self.inner.simplify = v;
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn path_precision(&self) -> Option<u32> {
|
||||
self.inner.path_precision
|
||||
|
||||
@@ -18,6 +18,7 @@ class Config:
|
||||
length_threshold: float = 4.0,
|
||||
max_iterations: int = 10,
|
||||
splice_threshold: int = 45,
|
||||
simplify: Optional[float] = None, # curve simplification tolerance in px (None = off)
|
||||
path_precision: int = 2,
|
||||
palette: Optional[list[str]] = None, # e.g. ["#112233", "#445566"]
|
||||
max_colors: Optional[int] = None, # auto-quantize target
|
||||
@@ -46,6 +47,7 @@ class Config:
|
||||
length_threshold: float
|
||||
max_iterations: int
|
||||
splice_threshold: int
|
||||
simplify: Optional[float]
|
||||
path_precision: Optional[int]
|
||||
palette: list[str]
|
||||
max_colors: Optional[int]
|
||||
|
||||
Reference in New Issue
Block a user