fn draw_segment(draw: &Draw, start: f32, end: f32, model: &Model) {
  let min_radius = random_range(model.min_radius, (model.max_radius - model.min_radius) / 2.);
  let inner_points = (0..20)
    .map(|n| {
      // to make border-less, change to ` / 19.`
      let factor = n as f32 / 20.;
      let theta = start + factor * (end - start);
      let x = theta.cos() * min_radius;
      let y = theta.sin() * min_radius;
      pt2(x, y)
    })
    // reverse so the polygon is concave, since inner and outer points are drawn in the same direction
    .rev();

  let max_radius = random_range((model.max_radius - model.min_radius) / 2., model.max_radius);
  let outer_points = (0..20).map(|n| {
    // to make border-less, change to ` / 19.`
    let factor = n as f32 / 20.;
    let theta = start + factor * (end - start);
    let x = theta.cos() * max_radius;
    let y = theta.sin() * max_radius;
    pt2(x, y)
  });

  let points: Vec<Point2> = inner_points.chain(outer_points).collect();

  let hue = random_range(model.hue * 0.95, model.hue * 1.05);
  let sat = random_range(model.sat * 0.9, model.sat * 1.1);
  let lum = random_range(model.lum * 0.9, model.lum * 1.1);
  draw.polygon().color(hsl(hue, sat, lum)).points(points);
}
/// draw single segment
/// Segments are polygons with an arc on top and bottom
draw single segment
Segments are polygons with an arc on top and bottom
draw single segment Segments are polygons with an arc on top and bottom
fn draw_segment(draw: &Draw, start: f32, end: f32, model: &Model) {
  let min_radius = random_range(model.min_radius, (model.max_radius - model.min_radius) / 2.);
  let inner_points = (0..20)
    .map(|n| {
      // to make border-less, change to ` / 19.`
      let factor = n as f32 / 20.;
      let theta = start + factor * (end - start);
      let x = theta.cos() * min_radius;
      let y = theta.sin() * min_radius;
      pt2(x, y)
    })
    // reverse so the polygon is concave, since inner and outer points are drawn in the same direction
    .rev();
  let max_radius = random_range((model.max_radius - model.min_radius) / 2., model.max_radius);
  let outer_points = (0..20).map(|n| {
    // to make border-less, change to ` / 19.`
    let factor = n as f32 / 20.;
    let theta = start + factor * (end - start);
    let x = theta.cos() * max_radius;
    let y = theta.sin() * max_radius;
    pt2(x, y)
  });
  let points: Vec<Point2> = inner_points.chain(outer_points).collect();
  let hue = random_range(model.hue * 0.95, model.hue * 1.05);
  let sat = random_range(model.sat * 0.9, model.sat * 1.1);
  let lum = random_range(model.lum * 0.9, model.lum * 1.1);
  draw.polygon().color(hsl(hue, sat, lum)).points(points);
}
fn draw_segment ( draw : & Draw , start : f32 , end : f32 , model : & Model ) { let min_radius = random_range ( model . min_radius , ( model . max_radius - model . min_radius ) / 2. ) ; let inner_points = ( 0 .. 20 ) . map ( | n | { // to make border-less, change to ` / 19.` let factor = n as f32 / 20. ; let theta = start + factor * ( end - start ) ; let x = theta . cos ( ) * min_radius ; let y = theta . sin ( ) * min_radius ; pt2 ( x , y ) } ) // reverse so the polygon is concave, since inner and outer points are drawn in the same direction . rev ( ) ; let max_radius = random_range ( ( model . max_radius - model . min_radius ) / 2. , model . max_radius ) ; let outer_points = ( 0 .. 20 ) . map ( | n | { // to make border-less, change to ` / 19.` let factor = n as f32 / 20. ; let theta = start + factor * ( end - start ) ; let x = theta . cos ( ) * max_radius ; let y = theta . sin ( ) * max_radius ; pt2 ( x , y ) } ) ; let points : Vec < Point2 > = inner_points . chain ( outer_points ) . collect ( ) ; let hue = random_range ( model . hue * 0.95 , model . hue * 1.05 ) ; let sat = random_range ( model . sat * 0.9 , model . sat * 1.1 ) ; let lum = random_range ( model . lum * 0.9 , model . lum * 1.1 ) ; draw . polygon ( ) . color ( hsl ( hue , sat , lum ) ) . points ( points ) ; }
draw single segment
Segments are polygons with an arc on top and bottom
draw single segment Segments are polygons with an arc on top and bottom
draw
&Draw
start
f32
end
f32
model
&Model