diff options
author | jaseg <git@jaseg.de> | 2021-01-27 01:26:54 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-01-27 01:26:54 +0100 |
commit | 9711fabab7893fcdd0a5708c79a7d48f2ad15167 (patch) | |
tree | a0af6000c47a5acc1b7ac8f6c802529b8af43f97 /src/vec_core.cpp | |
parent | 5285b6dce8f0df37282b744ce625d4976b0f2541 (diff) | |
download | gerbolyze-9711fabab7893fcdd0a5708c79a7d48f2ad15167.tar.gz gerbolyze-9711fabab7893fcdd0a5708c79a7d48f2ad15167.tar.bz2 gerbolyze-9711fabab7893fcdd0a5708c79a7d48f2ad15167.zip |
WIP render settings
Diffstat (limited to 'src/vec_core.cpp')
-rw-r--r-- | src/vec_core.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/vec_core.cpp b/src/vec_core.cpp index d329722..85b33b0 100644 --- a/src/vec_core.cpp +++ b/src/vec_core.cpp @@ -78,7 +78,7 @@ static void voronoi_relax_points(const jcv_diagram* diagram, jcv_point* points) * 4. It scales each of these voronoi cell polygons to match the input images brightness at the spot covered by this * cell. */ -void gerbolyze::vectorize_image(cairo_t *cr, const pugi::xml_node &node, double min_feature_size_px, ClipperLib::Paths &clip_path, cairo_matrix_t &viewport_matrix, PolygonSink &sink) { +void gerbolyze::VoronoiVectorizer::vectorize_image(cairo_t *cr, const pugi::xml_node &node, ClipperLib::Paths &clip_path, cairo_matrix_t &viewport_matrix, PolygonSink &sink, double min_feature_size_px) { /* Read XML node attributes */ auto x = usvg_double_attr(node, "x", 0.0); auto y = usvg_double_attr(node, "y", 0.0); @@ -167,8 +167,8 @@ void gerbolyze::vectorize_image(cairo_t *cr, const pugi::xml_node &node, double grayscale interpolation. Larger values -> better grayscale resolution, larger cells. */ double center_distance = min_feature_size_px * 2.0 * (1.0 / (1.0-grayscale_overhead)); - vector<d2p> *grid_centers = sample_poisson_disc(width, height, min_feature_size_px * 2.0 * 2.0); - /* TODO make these alternative grids available to callers */ + vector<d2p> *grid_centers = get_sampler(m_grid_type)(width, height, center_distance); + //vector<d2p> *grid_centers = sample_poisson_disc(width, height, min_feature_size_px * 2.0 * 2.0); //vector<d2p> *grid_centers = sample_hexgrid(width, height, center_distance); //vector<d2p> *grid_centers = sample_squaregrid(width, height, center_distance); @@ -197,7 +197,8 @@ void gerbolyze::vectorize_image(cairo_t *cr, const pugi::xml_node &node, double jcv_point *pts = reinterpret_cast<jcv_point *>(grid_centers->data()); /* hackety hack */ jcv_diagram_generate(grid_centers->size(), pts, &rect, 0, &diagram); /* Relax points, i.e. wiggle them around a little bit to equalize differences between cell sizes a little bit. */ - voronoi_relax_points(&diagram, pts); + if (m_relax) + voronoi_relax_points(&diagram, pts); memset(&diagram, 0, sizeof(jcv_diagram)); jcv_diagram_generate(grid_centers->size(), pts, &rect, 0, &diagram); |