draw: Change direction depending on chosen guide tangent

This commit is contained in:
Mikolaj Wielgus 2023-09-05 06:01:03 +02:00
parent f88636057f
commit 05fc42aa38
2 changed files with 4 additions and 5 deletions

View File

@ -83,15 +83,16 @@ impl<'a> Draw<'a> {
&mut self, &mut self,
head: Head, head: Head,
around: DotIndex, around: DotIndex,
cw: bool,
width: f64, width: f64,
) -> Result<Head, ()> { ) -> Result<Head, ()> {
let mut tangents = self let mut tangents = self
.guide(&Default::default()) .guide(&Default::default())
.head_around_dot_segments(&head, around, width); .head_around_dot_segments(&head, around, width);
let mut dirs = [true, false];
if tangents.1.euclidean_length() < tangents.0.euclidean_length() { if tangents.1.euclidean_length() < tangents.0.euclidean_length() {
tangents = (tangents.1, tangents.0); tangents = (tangents.1, tangents.0);
dirs = [false, true];
} }
for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() { for (i, tangent) in [tangents.0, tangents.1].iter().enumerate() {
@ -100,7 +101,7 @@ impl<'a> Draw<'a> {
TaggedIndex::Dot(around), TaggedIndex::Dot(around),
tangent.start_point(), tangent.start_point(),
tangent.end_point(), tangent.end_point(),
cw, dirs[i],
width, width,
) { ) {
Ok(head) => { Ok(head) => {

View File

@ -78,9 +78,7 @@ impl<'a> Route<'a> {
pub fn step(&mut self, trace: &mut Trace, to: VertexIndex, width: f64) -> Result<(), ()> { pub fn step(&mut self, trace: &mut Trace, to: VertexIndex, width: f64) -> Result<(), ()> {
let to_dot = self.mesh.dot(to); let to_dot = self.mesh.dot(to);
trace.head = self trace.head = self.draw().segbend_around_dot(trace.head, to_dot, width)?;
.draw()
.segbend_around_dot(trace.head, to_dot, true, width)?;
trace.path.push(to); trace.path.push(to);
Ok(()) Ok(())
} }