mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-10 10:20:55 +08:00
Bezier-rs: Convert to_svg used in subpaths to match style used in beziers (#854)
Converted subpath::to_svg to Bezier style
This commit is contained in:
committed by
Keavon Chambers
parent
9c87658ae4
commit
00c8fa83c2
@@ -383,15 +383,8 @@ impl WasmBezier {
|
||||
pub fn rotate(&self, angle: f64, pivot_x: f64, pivot_y: f64) -> String {
|
||||
let original_bezier_svg = self.get_bezier_path();
|
||||
let rotated_bezier = self.0.rotate_about_point(angle, DVec2::new(pivot_x, pivot_y));
|
||||
let empty_string = String::new();
|
||||
let mut rotated_bezier_svg = String::new();
|
||||
rotated_bezier.to_svg(
|
||||
&mut rotated_bezier_svg,
|
||||
CURVE_ATTRIBUTES.to_string().replace(BLACK, RED),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
empty_string,
|
||||
);
|
||||
rotated_bezier.to_svg(&mut rotated_bezier_svg, CURVE_ATTRIBUTES.to_string().replace(BLACK, RED), String::new(), String::new(), String::new());
|
||||
let pivot = draw_circle(pivot_x, pivot_y, 3., GRAY, 1.5, WHITE);
|
||||
|
||||
// Line between pivot and start point on curve
|
||||
@@ -433,15 +426,8 @@ impl WasmBezier {
|
||||
|
||||
let bezier_curve_svg = self.get_bezier_path();
|
||||
|
||||
let empty_string = String::new();
|
||||
let mut line_svg = String::new();
|
||||
line.to_svg(
|
||||
&mut line_svg,
|
||||
CURVE_ATTRIBUTES.to_string().replace(BLACK, RED),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
empty_string,
|
||||
);
|
||||
line.to_svg(&mut line_svg, CURVE_ATTRIBUTES.to_string().replace(BLACK, RED), String::new(), String::new(), String::new());
|
||||
|
||||
let intersections_svg = self
|
||||
.intersect(&line, None)
|
||||
@@ -460,15 +446,8 @@ impl WasmBezier {
|
||||
|
||||
let bezier_curve_svg = self.get_bezier_path();
|
||||
|
||||
let empty_string = String::new();
|
||||
let mut quadratic_svg = String::new();
|
||||
quadratic.to_svg(
|
||||
&mut quadratic_svg,
|
||||
CURVE_ATTRIBUTES.to_string().replace(BLACK, RED),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
empty_string,
|
||||
);
|
||||
quadratic.to_svg(&mut quadratic_svg, CURVE_ATTRIBUTES.to_string().replace(BLACK, RED), String::new(), String::new(), String::new());
|
||||
|
||||
let intersections_svg = self
|
||||
.intersect(&quadratic, Some(error))
|
||||
@@ -487,15 +466,8 @@ impl WasmBezier {
|
||||
|
||||
let bezier_curve_svg = self.get_bezier_path();
|
||||
|
||||
let empty_string = String::new();
|
||||
let mut cubic_svg = String::new();
|
||||
cubic.to_svg(
|
||||
&mut cubic_svg,
|
||||
CURVE_ATTRIBUTES.to_string().replace(BLACK, RED),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
empty_string,
|
||||
);
|
||||
cubic.to_svg(&mut cubic_svg, CURVE_ATTRIBUTES.to_string().replace(BLACK, RED), String::new(), String::new(), String::new());
|
||||
|
||||
let intersections_svg = self
|
||||
.intersect(&cubic, Some(error))
|
||||
@@ -526,7 +498,6 @@ impl WasmBezier {
|
||||
}
|
||||
|
||||
pub fn reduce(&self) -> String {
|
||||
let empty_string = String::new();
|
||||
let original_curve_svg = self.get_bezier_path();
|
||||
let bezier_curves_svg: String = self
|
||||
.0
|
||||
@@ -538,9 +509,9 @@ impl WasmBezier {
|
||||
bezier_curve.to_svg(
|
||||
&mut curve_svg,
|
||||
CURVE_ATTRIBUTES.to_string().replace(BLACK, &format!("hsl({}, 100%, 50%)", (40 * index))),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
String::new(),
|
||||
String::new(),
|
||||
String::new(),
|
||||
);
|
||||
curve_svg
|
||||
})
|
||||
@@ -549,7 +520,6 @@ impl WasmBezier {
|
||||
}
|
||||
|
||||
pub fn offset(&self, distance: f64) -> String {
|
||||
let empty_string = String::new();
|
||||
let original_curve_svg = self.get_bezier_path();
|
||||
let bezier_curves_svg = self
|
||||
.0
|
||||
@@ -561,9 +531,9 @@ impl WasmBezier {
|
||||
bezier_curve.to_svg(
|
||||
&mut curve_svg,
|
||||
CURVE_ATTRIBUTES.to_string().replace(BLACK, &format!("hsl({}, 100%, 50%)", (40 * index))),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
empty_string.clone(),
|
||||
String::new(),
|
||||
String::new(),
|
||||
String::new(),
|
||||
);
|
||||
curve_svg
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user