fn draw_contour_polygons(
  draw: &Draw,
  model: &Model,
  n: usize,
  contour_segments: Vec<Deque2>,
  win: &Rect,
) {
  let contour = connect_contour_segments(contour_segments);
  let hue = if n < model.n_contours / 2 { 0.07 } else { 0.59 };
  let color = hsla(
    hue,
    0.5,
    map_range(n, 0, model.n_contours - 1, 0.3, 0.8),
    0.1,
  );
  let stroke = hsla(hue, 0.4, 0.05, 1.);
  for mut line in contour.clone() {
    if !line.is_empty() {
      let front = line.front().unwrap().clone();
      let back = line.back().unwrap().clone();
      // if the line is not closed, then we will try our best to make it appear closed!
      if !is_somewhat_near(&front, &back) && terminals_are_out_of_view(&front, &back, win) {
        let (start, end) = get_extended_terminals(&front, &back, win);
        line.push_front(start);
        line.push_back(end);
      }
      if should_show(&front, &back, win) {
        draw
          .polygon()
          .color(color)
          .stroke_weight(1.0)
          .stroke(stroke)
          .points(line.clone());
      }
    }
  }

  for line in contour {
    // draw the stroke will full opacity
    draw.polyline().color(stroke).weight(2.0).points(line);
  }
}
// Draw all the lines for the contour.
// In contours1 and contours2, the `contour` vector contained a ton of 2-point segments.
// In this implementation, it contains full "connected" contours. However, any given
// contour can still have multiple non-contiguous segments, even if they are all closed.
// Hence, we still have a Vec<Line2>, but each Line2 has a very different meaning.
// In retrospect, I probably should have given the contour_segments a specific data type
// in contour1 and contour2, but y'know you live and learn
Draw all the lines for the contour.
In contours1 and contours2, the `contour` vector contained a ton of 2-point segments.
In this implementation, it contains full "connected" contours. However, any given
contour can still have multiple non-contiguous segments, even if they are all closed.
Hence, we still have a Vec, but each Line2 has a very different meaning.
In retrospect, I probably should have given the contour_segments a specific data type
in contour1 and contour2, but y'know you live and learn
Draw all the lines for the contour . In contours1 and contours2 the ` contour ` vector contained a ton of 2 - point segments . In this implementation it contains full " connected " contours . However any given contour can still have multiple non - contiguous segments even if they are all closed . Hence we still have a Vec but each Line2 has a very different meaning . In retrospect I probably should have given the contour_segments a specific data type in contour1 and contour2 but y ' know you live and learn
fn draw_contour_polygons(
  draw: &Draw,
  model: &Model,
  n: usize,
  contour_segments: Vec<Deque2>,
  win: &Rect,
) {
  let contour = connect_contour_segments(contour_segments);
  let hue = if n < model.n_contours / 2 { 0.07 } else { 0.59 };
  let color = hsla(
    hue,
    0.5,
    map_range(n, 0, model.n_contours - 1, 0.3, 0.8),
    0.1,
  );
  let stroke = hsla(hue, 0.4, 0.05, 1.);
  for mut line in contour.clone() {
    if !line.is_empty() {
      let front = line.front().unwrap().clone();
      let back = line.back().unwrap().clone();
      // if the line is not closed, then we will try our best to make it appear closed!
      if !is_somewhat_near(&front, &back) && terminals_are_out_of_view(&front, &back, win) {
        let (start, end) = get_extended_terminals(&front, &back, win);
        line.push_front(start);
        line.push_back(end);
      }
      if should_show(&front, &back, win) {
        draw
          .polygon()
          .color(color)
          .stroke_weight(1.0)
          .stroke(stroke)
          .points(line.clone());
      }
    }
  }
  for line in contour {
    // draw the stroke will full opacity
    draw.polyline().color(stroke).weight(2.0).points(line);
  }
}
fn draw_contour_polygons ( draw : & Draw , model : & Model , n : usize , contour_segments : Vec < Deque2 > , win : & Rect , ) { let contour = connect_contour_segments ( contour_segments ) ; let hue = if n < model . n_contours / 2 { 0.07 } else { 0.59 } ; let color = hsla ( hue , 0.5 , map_range ( n , 0 , model . n_contours - 1 , 0.3 , 0.8 ) , 0.1 , ) ; let stroke = hsla ( hue , 0.4 , 0.05 , 1. ) ; for mut line in contour . clone ( ) { if ! line . is_empty ( ) { let front = line . front ( ) . unwrap ( ) . clone ( ) ; let back = line . back ( ) . unwrap ( ) . clone ( ) ; // if the line is not closed, then we will try our best to make it appear closed! if ! is_somewhat_near ( & front , & back ) && terminals_are_out_of_view ( & front , & back , win ) { let ( start , end ) = get_extended_terminals ( & front , & back , win ) ; line . push_front ( start ) ; line . push_back ( end ) ; } if should_show ( & front , & back , win ) { draw . polygon ( ) . color ( color ) . stroke_weight ( 1.0 ) . stroke ( stroke ) . points ( line . clone ( ) ) ; } } } for line in contour { // draw the stroke will full opacity draw . polyline ( ) . color ( stroke ) . weight ( 2.0 ) . points ( line ) ; } }
Draw all the lines for the contour.
Draw all the lines for the contour .
draw
&Draw
model
&Model
n
usize
contour_segments
Vec<Deque2>
win
&Rect