mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-08 15:58:12 +08:00
Bezier-rs: Add trim for Subpath (#1006)
* Move compare.rs * Update traits for Subpath and ManipulatorGroup * Implement trim * UI adjustments and more tests * Add reverse, refactor code, rename variables * Improve comments * Comment nits * Address comments * Update trim behavior * Update doc comment for trim --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
ba50614af1
commit
8293f730f2
@@ -359,4 +359,21 @@ impl WasmSubpath {
|
||||
|
||||
wrap_svg_tag(format!("{}{}{}", self.to_default_svg(), main_subpath_svg, other_subpath_svg))
|
||||
}
|
||||
|
||||
pub fn trim(&self, t1: f64, t2: f64, t_variant: String) -> String {
|
||||
let t1 = parse_t_variant(&t_variant, t1);
|
||||
let t2 = parse_t_variant(&t_variant, t2);
|
||||
let trimmed_subpath = self.0.trim(t1, t2);
|
||||
|
||||
let mut trimmed_subpath_svg = String::new();
|
||||
trimmed_subpath.to_svg(
|
||||
&mut trimmed_subpath_svg,
|
||||
CURVE_ATTRIBUTES.to_string().replace(BLACK, RED).replace("stroke-width=\"2\"", "stroke-width=\"8\"") + " opacity=\"0.5\"",
|
||||
ANCHOR_ATTRIBUTES.to_string().replace(BLACK, RED),
|
||||
HANDLE_ATTRIBUTES.to_string().replace(GRAY, RED),
|
||||
HANDLE_LINE_ATTRIBUTES.to_string().replace(GRAY, RED),
|
||||
);
|
||||
|
||||
wrap_svg_tag(format!("{}{}", self.to_default_svg(), trimmed_subpath_svg))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user