mirror of
https://github.com/visioncortex/vtracer.git
synced 2025-12-07 09:36:09 -08:00
Update to visioncortex 0.4.0
This commit is contained in:
@@ -46,7 +46,7 @@ impl Canvas {
|
||||
image.data().to_vec()
|
||||
}
|
||||
|
||||
pub fn get_image_data_as_image(&self, x: u32, y: u32, width: u32, height: u32) -> ColorImage {
|
||||
pub fn get_image_data_as_color_image(&self, x: u32, y: u32, width: u32, height: u32) -> ColorImage {
|
||||
ColorImage {
|
||||
pixels: self.get_image_data(x, y, width, height),
|
||||
width: width as usize,
|
||||
|
||||
@@ -54,7 +54,7 @@ impl BinaryImageConverter {
|
||||
pub fn init(&mut self) {
|
||||
let width = self.canvas.width() as u32;
|
||||
let height = self.canvas.height() as u32;
|
||||
let image = self.canvas.get_image_data_as_image(0, 0, width, height);
|
||||
let image = self.canvas.get_image_data_as_color_image(0, 0, width, height);
|
||||
let binary_image = image.to_binary_image(|x| x.r < 128);
|
||||
self.clusters = binary_image.to_clusters(false);
|
||||
self.canvas.log(&format!(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
use visioncortex::PathSimplifyMode;
|
||||
use visioncortex::color_clusters::{IncrementalBuilder, Clusters, Runner, RunnerConfig};
|
||||
use visioncortex::color_clusters::{IncrementalBuilder, Clusters, Runner, RunnerConfig, HIERARCHICAL_MAX};
|
||||
|
||||
use crate::canvas::*;
|
||||
use crate::svg::*;
|
||||
@@ -64,8 +64,10 @@ impl ColorImageConverter {
|
||||
pub fn init(&mut self) {
|
||||
let width = self.canvas.width() as u32;
|
||||
let height = self.canvas.height() as u32;
|
||||
let image = self.canvas.get_image_data_as_image(0, 0, width, height);
|
||||
let image = self.canvas.get_image_data_as_color_image(0, 0, width, height);
|
||||
let runner = Runner::new(RunnerConfig {
|
||||
diagonal: self.params.layer_difference == 0,
|
||||
hierarchical: HIERARCHICAL_MAX,
|
||||
batch_size: 25600,
|
||||
good_min_area: self.params.filter_speckle,
|
||||
good_max_area: (width * height) as usize,
|
||||
|
||||
Reference in New Issue
Block a user