-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose clipper builder, add path methods
* Exposes the Clipper builder struct that uses a type state API to allow boolean operations on multiple paths at once. * Create Clipper builders from Paths::to_clipper_subject() and Paths::to_clipper_open_subject(). * Add inflate/simplify methods to Path and Paths * Update documentation and examples
- Loading branch information
Showing
19 changed files
with
636 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
use clipper2::*; | ||
use helpers::{draw_paths, draw_paths_points}; | ||
use helpers::{draw_path, draw_path_points}; | ||
use macroquad::prelude::*; | ||
|
||
mod helpers; | ||
|
||
#[macroquad::main("Simplify")] | ||
async fn main() { | ||
let path: Paths = vec![(1.0, 2.0), (1.0, 2.5), (1.2, 4.0), (1.8, 6.0)].into(); | ||
let path_simplified = simplify(path.translate(3.0, 0.0), 0.5, false); | ||
let path: Path = vec![(1.0, 2.0), (1.0, 2.5), (1.2, 4.0), (1.8, 6.0)].into(); | ||
|
||
// Functional API | ||
let _path = path.translate(3.0, 3.0); | ||
let _simplified = simplify(path.clone(), 0.5, false); | ||
|
||
// Alternative paths API | ||
let simplified = path.translate(3.0, 0.0).simplify(0.5, false); | ||
|
||
loop { | ||
clear_background(BLACK); | ||
draw_paths(&path, SKYBLUE); | ||
draw_paths(&path_simplified, SKYBLUE); | ||
draw_paths_points(&path, GREEN); | ||
draw_paths_points(&path_simplified, GREEN); | ||
draw_path(&path, SKYBLUE); | ||
draw_path(&simplified, SKYBLUE); | ||
draw_path_points(&path, GREEN); | ||
draw_path_points(&simplified, GREEN); | ||
next_frame().await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.