Skip to content

Add path-bool library #1952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
883b0bb
Add path-bool library
TrueDoctor Sep 2, 2024
5abda28
Cleanup code
TrueDoctor Sep 2, 2024
b38c323
Cargo format
TrueDoctor Sep 2, 2024
a407572
Integrate boolean ops into graphite
TrueDoctor Sep 2, 2024
94f72d1
Add test for editor crash
TrueDoctor Sep 2, 2024
3c2c1fe
Fix edge sort floating point instability
TrueDoctor Sep 4, 2024
6c2c2cd
Add unit test for red-dress failure
TrueDoctor Sep 5, 2024
fe40a70
Backport tests and aux functions
TrueDoctor Sep 13, 2024
cd6f45e
Use curvature based sorting
TrueDoctor Sep 13, 2024
eb6868c
Convert linear cubic splines to line segments
TrueDoctor Sep 13, 2024
7d40e4e
Deduplicate reversed path segments
TrueDoctor Sep 13, 2024
71ba9d4
Fix epsilon for empty segments
TrueDoctor Sep 14, 2024
5b7b848
Remove parameter based intersection pruning
TrueDoctor Sep 14, 2024
24eecdf
Add support for reversed paths
TrueDoctor Sep 14, 2024
5fccfd9
Add benchmark infrastructure
TrueDoctor Sep 14, 2024
676c22f
Add intersection benchmark
TrueDoctor Sep 14, 2024
3f0a282
Add recursion bound
TrueDoctor Sep 14, 2024
5f18b42
Implement support for overlapping path segments
TrueDoctor Sep 16, 2024
61f760c
Remove rouge prinln
TrueDoctor Sep 16, 2024
27de2e0
Fix sorting for bezier segments with one control point at the start o…
TrueDoctor Sep 16, 2024
4100a6f
Cleanup log statements
TrueDoctor Sep 16, 2024
4ac1f2d
Directly translate graphite paths to Path segments
TrueDoctor Sep 16, 2024
a4c33d4
Round data before passing it to path_bool
TrueDoctor Sep 17, 2024
88c72ae
Fix flag_faces traversal order
TrueDoctor Sep 17, 2024
3acce4e
Add test for white dots in bottom right of painted dreams
TrueDoctor Sep 17, 2024
2047c59
Make rounding configurable
TrueDoctor Sep 17, 2024
50e2db0
Update demo artwork to remove manual path modifications
TrueDoctor Sep 17, 2024
96fe907
Convert from path segments to manipulator groups directly
TrueDoctor Sep 17, 2024
dcf8655
Remove dead code
TrueDoctor Sep 17, 2024
0a5ddc2
Fix clippy lints
TrueDoctor Sep 17, 2024
b15f30f
Replace functions in path segment with methods and add documentation
TrueDoctor Sep 17, 2024
bc95d81
Add more documentation
TrueDoctor Sep 17, 2024
4a300f4
Close subpaths
TrueDoctor Sep 17, 2024
db7a199
Reorganize files and add README.md
TrueDoctor Sep 20, 2024
53e9da2
Add license information
TrueDoctor Sep 20, 2024
544b149
Code review
TrueDoctor Sep 20, 2024
99de883
Fix license info
Keavon Sep 20, 2024
176be29
Adopt new node macro and fix demo artwork
Keavon Sep 20, 2024
dd20465
Close subpaths with Z
Keavon Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for white dots in bottom right of painted dreams
  • Loading branch information
TrueDoctor authored and Keavon committed Sep 21, 2024
commit 3acce4ede5f08ad92200a3f7cb6fab595f4a3ecc
17 changes: 17 additions & 0 deletions libraries/path-bool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,23 @@ mod test {

let result = path_boolean(&a, FillRule::NonZero, &b, FillRule::NonZero, PathBooleanOperation::Intersection).unwrap();

// Add assertions here based on expected results
assert_eq!(result.len(), 1, "Expected 1 resulting path for Union operation");
dbg!(path_to_path_data(&result[0], 0.001));
// Add more specific assertions about the resulting path if needed
assert!(!result[0].is_empty());
}
#[test]
fn painted_dreams_7() {
let a = path_from_path_data(
"M 989.666700000000,768.000000000000 C 989.666700000000,768.000000000000 1011.111100000000,786.399400000000 1011.111100000000,786.399400000000 C 1011.111100000000,786.399400000000 1299.306500000000,786.399400000000 1299.306500000000,786.399400000000 C 1299.306500000000,786.399400000000 1318.000000000000,768.000000000000 1318.000000000000,768.000000000000 C 1293.666700000000,681.000000000000 1173.363200000000,625.103600000000 1094.162400000000,594.296600000000 C 1094.162400000000,594.296600000000 1058.747200000000,687.805800000000 989.666700000000,768.000000000000"
);
let b = path_from_path_data(
"M 983.155000000000,775.589300000000 L 1004.599400000000,793.988700000000 L 1007.409000000000,796.399400000000 L 1011.111100000000,796.399400000000 L 1299.306500000000,796.399400000000 L 1303.402200000000,796.399400000000 L 1306.321200000000,793.526300000000 L 1325.014800000000,775.126900000000 L 1329.236900000000,770.971200000000 L 1327.630400000000,765.306400000000 C 1302.280700000000,675.920800000000 1179.503900000000,617.211200000000 1097.787500000000,584.976800000000 L 1088.418100000000,581.280900000000 L 1084.806400000000,590.765700000000 C 1084.117400000000,592.575300000000 1049.449700000000,683.516200000000 982.090100000000,761.473400000000 L 975.539200000000,769.055000000000 L 983.155000000000,775.589300000000 M 1003.696800000000,766.861600000000 C 1068.901100000000,687.878900000000 1102.806400000000,599.696700000000 1103.497000000000,597.883400000000 L 1090.537200000000,603.616300000000 C 1165.521500000000,632.344400000000 1279.846400000000,683.736400000000 1306.585700000000,765.203400000000 L 1295.210700000000,776.399400000000 L 1014.813100000000,776.399400000000 L 1003.696800000000,766.861600000000",
);

let result = path_boolean(&a, FillRule::NonZero, &b, FillRule::NonZero, PathBooleanOperation::Difference).unwrap();

// Add assertions here based on expected results
assert_eq!(result.len(), 1, "Expected 1 resulting path for Union operation");
dbg!(path_to_path_data(&result[0], 0.001));
Expand Down
2 changes: 1 addition & 1 deletion libraries/path-bool/src/path_boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ fn flag_faces(
}
visited_faces.insert(face_key);

dbg!(face_key, a_count, b_count);
// dbg!(face_key, a_count, b_count);
let a_flag = get_flag(a_count, a_fill_rule);
let b_flag = get_flag(b_count, b_fill_rule);
*flags.entry(face_key).or_default() = a_flag | (b_flag << 1);
Expand Down