fn view(app: &App, model: &Model, frame: Frame) {
  // Prepare to draw.
  let draw = app.draw();

  // Clear the background to black.
  draw.background().color(hsl(242. / 360., 0.47, 0.02));

  // Harmonograph 1
  let harmonograph_1 = Harmonograph::new()
    .x_pendulums(vec![Pendulum::new(532.2, 48.06, 2.22, 0.03)])
    .y_pendulums(vec![
      Pendulum::new(524.2, 48.06, 0.85, 0.03),
      Pendulum::new(452.4, 8.07, 0.85, 0.03),
    ])
    .resolution(2200.)
    .length(26. * PI)
    .start(PI * 2.);

  let points = harmonograph_1.points();
  let n_points = points.len();

  let points_colored = points.iter().enumerate().map(|(i, pt)| {
    let factor = i as f32 / n_points as f32;
    let hue = lerp(model.color_start, model.color_end, factor);
    let lum = lerp(0.5, 0.7, factor);
    (pt.clone(), hsla(hue, 0.5, lum, 0.25))
  });

  points_colored.for_each(|(pt, color)| {
    draw
      .ellipse()
      .x_y(pt.x, pt.y)
      .w_h(0.15, 0.15)
      .color(color)
      .radius(model.line_weight);
  });

  // Harmonograph 2
  let harmonograph_2 = Harmonograph::new()
    .x_pendulums(vec![
      Pendulum::new(318.9, 8.01, 3.19, 0.06),
      Pendulum::new(255.1, 64.13, 2.22, 0.03),
    ])
    .y_pendulums(vec![
      Pendulum::new(337.5, 64.13, 0.85, 0.03),
      Pendulum::new(252.4, 8.07, 0.85, 0.03),
    ])
    .resolution(1000.)
    .length(5. * PI)
    .start(PI * 4.)
    .x_y(-500., 500.);

  let points = harmonograph_2.points();
  let n_points = points.len();

  let points_colored = points.iter().enumerate().map(|(i, pt)| {
    let factor = i as f32 / n_points as f32;
    let hue = lerp(model.color_start + 0.4, model.color_end + 0.4, factor);
    let lum = lerp(0.4, 0.6, factor);
    (pt.clone(), hsla(hue, 0.5, lum, 0.7))
  });

  // do not filter points that are offscreen because it can cause unexpected line artifacts
  // draw
  //   .polyline()
  //   .start_cap_round()
  //   .weight(model.line_weight)
  //   .points_colored(points_colored);

  // Harmonograph 3
  let harmonograph_3 = Harmonograph::new()
    .x_pendulums(vec![
      Pendulum::new(318.9, 8.01, 3.19, 0.06),
      Pendulum::new(255.1, 64.13, 2.22, 0.03),
    ])
    .y_pendulums(vec![
      Pendulum::new(337.5, 64.13, 0.85, 0.03),
      Pendulum::new(252.4, 8.07, 0.85, 0.03),
    ])
    .resolution(1000.)
    .length(5. * PI)
    .start(PI * 4.)
    .x_y(500., -500.);

  let points = harmonograph_3.points();
  let n_points = points.len();

  let points_colored = points.iter().enumerate().map(|(i, pt)| {
    let factor = i as f32 / n_points as f32;
    let hue = lerp(model.color_start + 0.4, model.color_end + 0.4, factor);
    let lum = lerp(0.4, 0.6, factor);
    (pt.clone(), hsla(hue, 0.5, lum, 0.7))
  });

  // do not filter points that are offscreen because it can cause unexpected line artifacts
  // draw
  //   .polyline()
  //   .start_cap_round()
  //   .weight(model.line_weight)
  //   .points_colored(points_colored);

  // Write to the window frame.
  draw.to_frame(app, &frame).unwrap();

  let file_path = captured_frame_path(app, &frame);
  app.main_window().capture_frame_threaded(file_path);
}
// the only thing this should do is draw the model.grid (or maybe model.next)
the only thing this should do is draw the model.grid (or maybe model.next)
the only thing this should do is draw the model . grid ( or maybe model . next )
fn view(app: &App, model: &Model, frame: Frame) {
  // Prepare to draw.
  let draw = app.draw();
  // Clear the background to black.
  draw.background().color(hsl(242. / 360., 0.47, 0.02));
  // Harmonograph 1
  let harmonograph_1 = Harmonograph::new()
    .x_pendulums(vec![Pendulum::new(532.2, 48.06, 2.22, 0.03)])
    .y_pendulums(vec![
      Pendulum::new(524.2, 48.06, 0.85, 0.03),
      Pendulum::new(452.4, 8.07, 0.85, 0.03),
    ])
    .resolution(2200.)
    .length(26. * PI)
    .start(PI * 2.);
  let points = harmonograph_1.points();
  let n_points = points.len();
  let points_colored = points.iter().enumerate().map(|(i, pt)| {
    let factor = i as f32 / n_points as f32;
    let hue = lerp(model.color_start, model.color_end, factor);
    let lum = lerp(0.5, 0.7, factor);
    (pt.clone(), hsla(hue, 0.5, lum, 0.25))
  });
  points_colored.for_each(|(pt, color)| {
    draw
      .ellipse()
      .x_y(pt.x, pt.y)
      .w_h(0.15, 0.15)
      .color(color)
      .radius(model.line_weight);
  });
  // Harmonograph 2
  let harmonograph_2 = Harmonograph::new()
    .x_pendulums(vec![
      Pendulum::new(318.9, 8.01, 3.19, 0.06),
      Pendulum::new(255.1, 64.13, 2.22, 0.03),
    ])
    .y_pendulums(vec![
      Pendulum::new(337.5, 64.13, 0.85, 0.03),
      Pendulum::new(252.4, 8.07, 0.85, 0.03),
    ])
    .resolution(1000.)
    .length(5. * PI)
    .start(PI * 4.)
    .x_y(-500., 500.);
  let points = harmonograph_2.points();
  let n_points = points.len();
  let points_colored = points.iter().enumerate().map(|(i, pt)| {
    let factor = i as f32 / n_points as f32;
    let hue = lerp(model.color_start + 0.4, model.color_end + 0.4, factor);
    let lum = lerp(0.4, 0.6, factor);
    (pt.clone(), hsla(hue, 0.5, lum, 0.7))
  });
  // do not filter points that are offscreen because it can cause unexpected line artifacts
  // draw
  //   .polyline()
  //   .start_cap_round()
  //   .weight(model.line_weight)
  //   .points_colored(points_colored);
  // Harmonograph 3
  let harmonograph_3 = Harmonograph::new()
    .x_pendulums(vec![
      Pendulum::new(318.9, 8.01, 3.19, 0.06),
      Pendulum::new(255.1, 64.13, 2.22, 0.03),
    ])
    .y_pendulums(vec![
      Pendulum::new(337.5, 64.13, 0.85, 0.03),
      Pendulum::new(252.4, 8.07, 0.85, 0.03),
    ])
    .resolution(1000.)
    .length(5. * PI)
    .start(PI * 4.)
    .x_y(500., -500.);
  let points = harmonograph_3.points();
  let n_points = points.len();
  let points_colored = points.iter().enumerate().map(|(i, pt)| {
    let factor = i as f32 / n_points as f32;
    let hue = lerp(model.color_start + 0.4, model.color_end + 0.4, factor);
    let lum = lerp(0.4, 0.6, factor);
    (pt.clone(), hsla(hue, 0.5, lum, 0.7))
  });
  // do not filter points that are offscreen because it can cause unexpected line artifacts
  // draw
  //   .polyline()
  //   .start_cap_round()
  //   .weight(model.line_weight)
  //   .points_colored(points_colored);
  // Write to the window frame.
  draw.to_frame(app, &frame).unwrap();
  let file_path = captured_frame_path(app, &frame);
  app.main_window().capture_frame_threaded(file_path);
}
fn view ( app : & App , model : & Model , frame : Frame ) { // Prepare to draw. let draw = app . draw ( ) ; // Clear the background to black. draw . background ( ) . color ( hsl ( 242. / 360. , 0.47 , 0.02 ) ) ; // Harmonograph 1 let harmonograph_1 = Harmonograph :: new ( ) . x_pendulums ( vec ! [ Pendulum new ( 532.2 48.06 2.22 0.03 ) ] ) . y_pendulums ( vec ! [ Pendulum new ( 524.2 48.06 0.85 0.03 ) Pendulum new ( 452.4 8.07 0.85 0.03 ) ] ) . resolution ( 2200. ) . length ( 26. * PI ) . start ( PI * 2. ) ; let points = harmonograph_1 . points ( ) ; let n_points = points . len ( ) ; let points_colored = points . iter ( ) . enumerate ( ) . map ( | ( i , pt ) | { let factor = i as f32 / n_points as f32 ; let hue = lerp ( model . color_start , model . color_end , factor ) ; let lum = lerp ( 0.5 , 0.7 , factor ) ; ( pt . clone ( ) , hsla ( hue , 0.5 , lum , 0.25 ) ) } ) ; points_colored . for_each ( | ( pt , color ) | { draw . ellipse ( ) . x_y ( pt . x , pt . y ) . w_h ( 0.15 , 0.15 ) . color ( color ) . radius ( model . line_weight ) ; } ) ; // Harmonograph 2 let harmonograph_2 = Harmonograph :: new ( ) . x_pendulums ( vec ! [ Pendulum new ( 318.9 8.01 3.19 0.06 ) Pendulum new ( 255.1 64.13 2.22 0.03 ) ] ) . y_pendulums ( vec ! [ Pendulum new ( 337.5 64.13 0.85 0.03 ) Pendulum new ( 252.4 8.07 0.85 0.03 ) ] ) . resolution ( 1000. ) . length ( 5. * PI ) . start ( PI * 4. ) . x_y ( - 500. , 500. ) ; let points = harmonograph_2 . points ( ) ; let n_points = points . len ( ) ; let points_colored = points . iter ( ) . enumerate ( ) . map ( | ( i , pt ) | { let factor = i as f32 / n_points as f32 ; let hue = lerp ( model . color_start + 0.4 , model . color_end + 0.4 , factor ) ; let lum = lerp ( 0.4 , 0.6 , factor ) ; ( pt . clone ( ) , hsla ( hue , 0.5 , lum , 0.7 ) ) } ) ; // do not filter points that are offscreen because it can cause unexpected line artifacts // draw //   .polyline() //   .start_cap_round() //   .weight(model.line_weight) //   .points_colored(points_colored); // Harmonograph 3 let harmonograph_3 = Harmonograph :: new ( ) . x_pendulums ( vec ! [ Pendulum new ( 318.9 8.01 3.19 0.06 ) Pendulum new ( 255.1 64.13 2.22 0.03 ) ] ) . y_pendulums ( vec ! [ Pendulum new ( 337.5 64.13 0.85 0.03 ) Pendulum new ( 252.4 8.07 0.85 0.03 ) ] ) . resolution ( 1000. ) . length ( 5. * PI ) . start ( PI * 4. ) . x_y ( 500. , - 500. ) ; let points = harmonograph_3 . points ( ) ; let n_points = points . len ( ) ; let points_colored = points . iter ( ) . enumerate ( ) . map ( | ( i , pt ) | { let factor = i as f32 / n_points as f32 ; let hue = lerp ( model . color_start + 0.4 , model . color_end + 0.4 , factor ) ; let lum = lerp ( 0.4 , 0.6 , factor ) ; ( pt . clone ( ) , hsla ( hue , 0.5 , lum , 0.7 ) ) } ) ; // do not filter points that are offscreen because it can cause unexpected line artifacts // draw //   .polyline() //   .start_cap_round() //   .weight(model.line_weight) //   .points_colored(points_colored); // Write to the window frame. draw . to_frame ( app , & frame ) . unwrap ( ) ; let file_path = captured_frame_path ( app , & frame ) ; app . main_window ( ) . capture_frame_threaded ( file_path ) ; }
the only thing this should do is draw the model.grid (or maybe model.next)
the only thing this should do is draw the model . grid ( or maybe model . next )
app
&App
model
&Model
frame
Frame