-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rework edges and add parallel lines
- Loading branch information
Showing
19 changed files
with
1,043 additions
and
503 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#[derive(Debug, Clone, Copy)] | ||
pub enum EdgeDirection { | ||
Up, | ||
DiagUpRight, | ||
Right, | ||
DiagDownRight, | ||
Down, | ||
DiagDownLeft, | ||
Left, | ||
DiagUpLeft, | ||
Equal, | ||
} | ||
|
||
/// Calculates the direction the edge is moving. | ||
pub fn calc_direction(from_x: f64, from_y: f64, to_x: f64, to_y: f64) -> EdgeDirection { | ||
if from_x == to_x && from_y > to_y { | ||
EdgeDirection::Up | ||
} else if from_x < to_x && from_y > to_y { | ||
EdgeDirection::DiagUpRight | ||
} else if from_x < to_x && from_y == to_y { | ||
EdgeDirection::Right | ||
} else if from_x < to_x && from_y < to_y { | ||
EdgeDirection::DiagDownRight | ||
} else if from_x == to_x && from_y < to_y { | ||
EdgeDirection::Down | ||
} else if from_x > to_x && from_y < to_y { | ||
EdgeDirection::DiagDownLeft | ||
} else if from_x > to_x && from_y == to_y { | ||
EdgeDirection::Left | ||
} else if from_x > to_x && from_y > to_y { | ||
EdgeDirection::DiagUpLeft | ||
} else { | ||
EdgeDirection::Equal | ||
} | ||
} |
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
Oops, something went wrong.