mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
preserve the curvature as much as possible
This commit is contained in:
parent
00b943b76b
commit
26e1a5355e
1 changed files with 24 additions and 3 deletions
|
@ -486,7 +486,12 @@ async fn round_corners(
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
new_bezpath.move_to(segments[0].start());
|
new_bezpath.move_to(segments[0].start());
|
||||||
} else if prev_rounded {
|
} else if prev_rounded {
|
||||||
new_bezpath.line_to(segments.last().unwrap().end())
|
let curr_seg = segments.last().unwrap();
|
||||||
|
let n = match curr_seg.as_path_el() {
|
||||||
|
PathEl::CurveTo(point, point1, point2) => PathEl::QuadTo(point1, point2),
|
||||||
|
el => el,
|
||||||
|
};
|
||||||
|
new_bezpath.push(n);
|
||||||
} else {
|
} else {
|
||||||
new_bezpath.push(segments.last().unwrap().as_path_el());
|
new_bezpath.push(segments.last().unwrap().as_path_el());
|
||||||
}
|
}
|
||||||
|
@ -508,7 +513,15 @@ async fn round_corners(
|
||||||
// Skip near-straight corners
|
// Skip near-straight corners
|
||||||
let curr_seg = segments[i];
|
let curr_seg = segments[i];
|
||||||
if theta > PI - min_angle_threshold.to_radians() {
|
if theta > PI - min_angle_threshold.to_radians() {
|
||||||
let n = if prev_rounded { PathEl::LineTo(curr_seg.end()) } else { curr_seg.as_path_el() };
|
// let n = if prev_rounded { PathEl::LineTo(curr_seg.end()) } else { curr_seg.as_path_el() };
|
||||||
|
let n = if prev_rounded {
|
||||||
|
match curr_seg.as_path_el() {
|
||||||
|
PathEl::CurveTo(point, point1, point2) => PathEl::QuadTo(point1, point2),
|
||||||
|
el => el,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
curr_seg.as_path_el()
|
||||||
|
};
|
||||||
new_bezpath.push(n);
|
new_bezpath.push(n);
|
||||||
prev_rounded = false;
|
prev_rounded = false;
|
||||||
continue;
|
continue;
|
||||||
|
@ -525,7 +538,15 @@ async fn round_corners(
|
||||||
if new_bezpath.elements().is_empty() {
|
if new_bezpath.elements().is_empty() {
|
||||||
new_bezpath.push(PathEl::MoveTo(dvec2_to_point(p1)));
|
new_bezpath.push(PathEl::MoveTo(dvec2_to_point(p1)));
|
||||||
} else {
|
} else {
|
||||||
new_bezpath.push(PathEl::LineTo(dvec2_to_point(p1)));
|
let n = if prev_rounded {
|
||||||
|
PathEl::LineTo(dvec2_to_point(p1))
|
||||||
|
} else {
|
||||||
|
match curr_seg.as_path_el() {
|
||||||
|
PathEl::CurveTo(point, _, _) => PathEl::QuadTo(point, dvec2_to_point(p1)),
|
||||||
|
el => el,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
new_bezpath.push(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
let point1 = dvec2_to_point(curr - dir1 * distance_along_edge * roundness);
|
let point1 = dvec2_to_point(curr - dir1 * distance_along_edge * roundness);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue