pub fn round_capped_line(&mut self, a: Vec2<f32>, b: Vec2<f32>, width: f32, color: Color) {
        self.push_state_cmd(StateCmd::TextureChange(SamplerId::Solid)); 
        let uv = Vec2::ZERO;

        let size = width/2.0;

        let len = (b - a).len();
        let tangent = (b - a) / len; 
        let normal = tangent.left();

        let a = a + tangent*size;
        let b = b - tangent*size;

        // Draw main line
        self.add_vertices(&[
            Vert { pos: a - normal*size, uv, color },
            Vert { pos: b - normal*size, uv, color },
            Vert { pos: b + normal*size, uv, color },
            Vert { pos: a - normal*size, uv, color },
            Vert { pos: b + normal*size, uv, color },
            Vert { pos: a + normal*size, uv, color },
        ]);

        // Draw caps
        for i in 0..(SIN_COS.len() - 1) {
            let c = (
                Vec2::complex_mul(SIN_COS[i], -normal),
                Vec2::complex_mul(SIN_COS[i + 1], -normal)
            );

            let d = (
                Vec2::complex_mul(SIN_COS[i], tangent),
                Vec2::complex_mul(SIN_COS[i + 1], tangent)
            );

            self.add_vertices(&[
                Vert { pos: a, uv, color },
                Vert { pos: a + Vec2::new(-c.0.x, -c.0.y)*size, uv, color },
                Vert { pos: a + Vec2::new(-c.1.x, -c.1.y)*size, uv, color },
                Vert { pos: a, uv, color },
                Vert { pos: a + Vec2::new(-d.0.x, -d.0.y)*size, uv, color },
                Vert { pos: a + Vec2::new(-d.1.x, -d.1.y)*size, uv, color },

                Vert { pos: b, uv, color },
                Vert { pos: b + Vec2::new(c.0.x, c.0.y)*size, uv, color },
                Vert { pos: b + Vec2::new(c.1.x, c.1.y)*size, uv, color },
                Vert { pos: b, uv, color },
                Vert { pos: b + Vec2::new(d.0.x, d.0.y)*size, uv, color },
                Vert { pos: b + Vec2::new(d.1.x, d.1.y)*size, uv, color },
            ]);
        }
    }
/// Draws a thick line with rounded caps.
Draws a thick line with rounded caps.
Draws a thick line with rounded caps .
pub fn round_capped_line(&mut self, a: Vec2<f32>, b: Vec2<f32>, width: f32, color: Color) {
        self.push_state_cmd(StateCmd::TextureChange(SamplerId::Solid)); 
        let uv = Vec2::ZERO;
        let size = width/2.0;
        let len = (b - a).len();
        let tangent = (b - a) / len; 
        let normal = tangent.left();
        let a = a + tangent*size;
        let b = b - tangent*size;
        // Draw main line
        self.add_vertices(&[
            Vert { pos: a - normal*size, uv, color },
            Vert { pos: b - normal*size, uv, color },
            Vert { pos: b + normal*size, uv, color },
            Vert { pos: a - normal*size, uv, color },
            Vert { pos: b + normal*size, uv, color },
            Vert { pos: a + normal*size, uv, color },
        ]);
        // Draw caps
        for i in 0..(SIN_COS.len() - 1) {
            let c = (
                Vec2::complex_mul(SIN_COS[i], -normal),
                Vec2::complex_mul(SIN_COS[i + 1], -normal)
            );
            let d = (
                Vec2::complex_mul(SIN_COS[i], tangent),
                Vec2::complex_mul(SIN_COS[i + 1], tangent)
            );
            self.add_vertices(&[
                Vert { pos: a, uv, color },
                Vert { pos: a + Vec2::new(-c.0.x, -c.0.y)*size, uv, color },
                Vert { pos: a + Vec2::new(-c.1.x, -c.1.y)*size, uv, color },
                Vert { pos: a, uv, color },
                Vert { pos: a + Vec2::new(-d.0.x, -d.0.y)*size, uv, color },
                Vert { pos: a + Vec2::new(-d.1.x, -d.1.y)*size, uv, color },
                Vert { pos: b, uv, color },
                Vert { pos: b + Vec2::new(c.0.x, c.0.y)*size, uv, color },
                Vert { pos: b + Vec2::new(c.1.x, c.1.y)*size, uv, color },
                Vert { pos: b, uv, color },
                Vert { pos: b + Vec2::new(d.0.x, d.0.y)*size, uv, color },
                Vert { pos: b + Vec2::new(d.1.x, d.1.y)*size, uv, color },
            ]);
        }
    }
pub fn round_capped_line ( & mut self , a : Vec2 < f32 > , b : Vec2 < f32 > , width : f32 , color : Color ) { self . push_state_cmd ( StateCmd :: TextureChange ( SamplerId :: Solid ) ) ; let uv = Vec2 :: ZERO ; let size = width / 2.0 ; let len = ( b - a ) . len ( ) ; let tangent = ( b - a ) / len ; let normal = tangent . left ( ) ; let a = a + tangent * size ; let b = b - tangent * size ; // Draw main line self . add_vertices ( & [ Vert { pos : a - normal * size , uv , color } , Vert { pos : b - normal * size , uv , color } , Vert { pos : b + normal * size , uv , color } , Vert { pos : a - normal * size , uv , color } , Vert { pos : b + normal * size , uv , color } , Vert { pos : a + normal * size , uv , color } , ] ) ; // Draw caps for i in 0 .. ( SIN_COS . len ( ) - 1 ) { let c = ( Vec2 :: complex_mul ( SIN_COS [ i ] , - normal ) , Vec2 :: complex_mul ( SIN_COS [ i + 1 ] , - normal ) ) ; let d = ( Vec2 :: complex_mul ( SIN_COS [ i ] , tangent ) , Vec2 :: complex_mul ( SIN_COS [ i + 1 ] , tangent ) ) ; self . add_vertices ( & [ Vert { pos : a , uv , color } , Vert { pos : a + Vec2 :: new ( - c . 0 . x , - c . 0 . y ) * size , uv , color } , Vert { pos : a + Vec2 :: new ( - c . 1 . x , - c . 1 . y ) * size , uv , color } , Vert { pos : a , uv , color } , Vert { pos : a + Vec2 :: new ( - d . 0 . x , - d . 0 . y ) * size , uv , color } , Vert { pos : a + Vec2 :: new ( - d . 1 . x , - d . 1 . y ) * size , uv , color } , Vert { pos : b , uv , color } , Vert { pos : b + Vec2 :: new ( c . 0 . x , c . 0 . y ) * size , uv , color } , Vert { pos : b + Vec2 :: new ( c . 1 . x , c . 1 . y ) * size , uv , color } , Vert { pos : b , uv , color } , Vert { pos : b + Vec2 :: new ( d . 0 . x , d . 0 . y ) * size , uv , color } , Vert { pos : b + Vec2 :: new ( d . 1 . x , d . 1 . y ) * size , uv , color } , ] ) ; } }
Draws a thick line with rounded caps.
Draws a thick line with rounded caps .
&mut self
a
Vec2<f32>
b
Vec2<f32>
width
f32
color
Color
&mut self
a
Vec2<f32>
b
Vec2<f32>
width
f32
color
Color