mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 16:28:12 +08:00
Fix shape not closed after using Fill Tool (#510)
* Always set shape property 'closed' on fill * Remove closed property on Shape * Make color mandatory in Fill * Fix intersection for filled but open shapes * Code style tweak * Add TODO note to rework ClosePath check
This commit is contained in:
committed by
Keavon Chambers
parent
ca46767cf2
commit
386c970b60
@@ -47,18 +47,24 @@ fn to_point(vec: DVec2) -> Point {
|
||||
Point::new(vec.x, vec.y)
|
||||
}
|
||||
|
||||
pub fn intersect_quad_bez_path(quad: Quad, shape: &BezPath, closed: bool) -> bool {
|
||||
pub fn intersect_quad_bez_path(quad: Quad, shape: &BezPath, filled: bool) -> bool {
|
||||
let mut shape = shape.clone();
|
||||
// for filled shapes act like shape was closed even if it isn't
|
||||
if filled && shape.elements().last() != Some(&kurbo::PathEl::ClosePath) {
|
||||
shape.close_path();
|
||||
}
|
||||
|
||||
// check if outlines intersect
|
||||
if shape.segments().any(|path_segment| quad.lines().iter().any(|line| !path_segment.intersect_line(*line).is_empty())) {
|
||||
return true;
|
||||
}
|
||||
// check if selection is entirely within the shape
|
||||
if closed && shape.contains(to_point(quad.0[0])) {
|
||||
if filled && shape.contains(to_point(quad.0[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if shape is entirely within selection
|
||||
get_arbitrary_point_on_path(shape).map(|shape_point| quad.path().contains(shape_point)).unwrap_or_default()
|
||||
get_arbitrary_point_on_path(&shape).map(|shape_point| quad.path().contains(shape_point)).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn get_arbitrary_point_on_path(path: &BezPath) -> Option<Point> {
|
||||
|
||||
Reference in New Issue
Block a user