diff --git a/tessellation/src/lib.rs b/tessellation/src/lib.rs index 0d588826..53b2965f 100644 --- a/tessellation/src/lib.rs +++ b/tessellation/src/lib.rs @@ -168,8 +168,8 @@ //! //! ## Examples //! -//! - [tessellating path fills](path_fill/index.html#examples). -//! - [tessellating path strokes](path_stroke/index.html#examples). +//! - [tessellating path fills](path_fill/struct.FillTessellator.html#examples). +//! - [tessellating path strokes](path_stroke/struct.StrokeTessellator.html#examples). //! - [Generating custom vertices](geometry_builder/index.html#generating-custom-vertices). //! - [Generating completely custom output](geometry_builder/index.html#generating-a-completely-custom-output). //! - [Writing a tessellator](geometry_builder/index.html#writing-a-tessellator). @@ -311,7 +311,7 @@ pub enum LineJoin { MiterClip, /// A round corner is to be used to join path segments. Round, - /// [Not implemented] A bevelled corner is to be used to join path segments. + /// A bevelled corner is to be used to join path segments. /// The bevel shape is a triangle that fills the area between the two stroked /// segments. Bevel, diff --git a/tessellation/src/path_stroke.rs b/tessellation/src/path_stroke.rs index 61c63ef7..0c261579 100644 --- a/tessellation/src/path_stroke.rs +++ b/tessellation/src/path_stroke.rs @@ -629,6 +629,38 @@ impl<'l, Output: 'l + GeometryBuilder> StrokeBuilder<'l, Output> { (start_vertex, last_vertex) } + + LineJoin::Bevel => { + let neg_if_right = if front_side.is_left() { 1.0 } else { -1.0 }; + let prev_tangent = vec2(-prev_tangent.y, prev_tangent.x) * neg_if_right; + let next_tangent = vec2(-next_tangent.y, next_tangent.x) * neg_if_right; + + + let start_vertex = add_vertex!( + self, + Vertex { + position: self.current, + normal: prev_tangent, + advancement: self.length, + side: front_side, + } + ); + let last_vertex= add_vertex!( + self, + Vertex { + position: self.current, + normal: next_tangent, + advancement: self.length, + side: front_side, + } + ); + self.prev_normal = next_tangent * neg_if_right; + self.output.add_triangle(start_vertex, last_vertex, back_vertex); + + (start_vertex, last_vertex) + + } + // Fallback to Miter for unimplemented line joins _ => { let v = add_vertex!( @@ -640,7 +672,6 @@ impl<'l, Output: 'l + GeometryBuilder> StrokeBuilder<'l, Output> { side: front_side, } ); - self.prev_normal = normal; (v, v)