Improve rendered SVG output syntax for better compatibility and terseness (#1880)

* Improve rendered SVG output syntax for better compatibility and terseness

* Fix CI failing on boolean operations without wasm32?

* Attempt 2
This commit is contained in:
Keavon Chambers
2024-07-30 08:28:49 -07:00
committed by GitHub
parent 22ebe9a2cb
commit 44ffb635e9
12 changed files with 249 additions and 189 deletions

View File

@@ -279,6 +279,7 @@ pub fn convert_usvg_path(path: &usvg::Path) -> Vec<Subpath<PointId>> {
subpaths
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(module = "/../../frontend/src/utility-functions/computational-geometry.ts")]
extern "C" {
#[wasm_bindgen(js_name = booleanUnion)]
@@ -290,3 +291,19 @@ extern "C" {
#[wasm_bindgen(js_name = booleanDifference)]
fn boolean_difference(path1: String, path2: String) -> String;
}
#[cfg(not(target_arch = "wasm32"))]
fn boolean_union(_path1: String, _path2: String) -> String {
String::from("M0,0 L1,0 L1,1 L0,1 Z")
}
#[cfg(not(target_arch = "wasm32"))]
fn boolean_subtract(_path1: String, _path2: String) -> String {
String::from("M0,0 L1,0 L1,1 L0,1 Z")
}
#[cfg(not(target_arch = "wasm32"))]
fn boolean_intersect(_path1: String, _path2: String) -> String {
String::from("M0,0 L1,0 L1,1 L0,1 Z")
}
#[cfg(not(target_arch = "wasm32"))]
fn boolean_difference(_path1: String, _path2: String) -> String {
String::from("M0,0 L1,0 L1,1 L0,1 Z")
}

View File

@@ -93,7 +93,10 @@ fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_p
attributes.push("y", "0");
attributes.push("width", footprint.resolution.x.to_string());
attributes.push("height", footprint.resolution.y.to_string());
attributes.push("transform", format_transform_matrix(footprint.transform.inverse()));
let matrix = format_transform_matrix(footprint.transform.inverse());
if !matrix.is_empty() {
attributes.push("transform", matrix);
}
attributes.push("fill", "white");
});
}