pub fn path_for_rounded_rectangle(
    bounds: &Rect,
    corner_radius: Coord,
    render_context: &mut RenderContext,
) -> Path {
    let kappa = 4.0 / 3.0 * (std::f32::consts::PI / 8.0).tan();
    let control_dist = kappa * corner_radius;

    let top_left_arc_start = bounds.origin + vec2(0.0, corner_radius);
    let top_left_arc_end = bounds.origin + vec2(corner_radius, 0.0);
    let top_left_curve_center = bounds.origin + vec2(corner_radius, corner_radius);
    let top_left_p1 = top_left_curve_center + vec2(-corner_radius, -control_dist);
    let top_left_p2 = top_left_curve_center + vec2(-control_dist, -corner_radius);

    let top_right = bounds.top_right();
    let top_right_arc_start = top_right + vec2(-corner_radius, 0.0);
    let top_right_arc_end = top_right + vec2(0.0, corner_radius);
    let top_right_curve_center = top_right + vec2(-corner_radius, corner_radius);
    let top_right_p1 = top_right_curve_center + vec2(control_dist, -corner_radius);
    let top_right_p2 = top_right_curve_center + vec2(corner_radius, -control_dist);

    let bottom_right = bounds.bottom_right();
    let bottom_right_arc_start = bottom_right + vec2(0.0, -corner_radius);
    let bottom_right_arc_end = bottom_right + vec2(-corner_radius, 0.0);
    let bottom_right_curve_center = bottom_right + vec2(-corner_radius, -corner_radius);
    let bottom_right_p1 = bottom_right_curve_center + vec2(corner_radius, control_dist);
    let bottom_right_p2 = bottom_right_curve_center + vec2(control_dist, corner_radius);

    let bottom_left = bounds.bottom_left();
    let bottom_left_arc_start = bottom_left + vec2(corner_radius, 0.0);
    let bottom_left_arc_end = bottom_left + vec2(0.0, -corner_radius);
    let bottom_left_curve_center = bottom_left + vec2(corner_radius, -corner_radius);
    let bottom_left_p1 = bottom_left_curve_center + vec2(-control_dist, corner_radius);
    let bottom_left_p2 = bottom_left_curve_center + vec2(-corner_radius, control_dist);

    let mut path_builder = render_context.path_builder().expect("path_builder");
    path_builder
        .move_to(top_left_arc_start)
        .cubic_to(top_left_p1, top_left_p2, top_left_arc_end)
        .line_to(top_right_arc_start)
        .cubic_to(top_right_p1, top_right_p2, top_right_arc_end)
        .line_to(bottom_right_arc_start)
        .cubic_to(bottom_right_p1, bottom_right_p2, bottom_right_arc_end)
        .line_to(bottom_left_arc_start)
        .cubic_to(bottom_left_p1, bottom_left_p2, bottom_left_arc_end)
        .line_to(top_left_arc_start);
    path_builder.build()
}
/// Create a render path for the specified rounded rectangle.
Create a render path for the specified rounded rectangle.
Create a render path for the specified rounded rectangle .
pub fn path_for_rounded_rectangle(
    bounds: &Rect,
    corner_radius: Coord,
    render_context: &mut RenderContext,
) -> Path {
    let kappa = 4.0 / 3.0 * (std::f32::consts::PI / 8.0).tan();
    let control_dist = kappa * corner_radius;
    let top_left_arc_start = bounds.origin + vec2(0.0, corner_radius);
    let top_left_arc_end = bounds.origin + vec2(corner_radius, 0.0);
    let top_left_curve_center = bounds.origin + vec2(corner_radius, corner_radius);
    let top_left_p1 = top_left_curve_center + vec2(-corner_radius, -control_dist);
    let top_left_p2 = top_left_curve_center + vec2(-control_dist, -corner_radius);
    let top_right = bounds.top_right();
    let top_right_arc_start = top_right + vec2(-corner_radius, 0.0);
    let top_right_arc_end = top_right + vec2(0.0, corner_radius);
    let top_right_curve_center = top_right + vec2(-corner_radius, corner_radius);
    let top_right_p1 = top_right_curve_center + vec2(control_dist, -corner_radius);
    let top_right_p2 = top_right_curve_center + vec2(corner_radius, -control_dist);
    let bottom_right = bounds.bottom_right();
    let bottom_right_arc_start = bottom_right + vec2(0.0, -corner_radius);
    let bottom_right_arc_end = bottom_right + vec2(-corner_radius, 0.0);
    let bottom_right_curve_center = bottom_right + vec2(-corner_radius, -corner_radius);
    let bottom_right_p1 = bottom_right_curve_center + vec2(corner_radius, control_dist);
    let bottom_right_p2 = bottom_right_curve_center + vec2(control_dist, corner_radius);
    let bottom_left = bounds.bottom_left();
    let bottom_left_arc_start = bottom_left + vec2(corner_radius, 0.0);
    let bottom_left_arc_end = bottom_left + vec2(0.0, -corner_radius);
    let bottom_left_curve_center = bottom_left + vec2(corner_radius, -corner_radius);
    let bottom_left_p1 = bottom_left_curve_center + vec2(-control_dist, corner_radius);
    let bottom_left_p2 = bottom_left_curve_center + vec2(-corner_radius, control_dist);
    let mut path_builder = render_context.path_builder().expect("path_builder");
    path_builder
        .move_to(top_left_arc_start)
        .cubic_to(top_left_p1, top_left_p2, top_left_arc_end)
        .line_to(top_right_arc_start)
        .cubic_to(top_right_p1, top_right_p2, top_right_arc_end)
        .line_to(bottom_right_arc_start)
        .cubic_to(bottom_right_p1, bottom_right_p2, bottom_right_arc_end)
        .line_to(bottom_left_arc_start)
        .cubic_to(bottom_left_p1, bottom_left_p2, bottom_left_arc_end)
        .line_to(top_left_arc_start);
    path_builder.build()
}
pub fn path_for_rounded_rectangle ( bounds : & Rect , corner_radius : Coord , render_context : & mut RenderContext , ) -> Path { let kappa = 4.0 / 3.0 * ( std :: f32 :: consts :: PI / 8.0 ) . tan ( ) ; let control_dist = kappa * corner_radius ; let top_left_arc_start = bounds . origin + vec2 ( 0.0 , corner_radius ) ; let top_left_arc_end = bounds . origin + vec2 ( corner_radius , 0.0 ) ; let top_left_curve_center = bounds . origin + vec2 ( corner_radius , corner_radius ) ; let top_left_p1 = top_left_curve_center + vec2 ( - corner_radius , - control_dist ) ; let top_left_p2 = top_left_curve_center + vec2 ( - control_dist , - corner_radius ) ; let top_right = bounds . top_right ( ) ; let top_right_arc_start = top_right + vec2 ( - corner_radius , 0.0 ) ; let top_right_arc_end = top_right + vec2 ( 0.0 , corner_radius ) ; let top_right_curve_center = top_right + vec2 ( - corner_radius , corner_radius ) ; let top_right_p1 = top_right_curve_center + vec2 ( control_dist , - corner_radius ) ; let top_right_p2 = top_right_curve_center + vec2 ( corner_radius , - control_dist ) ; let bottom_right = bounds . bottom_right ( ) ; let bottom_right_arc_start = bottom_right + vec2 ( 0.0 , - corner_radius ) ; let bottom_right_arc_end = bottom_right + vec2 ( - corner_radius , 0.0 ) ; let bottom_right_curve_center = bottom_right + vec2 ( - corner_radius , - corner_radius ) ; let bottom_right_p1 = bottom_right_curve_center + vec2 ( corner_radius , control_dist ) ; let bottom_right_p2 = bottom_right_curve_center + vec2 ( control_dist , corner_radius ) ; let bottom_left = bounds . bottom_left ( ) ; let bottom_left_arc_start = bottom_left + vec2 ( corner_radius , 0.0 ) ; let bottom_left_arc_end = bottom_left + vec2 ( 0.0 , - corner_radius ) ; let bottom_left_curve_center = bottom_left + vec2 ( corner_radius , - corner_radius ) ; let bottom_left_p1 = bottom_left_curve_center + vec2 ( - control_dist , corner_radius ) ; let bottom_left_p2 = bottom_left_curve_center + vec2 ( - corner_radius , control_dist ) ; let mut path_builder = render_context . path_builder ( ) . expect ( " " ) ; path_builder . move_to ( top_left_arc_start ) . cubic_to ( top_left_p1 , top_left_p2 , top_left_arc_end ) . line_to ( top_right_arc_start ) . cubic_to ( top_right_p1 , top_right_p2 , top_right_arc_end ) . line_to ( bottom_right_arc_start ) . cubic_to ( bottom_right_p1 , bottom_right_p2 , bottom_right_arc_end ) . line_to ( bottom_left_arc_start ) . cubic_to ( bottom_left_p1 , bottom_left_p2 , bottom_left_arc_end ) . line_to ( top_left_arc_start ) ; path_builder . build ( ) }
Create a render path for the specified rounded rectangle.
Create a render path for the specified rounded rectangle .
bounds
&Rect
corner_radius
Coord
render_context
&mut RenderContext
bounds
&Rect
corner_radius
Coord
render_context
&mut RenderContext